当前位置:   article > 正文

STM32—项目四(LCD屏显示温湿度)_stm32温湿度代码

stm32温湿度代码

目录

一、LCD1602液晶显示屏

1.说明

2.例子(LDC显示字符)

二、DHT11温湿度传感器

三、实验(LCD屏显示温湿度)

1.接线

2.配置

3.main.c代码


一、LCD1602液晶显示屏

1.说明

        1.引脚接口说明

第 1 脚: VSS 为电源地

第 2 脚: VDD 接 5V 正电源

第 3 脚: VL 为液晶显示器对比度调整端,接正电源时对比度最弱,接地时对比度最高,对比度 过高时会产生“鬼影”,使用时可以通过一个 10K 的电位器调整对比度。

第 4 脚:RS 为寄存器选择,高电平时选择数据寄存器、低电平时选择指令寄存器。

第 5 脚:R/W 为读写信号线,高电平时进行读操作,低电平时进行写操作。

                当 RS 和 R/W 共 同为低电平时可以写入指令或者显示地址,

                当 RS 为低电平 R/W 为高电平时可以读忙信号,

                当 RS 为高电平 R/W 为低电平时可以写入数据。

第 6 脚:E 端为使能端,当 E 端由高电平跳变成低电平时,液晶模块执行命令。

第 7-14 脚:D0~D7 为 8 位双向数据线。

第 15 脚:背光源正极。

第 16 脚:背光源负极。

        2.模块控制指令

         3.在什么位置显示

         例如:第二行第一个字符的地址是 40H,那么是否直接写入 40H 就可以将光标定位在第二行第 一个字符的位置呢?这样不行,因为写入显示地址时要求最高位 D7 恒定为高电平 1 所以实 际写入的数据应该是 01000000B(40H) +10000000B(80H)=11000000B(C0H)。

         4.显示什么(Ascll码表)

        5.读操作时序

        6.写操作时序

2.例子(LDC显示字符)

        1.接线

        D0~D7->A0~A7        RS -> B1         RW -> B2         EN -> B10        V0 ->GND

        BLA ->VCC        BLK->GND

        2.配置

              1.SYS

        2.RCC

         3.GPIO

        3.main.c代码(显示jiayou)

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include "gpio.h"
  22. /* Private includes ----------------------------------------------------------*/
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE END Includes */
  25. /* Private typedef -----------------------------------------------------------*/
  26. /* USER CODE BEGIN PTD */
  27. /* USER CODE END PTD */
  28. /* Private define ------------------------------------------------------------*/
  29. /* USER CODE BEGIN PD */
  30. /* USER CODE END PD */
  31. /* Private macro -------------------------------------------------------------*/
  32. /* USER CODE BEGIN PM */
  33. /* USER CODE END PM */
  34. /* Private variables ---------------------------------------------------------*/
  35. /* USER CODE BEGIN PV */
  36. /* USER CODE END PV */
  37. /* Private function prototypes -----------------------------------------------*/
  38. void SystemClock_Config(void);
  39. /* USER CODE BEGIN PFP */
  40. /* USER CODE END PFP */
  41. /* Private user code ---------------------------------------------------------*/
  42. /* USER CODE BEGIN 0 */
  43. //宏定义 为了更加简便
  44. #define RS_GPIO_Port GPIOB
  45. #define RW_GPIO_Port GPIOB
  46. #define EN_GPIO_Port GPIOB
  47. #define RS_Pin GPIO_PIN_1
  48. #define RW_Pin GPIO_PIN_10
  49. #define EN_Pin GPIO_PIN_0
  50. #define RS_HIGH HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, GPIO_PIN_SET)//RS拉高
  51. #define RS_LOW HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, GPIO_PIN_RESET)
  52. #define RW_HIGH HAL_GPIO_WritePin(RW_GPIO_Port, RW_Pin, GPIO_PIN_SET)//RW拉高
  53. #define RW_LOW HAL_GPIO_WritePin(RW_GPIO_Port, RW_Pin, GPIO_PIN_RESET)
  54. #define EN_HIGH HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_SET)//EN拉高
  55. #define EN_LOW HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_RESET)
  56. void Write_Cmd_Func(uint8_t cmd)//写命令
  57. {
  58. RS_LOW;
  59. RW_LOW;
  60. EN_LOW;
  61. GPIOA->ODR = cmd;//cmd的数据按位输出给A口
  62. HAL_Delay(5);//5ms
  63. EN_HIGH;
  64. HAL_Delay(5);
  65. EN_LOW;
  66. }
  67. void Write_Data_Func(uint8_t dataShow)//写数据
  68. {
  69. RS_HIGH;
  70. RW_LOW;
  71. EN_LOW;
  72. GPIOA->ODR = dataShow;
  73. HAL_Delay(5);
  74. EN_HIGH;
  75. HAL_Delay(5);
  76. EN_LOW;
  77. }
  78. void LCD1602_INIT(void)//初始化
  79. {
  80. //(1)延时 15ms
  81. HAL_Delay(15);
  82. //(2)写指令 38H(不检测忙信号)
  83. Write_Cmd_Func(0x38);
  84. //(3)延时 5ms
  85. HAL_Delay(5);
  86. //(4)以后每次写指令,读/写数据操作均需要检测忙信号
  87. //(5)写指令 38H:显示模式设置
  88. Write_Cmd_Func(0x38);
  89. //(6)写指令 08H:显示关闭
  90. Write_Cmd_Func(0x08);
  91. //(7)写指令 01H:显示清屏
  92. Write_Cmd_Func(0x01);
  93. //(8)写指令 06H:显示光标移动设置
  94. Write_Cmd_Func(0x06);
  95. //(9)写指令 0CH:显示开及光标设置}
  96. Write_Cmd_Func(0x0c);
  97. }
  98. void LCD1602_showLine(char row, char col, char *string)
  99. {
  100. switch(row){
  101. case 1:
  102. Write_Cmd_Func(0x80+col);//第一行
  103. while(*string){
  104. Write_Data_Func(*string);
  105. string++;
  106. }
  107. break;
  108. case 2:
  109. Write_Cmd_Func(0x80+0x40+col);//第二行
  110. while(*string){
  111. Write_Data_Func(*string);
  112. string++;
  113. }
  114. break;
  115. }
  116. }
  117. /* USER CODE END 0 */
  118. /**
  119. * @brief The application entry point.
  120. * @retval int
  121. */
  122. int main(void)
  123. {
  124. /* USER CODE BEGIN 1 */
  125. /* USER CODE END 1 */
  126. /* MCU Configuration--------------------------------------------------------*/
  127. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  128. HAL_Init();
  129. /* USER CODE BEGIN Init */
  130. /* USER CODE END Init */
  131. /* Configure the system clock */
  132. SystemClock_Config();
  133. /* USER CODE BEGIN SysInit */
  134. /* USER CODE END SysInit */
  135. /* Initialize all configured peripherals */
  136. MX_GPIO_Init();
  137. /* USER CODE BEGIN 2 */
  138. LCD1602_INIT();//初始化
  139. LCD1602_showLine(1,1,"jia");//横、列、字符串
  140. LCD1602_showLine(2,1,"you");
  141. /* USER CODE END 2 */
  142. /* Infinite loop */
  143. /* USER CODE BEGIN WHILE */
  144. while (1)
  145. {
  146. /* USER CODE END WHILE */
  147. /* USER CODE BEGIN 3 */
  148. }
  149. /* USER CODE END 3 */
  150. }
  151. /**
  152. * @brief System Clock Configuration
  153. * @retval None
  154. */
  155. void SystemClock_Config(void)
  156. {
  157. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  158. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  159. /** Initializes the RCC Oscillators according to the specified parameters
  160. * in the RCC_OscInitTypeDef structure.
  161. */
  162. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  163. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  164. RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  165. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  166. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  167. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  168. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  169. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  170. {
  171. Error_Handler();
  172. }
  173. /** Initializes the CPU, AHB and APB buses clocks
  174. */
  175. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  176. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  177. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  178. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  179. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  180. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  181. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  182. {
  183. Error_Handler();
  184. }
  185. }
  186. /* USER CODE BEGIN 4 */
  187. /* USER CODE END 4 */
  188. /**
  189. * @brief This function is executed in case of error occurrence.
  190. * @retval None
  191. */
  192. void Error_Handler(void)
  193. {
  194. /* USER CODE BEGIN Error_Handler_Debug */
  195. /* User can add his own implementation to report the HAL error return state */
  196. __disable_irq();
  197. while (1)
  198. {
  199. }
  200. /* USER CODE END Error_Handler_Debug */
  201. }
  202. #ifdef USE_FULL_ASSERT
  203. /**
  204. * @brief Reports the name of the source file and the source line number
  205. * where the assert_param error has occurred.
  206. * @param file: pointer to the source file name
  207. * @param line: assert_param error line source number
  208. * @retval None
  209. */
  210. void assert_failed(uint8_t *file, uint32_t line)
  211. {
  212. /* USER CODE BEGIN 6 */
  213. /* User can add his own implementation to report the file name and line number,
  214. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  215. /* USER CODE END 6 */
  216. }
  217. #endif /* USE_FULL_ASSERT */

二、DHT11温湿度传感器

        详细介绍看(1条消息) STM32—项目三(温湿度在oled屏显示)_wlkq~的博客-CSDN博客

        1.总时序图(主机信号由代码设置波形,DHT信号由DHT11发出)

         2.初始化部分  检测模块是否存在(检测下图DHT响应信号有没有被拉低)

         3.接收数据部分(有效数据都是高电平,但持续时间不一样,可通过延时后是否被拉低来判断是0还是1)

                 DHT11传输0的时序分析

               DHT11传输1的时序分析  

         4.数据格式

        只有一根数据线DAT,发送序列指令给DHT11模块,模块就会传输一次完整的数据为40bit(8bit湿度整数数据+8bit湿度小数数据+8bi温度整数数据+8bit温度小数数据+8bit校验),高位先出。

三、实验(LCD屏显示温湿度)

1.接线

        D0~D7->A0~A7        RS -> B1         RW -> B2         EN -> B10        V0 ->GND

        BLA ->VCC        BLK->GND

        DAT->B3

2.配置

         1.SYS

        2.RCC

         3.GPIO

        4.B3既作为输入,也作为输出,则不能直接在CubeMX里配置,需要自己写代码。

3.main.c代码

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include "gpio.h"
  22. /* Private includes ----------------------------------------------------------*/
  23. /* USER CODE BEGIN Includes */
  24. #include "stdio.h"
  25. /* USER CODE END Includes */
  26. /* Private typedef -----------------------------------------------------------*/
  27. /* USER CODE BEGIN PTD */
  28. /* USER CODE END PTD */
  29. /* Private define ------------------------------------------------------------*/
  30. /* USER CODE BEGIN PD */
  31. /* USER CODE END PD */
  32. /* Private macro -------------------------------------------------------------*/
  33. /* USER CODE BEGIN PM */
  34. /* USER CODE END PM */
  35. /* Private variables ---------------------------------------------------------*/
  36. /* USER CODE BEGIN PV */
  37. /* USER CODE END PV */
  38. /* Private function prototypes -----------------------------------------------*/
  39. void SystemClock_Config(void);
  40. /* USER CODE BEGIN PFP */
  41. /* USER CODE END PFP */
  42. /* Private user code ---------------------------------------------------------*/
  43. /* USER CODE BEGIN 0 */
  44. //LCD宏定义 为了更加简便
  45. #define RS_GPIO_Port GPIOB
  46. #define RW_GPIO_Port GPIOB
  47. #define EN_GPIO_Port GPIOB
  48. #define RS_Pin GPIO_PIN_1
  49. #define RW_Pin GPIO_PIN_10
  50. #define EN_Pin GPIO_PIN_0
  51. #define RS_HIGH HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, GPIO_PIN_SET)//RS拉高
  52. #define RS_LOW HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, GPIO_PIN_RESET)
  53. #define RW_HIGH HAL_GPIO_WritePin(RW_GPIO_Port, RW_Pin, GPIO_PIN_SET)//RW拉高
  54. #define RW_LOW HAL_GPIO_WritePin(RW_GPIO_Port, RW_Pin, GPIO_PIN_RESET)
  55. #define EN_HIGH HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_SET)//EN拉高
  56. #define EN_LOW HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_RESET)
  57. //DH11宏定义
  58. #define DAT_LOW HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET)
  59. #define DAT_HIGH HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET)
  60. #define DAT_VALUE HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_3)
  61. void delay_us(uint32_t us)//微妙延时
  62. {
  63. uint32_t delay = (HAL_RCC_GetHCLKFreq() / 4000000 * us);
  64. while (delay--)
  65. {
  66. ;
  67. }
  68. }
  69. void Write_Cmd_Func(uint8_t cmd)//LCD写命令
  70. {
  71. RS_LOW;
  72. RW_LOW;
  73. EN_LOW;
  74. GPIOA->ODR = cmd;//cmd的数据按位输出给A口
  75. HAL_Delay(5);//5ms
  76. EN_HIGH;
  77. HAL_Delay(5);
  78. EN_LOW;
  79. }
  80. void Write_Data_Func(uint8_t dataShow)//LCD写数据
  81. {
  82. RS_HIGH;
  83. RW_LOW;
  84. EN_LOW;
  85. GPIOA->ODR = dataShow;
  86. HAL_Delay(5);
  87. EN_HIGH;
  88. HAL_Delay(5);
  89. EN_LOW;
  90. }
  91. void LCD1602_INIT(void)//LCD初始化
  92. {
  93. //(1)延时 15ms
  94. HAL_Delay(15);
  95. //(2)写指令 38H(不检测忙信号)
  96. Write_Cmd_Func(0x38);
  97. //(3)延时 5ms
  98. HAL_Delay(5);
  99. //(4)以后每次写指令,读/写数据操作均需要检测忙信号
  100. //(5)写指令 38H:显示模式设置
  101. Write_Cmd_Func(0x38);
  102. //(6)写指令 08H:显示关闭
  103. Write_Cmd_Func(0x08);
  104. //(7)写指令 01H:显示清屏
  105. Write_Cmd_Func(0x01);
  106. //(8)写指令 06H:显示光标移动设置
  107. Write_Cmd_Func(0x06);
  108. //(9)写指令 0CH:显示开及光标设置}
  109. Write_Cmd_Func(0x0c);
  110. }
  111. void LCD1602_showLine(char row, char col, char *string)//LCD行、列、字符串显示
  112. {
  113. switch(row){
  114. case 1:
  115. Write_Cmd_Func(0x80+col);//第一行
  116. while(*string){
  117. Write_Data_Func(*string);
  118. string++;
  119. }
  120. break;
  121. case 2:
  122. Write_Cmd_Func(0x80+0x40+col);//第二行
  123. while(*string){
  124. Write_Data_Func(*string);
  125. string++;
  126. }
  127. break;
  128. }
  129. }
  130. void DHT_GPIO_Init(uint32_t Mode)//初始化GPIO口,PB3口接温度传感器DAT
  131. {
  132. GPIO_InitTypeDef GPIO_InitStruct = {0};
  133. __HAL_RCC_GPIOB_CLK_ENABLE();//时钟
  134. GPIO_InitStruct.Pin = GPIO_PIN_3;
  135. GPIO_InitStruct.Mode = Mode;//输出还是输入
  136. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  137. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  138. }
  139. void DHT11_Start()//DHT11初始化开始信号
  140. {
  141. //下面是主机信号
  142. DHT_GPIO_Init(GPIO_MODE_OUTPUT_PP);//PA5设置为输出推挽模式
  143. DAT_HIGH;
  144. DAT_LOW;
  145. HAL_Delay(30);//ms
  146. DAT_HIGH;
  147. DHT_GPIO_Init(GPIO_MODE_INPUT);//PA5设置为输入模式
  148. //下面是DHT信号,如果符合DHT信号时序图就进行运行
  149. while(DAT_VALUE);
  150. //dht=0
  151. while(!DAT_VALUE);
  152. //dht=1
  153. while(DAT_VALUE);//之后开始传输数据
  154. //dht=0
  155. }
  156. uint8_t data[5];//存放DH11数据
  157. void DHT11_Read()//接收DH11数据
  158. {
  159. int i;
  160. int j;
  161. char tmp;//移位,存放8个bit
  162. char flag;//标志位
  163. DHT11_Start();//重启进入高速模式之后才发送bit
  164. DHT_GPIO_Init(GPIO_MODE_INPUT);//PA5设置为输入模式
  165. for(i = 0;i < 5;i++){//取4个字节
  166. for(j=0;j<8;j++){//每个字节取8个bit
  167. while(!DAT_VALUE);//卡g点数据来会从0变成1
  168. delay_us(40); //延时读取
  169. if(DAT_VALUE == 1){
  170. flag = 1;
  171. while(DAT_VALUE);//等待变位70us下一个bit
  172. }else{
  173. flag = 0;
  174. }
  175. tmp = tmp << 1;//左移一位或者 tmp<<=1,为了使先出来的bit到高位
  176. tmp |= flag;//可以为 tmp=tmp|flag
  177. }
  178. data[i] = tmp;//得到8个bit为一个字节,存放在数组里
  179. }
  180. }
  181. /* USER CODE END 0 */
  182. /**
  183. * @brief The application entry point.
  184. * @retval int
  185. */
  186. int main(void)
  187. {
  188. /* USER CODE BEGIN 1 */
  189. char SpeedMes[16];//存放显示的字符串
  190. /* USER CODE END 1 */
  191. /* MCU Configuration--------------------------------------------------------*/
  192. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  193. HAL_Init();
  194. /* USER CODE BEGIN Init */
  195. /* USER CODE END Init */
  196. /* Configure the system clock */
  197. SystemClock_Config();
  198. /* USER CODE BEGIN SysInit */
  199. /* USER CODE END SysInit */
  200. /* Initialize all configured peripherals */
  201. MX_GPIO_Init();
  202. /* USER CODE BEGIN 2 */
  203. /* USER CODE END 2 */
  204. /* Infinite loop */
  205. /* USER CODE BEGIN WHILE */
  206. while (1)
  207. {
  208. /* USER CODE END WHILE */
  209. /* USER CODE BEGIN 3 */
  210. LCD1602_INIT();//初始化
  211. DHT11_Read();//读取数据
  212. sprintf(SpeedMes,"H:%d.%d",data[0], data[1]);
  213. LCD1602_showLine(1,0,SpeedMes);//横、列、字符串
  214. sprintf(SpeedMes,"T:%d.%d",data[2], data[3]);
  215. LCD1602_showLine(2,0,SpeedMes);//横、列、字符串
  216. HAL_Delay(600);// 600毫秒
  217. }
  218. /* USER CODE END 3 */
  219. }
  220. /**
  221. * @brief System Clock Configuration
  222. * @retval None
  223. */
  224. void SystemClock_Config(void)
  225. {
  226. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  227. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  228. /** Initializes the RCC Oscillators according to the specified parameters
  229. * in the RCC_OscInitTypeDef structure.
  230. */
  231. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  232. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  233. RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  234. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  235. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  236. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  237. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  238. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  239. {
  240. Error_Handler();
  241. }
  242. /** Initializes the CPU, AHB and APB buses clocks
  243. */
  244. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  245. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  246. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  247. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  248. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  249. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  250. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  251. {
  252. Error_Handler();
  253. }
  254. }
  255. /* USER CODE BEGIN 4 */
  256. /* USER CODE END 4 */
  257. /**
  258. * @brief This function is executed in case of error occurrence.
  259. * @retval None
  260. */
  261. void Error_Handler(void)
  262. {
  263. /* USER CODE BEGIN Error_Handler_Debug */
  264. /* User can add his own implementation to report the HAL error return state */
  265. __disable_irq();
  266. while (1)
  267. {
  268. }
  269. /* USER CODE END Error_Handler_Debug */
  270. }
  271. #ifdef USE_FULL_ASSERT
  272. /**
  273. * @brief Reports the name of the source file and the source line number
  274. * where the assert_param error has occurred.
  275. * @param file: pointer to the source file name
  276. * @param line: assert_param error line source number
  277. * @retval None
  278. */
  279. void assert_failed(uint8_t *file, uint32_t line)
  280. {
  281. /* USER CODE BEGIN 6 */
  282. /* User can add his own implementation to report the file name and line number,
  283. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  284. /* USER CODE END 6 */
  285. }
  286. #endif /* USE_FULL_ASSERT */
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/606403
推荐阅读
相关标签
  

闽ICP备14008679号