/** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** ** This notice applies to any and all portions of this file * that are not between comment pairs USER CODE BEGIN and * USER CODE END. Other portions of this file, whether * inserted by the user or by software development tools * are owned by their respective copyright owners. * * COPYRIGHT(c) 2018 STMicroelectronics * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32l1xx_hal.h" /* USER CODE BEGIN Includes */ #include "math.h" //#include "intrinsics.h" /* USER CODE BEGIN Includes */ unsigned char reg; uint8_t hi[2]={'h','i'}; uint8_t low[2]={'l','o'}; uint8_t temp[2]; char wakeup=0; #define SCLL GPIOB->ODR&=~(1<<8) #define SCLH GPIOB->ODR|=(1<<8) #define SDAL GPIOB->ODR&=~(1<<9) #define SDAH GPIOB->ODR|=(1<<9) #define readstate() {GPIOA->CRL&=0XFFFFF0FF; GPIOA->CRL|=0X00000400;}//GPIOA->ODR&=~(1<<2);} #define writestate() {GPIOA->CRL&=0XFFFFF0FF; GPIOA->CRL|=0X00000300;} #define data() ((GPIOA->IDR>>1)&1) // Define some pins to output diagnostic data. // void delay1Us(uint16_t microSecs) { while(microSecs--) { /* 32 NOPs == 1 usecs */ __NOP(); //__NOP(); __NOP(); __NOP(); __NOP(); //asm("nop"); __NOP(); //__NOP(); __NOP(); __NOP(); //asm("nop"); // asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); } } // // SHT10 related commands. #define RESETsht10 0x1e /// first 3 bits 000 and last 5 bits 11110 #define STATUS_REG_R 0x07 /// first 3 bits 000 and last 5 bits 00111 #define STATUS_REG_W 0x06 /// first 3 bits 000 and last 5 bits 00110 #define MEASURE_TEMP 0X03 /// first 3 bits 000 and last 5 bits 00011 #define MEASURE_HUMI 0X05 /// first 3 bits 000 and last 5 bits 00101 #define noACK 0 #define ACK 1 #define HUMI 2 #define TEMP 1 // // Buffer to hold the I2C data. // uint8_t Temp[2]; uint8_t RH[2]; typedef union { unsigned int j; float f; }value; value humi_val,temp_val; void set_datapinasinput() //Function for making data pin as input { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ // __HAL_RCC_GPIOB_CLK_ENABLE(); // __HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pin Output Level */ // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET); /*Configure GPIO pins : PC0 PC1 */ GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_INPUT ; // GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } void set_datapinasoutput() //Function for making data pin as output { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ // __HAL_RCC_GPIOB_CLK_ENABLE(); // __HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pin Output Level */ //HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET); /*Configure GPIO pins : PC0 PC1 */ GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; //GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } char s_write_byte(unsigned char value) //function for writing the byte { unsigned char i,error=0; //set_datapinasoutput(); for (i=0x80;i>0;i/=2) //shift bit for masking { if(i&value) HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); //masking value with i , write to SENSI-BUS else HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); //clk for SENSI-BUS HAL_Delay(3);//__NOP(); //__NOP(); //__NOP(); //pulswith approx. 5 us HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); HAL_Delay(3); } HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); //release DATA-line //set_datapinasinput(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); //clk #9 for ack HAL_Delay(3); error=HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8); //check ack (DATA will be pulled down by SHT11) // set_datapinasoutput(); HAL_Delay(1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); return error; //error=1 in case of no acknowledge } char s_read_byte(unsigned char ack) { unsigned char i,val=0; // set_datapinasoutput(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); //release DATA-line HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); //set_datapinasinput(); for (i=0x80;i>0;i/=2) //shift bit for masking { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); //clk for SENSI-BUS if (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) val=(val | i); //read bit HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); HAL_Delay(1); } // set_datapinasoutput(); if(ack){ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_RESET); } else { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); } //in case of "ack==1" pull down DATA-Line HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); //clk #9 for ack HAL_Delay(3);//__NOP(); //__NOP(); //__NOP(); //pulswith approx. 5 us HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); //release DATA-line // set_datapinasinput(); return val; } void s_transstart(void) { // set_datapinasoutput(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); //Initial state HAL_Delay(1);//__NOP(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); HAL_Delay(1);//__NOP(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_RESET); HAL_Delay(1);//__NOP(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); HAL_Delay(3);//__NOP(); // __NOP(); //__NOP(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); HAL_Delay(1);//__NOP(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); HAL_Delay(1);//__NOP(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); } void s_connectionreset(void) { unsigned char i; //set_datapinasoutput(); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); //Initial state for(i=0;i<9;i++) //9 SCK cycles { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); } s_transstart(); //transmission start } char s_softreset(void) { unsigned char error=0; // s_connectionreset(); //reset communication error+=s_write_byte(RESETsht10); //send RESET-command to sensor return error; //error=1 in case of no response form the sensor } char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum) { unsigned char error=0; s_transstart(); //transmission start error=s_write_byte(STATUS_REG_R); //send command to sensor *p_value=s_read_byte(ACK); //read status register (8-bit) *p_checksum=s_read_byte(noACK); //read checksum (8-bit) return error; //error=1 in case of no response form the sensor } char s_write_statusreg(unsigned char *p_value) { unsigned char error=0; s_transstart(); //transmission start error+=s_write_byte(STATUS_REG_W);//send command to sensor error+=s_write_byte(*p_value); //send value of status register return error; //error>=1 in case of no response form the sensor } char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode) { unsigned error=0; unsigned int i; s_transstart(); //transmission start switch(mode){ //send command to sensor case TEMP : error+=s_write_byte(MEASURE_TEMP); break; case HUMI : error+=s_write_byte(MEASURE_HUMI); break; default : break; } // set_datapinasinput(); for (i=0;i<65535;i++) if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)==0) break; //wait until sensor has finished the measurement if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) error+=1; // or timeout (~2 sec.) is reached // set_datapinasoutput(); *(p_value) =s_read_byte(ACK); //read the first byte (MSB) *(p_value+1)=s_read_byte(ACK); //read the second byte (LSB) *p_checksum =s_read_byte(noACK); //read checksum return error; } void calc_sth10(float *p_humidity ,float *p_temperature) { const float C1=-4.0; // for 12 Bit const float C2=+0.0405; // for 12 Bit const float C3=-0.0000028; // for 12 Bit const float T1=+0.01; // for 14 Bit @ 5V const float T2=+0.00008; // for 14 Bit @ 5V float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit float t=*p_temperature; // t: Temperature [Ticks] 14 Bit float rh_lin; // rh_lin: Humidity linear float rh_true; // rh_true: Temperature compensated humidity float t_C; // t_C : Temperature [°C] t_C=t*0.01 - 40; //calc. temperature from ticks to [°C] rh_lin=C3*rh*rh + C2*rh + C1; //calc. humidity from ticks to [%RH] rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //calc. temperature compensated humidity [%RH] if(rh_true>100)rh_true=100; //cut if the value is outside of if(rh_true<0.1)rh_true=0.1; //the physical possible range *p_temperature=t_C; //return temperature [°C] *p_humidity=rh_true; //return humidity[%RH] } float calc_dewpoint(float h,float t) { float logEx,dew_point; logEx=0.66077+7.5*t/(237.3+t)+(log10(h)-2); dew_point = (logEx - 0.66077)*237.3/(0.66077+7.5-logEx); return dew_point; } /* USER CODE END Includes */ /* Private variables ---------------------------------------------------------*/ UART_HandleTypeDef huart2; /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_USART2_UART_Init(void); /* USER CODE BEGIN PFP */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE END PFP */ /* USER CODE BEGIN 0 */ /*HAL_GPIO_EXTI_Callback(gpio) { wakeup=1; }*/ /* USER CODE END 0 */ /** * @brief The application entry point. * * @retval None */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ // SystemPower_Config(); /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ float dew_point; unsigned char error,checksum; HAL_UART_Transmit_IT(&huart2,hi,2); while (1) { //HAL_UART_Transmit_IT(&huart2,hi,2); //HAL_UART_Receive_IT(&huart2,temp,2); //HAL_UART_Transmit(&huart2,temp,2,0); /* if(temp[0]==0x31) { HAL_UART_Transmit(&huart2,temp,2,0); temp[0]=0; temp[1]=0; // wakeup=1; }*/ //led_blink(); // __wait_for_interrupt(); // HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET); // HAL_PWR_DisablePVD( ); // Enable Ultra low power mode // HAL_PWREx_EnableUltraLowPower( ); //HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); // Enable the fast wake up from Ultra low power mode // HAL_PWREx_EnableFastWakeUp( ); // HAL_SuspendTick(); //Enter to sleep Mode using the HAL function HAL_PWR_EnterSLEEPMode with WFI instruction // HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI); // HAL_PWR_EnterSTOPMode( PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE ); /*if(wakeup&&temp[0]==0x31) { __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); // HAL_Delay(100); // Enable Power Control clock __HAL_RCC_PWR_CLK_ENABLE(); //SystemClock_Config(); MX_GPIO_Init(); MX_USART2_UART_Init(); HAL_UART_Transmit_IT(&huart2,low,2); HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET); wakeup=0; temp[0]=0; temp[1]=0; }*/ // else wakeup=0; //HAL_PWR_EnterSTANDBYMode(); s_connectionreset(); //HAL_Delay(100); error=0; error+=s_measure((unsigned char*) &humi_val.j,&checksum,HUMI); //measure humidity error+=s_measure((unsigned char*) &temp_val.j,&checksum,TEMP); //measure temperature if(error!=0) { s_connectionreset(); //in case of an error: connection reset // beepone(1,500,1); } else { humi_val.f=(float)humi_val.j; //converts integer to float temp_val.f=(float)temp_val.j; //converts integer to float calc_sth10(&humi_val.f,&temp_val.f); //calculate humidity, temperature dew_point=calc_dewpoint(humi_val.f,temp_val.f); //calculate dew point Temp[0]=(uint8_t)temp_val.f; RH[0]=(uint8_t)humi_val.f; HAL_UART_Transmit(&huart2,&Temp[0],1,0); HAL_UART_Transmit(&huart2,&RH[0],1,0); } /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; /**Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /**Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = 16; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } /**Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } /**Configure the Systick interrupt time */ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); /**Configure the Systick */ HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); } /* USART2 init function */ static void MX_USART2_UART_Init(void) { huart2.Instance = USART2; huart2.Init.BaudRate = 9600; huart2.Init.WordLength = UART_WORDLENGTH_8B; huart2.Init.StopBits = UART_STOPBITS_1; huart2.Init.Parity = UART_PARITY_NONE; huart2.Init.Mode = UART_MODE_TX_RX; huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart2.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&huart2) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } } /** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET); /*Configure GPIO pin : B1_Pin */ GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LD2_Pin */ GPIO_InitStruct.Pin = LD2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PB8 PB9 */ GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } /* USER CODE BEGIN 4 */ void PreSleepProcessing(uint32_t *ulExpectedIdleTime) { // place for user code *ulExpectedIdleTime = 0; //HAL_UART_DeInit(&huart2); // Disable the Power Voltage Detector HAL_PWR_DisablePVD( ); // Enable Ultra low power mode HAL_PWREx_EnableUltraLowPower( ); // Enable the fast wake up from Ultra low power mode //HAL_PWREx_EnableFastWakeUp( ); //Enter to sleep Mode using the HAL function HAL_PWR_EnterSLEEPMode with WFI instruction // HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); HAL_PWR_EnterSTOPMode( PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI ); //HAL_PWR_EnterSTANDBYMode(); } void PostSleepProcessing(uint32_t *ulExpectedIdleTime) { // Enable Power Control clock __HAL_RCC_PWR_CLK_ENABLE(); SystemClock_Config(); MX_GPIO_Init(); } void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { /* Prevent unused argument(s) compilation warning */ UNUSED(GPIO_Pin); //xTaskResumeFromISR(defaultTaskHandle); /* NOTE : This function Should not be modified, when the callback is needed, the HAL_GPIO_EXTI_Callback could be implemented in the user file */ } /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @param file: The file name as string. * @param line: The line in file as a number. * @retval None */ void _Error_Handler(char *file, int line) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/