STM32CubeMX生成HAL库文件,出现identifier “HAL_StatusTypeDef” is undefined错误

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:11   1740   0

使用STM32CubeMX生成了一个工程文件,在使用串口库文件是,出现:“”identifier “HAL_StatusTypeDef” is undefined”错误。

经过测试发现是在添加的usart.c文件中,直接调用了#include "stm32f1xx_hal_uart.h"头文件,便会出现上述错误,解决方法经过测试,在调用#include "stm32f1xx_hal_uart.h"头文件时首先调用#include "stm32f1xx_hal.h"头文件,该头文件根据自己工程修改,我的是STM32F103,用的是stm32f1xx_hal.h。

将上述头文件添加到#include "stm32f1xx_hal_uart.h"头文件前,再次编译,解决该问题。

为了美观,将#include "stm32f1xx_hal.h"放入usart.h头文件中,将usart.h的头文件调用放到#include "stm32f1xx_hal_uart.h"前,如下图所示,异曲同工。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP