function - Stm Cube IDE ERROR:函数比较错误
问题描述
我正在通过 STMBUBEIDE 程序试验 STM32f407vg 板。
首先,我准备自己的库文件,并在中断部分进行设置。
如果我无法摆脱这个错误的原因怎么办?
首先,我的 src 文件有一个 griodriver.c 文件。我在其中的定义:
uint8_t portcode = GPIO_BASE_ADDR_TO_CODE (pGPIOHandle-> pGPIOx);
然后我写我的函数,这样它就回来了。
uint16_t GPIO_BASE_ADDR_TO_CODE(*x)
{
if(x==GPIOA) { return 0; }
else if(x==GPIOB) { return 1; }
else if(x==GPIOC) { return 2; }
else if(x==GPIOD) { return 3; }
else if(x==GPIOE) { return 4; }
else if(x==GPIOF) { return 5; }
else if(x==GPIOG) { return 6; }
}
如果我删除循环内的指针,我会得到指针和整数错误之间的比较。
每当我编译时,都会出现错误。
我的错误说明了该功能:这是警告错误。
Description Resource Path Location Type
implicit declaration of function 'GPIO_BASE_ADDR_TO_CODE'; did you mean 'GPIOJ_BASEADDR'?
[- Wimplicit-function-declaration] stm32f407xx_gpio_driver.c /stm32f407xx/drivers/Src
line 253 C/C++ Problem
但是我还有另外两个错误是错误的。 在此处输入图像描述
第一的:
1. ERROR: Description Resource Path Location Type
make: *** [drivers/Src/subdir.mk:18: drivers/Src/stm32f407xx_gpio_driver.o]
Error 1 stm32f407xx C/C++ Problem
第二:
Description Resource Path Location Type
expected declaration specifiers or '...' before '*' token stm32f407xx_gpio_driver.c
/stm32f407xx/drivers/Src line 168 C/C++ Problem
错误屏幕:
解决方案
我没有在函数中调用它,而是将其定义为 #define for
GPIO_BASEADDR_TO_CODE
if else 条件也被删除。我使用了 C 第三个条件。
3天后现在没有错误:))
你可以在下面的图片中看到我做了什么。
#define GPIO_BASEADDR_TO_CODE(x) ((x == GPIOA)?0 :\
(x == GPIOB)?1 :\
(x == GPIOA)? :\
(x == GPIOA)?3 :\
(x == GPIOA)?4 :\
(x == GPIOA)?5 :\
(x == GPIOA)?6 :\
(x == GPIOA)?7 :0 )
推荐阅读
- ruby-on-rails - Rails 祖先 gem + 渲染并以新形式选择类别/子类别
- java - 从 java 程序内部运行一个 docker 容器
- powershell - 防止在批处理文件中解释多行命令
- python - 你如何调用列表中的位置,它是一个字符串?
- c# - 如何处理特定的 IOException?
- git - 如何在不调用 Github API 的情况下获取 GitBash 中特定分支的现有 Pull Request ID 和 Url?
- blender - Solidworks 中拓扑的高级控制
- saml-2.0 - 如何将硬编码的 SAML2 响应发送到 AuthServices/Acs 端点以进行测试
- github - 如何链接到markdown文件(目录)中包含点(。)或逗号(,)的标题?
- javascript - Html - span 标签中的文本不是内联的?