惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Heimdal Security Blog
SecWiki News
SecWiki News
H
Hacker News: Front Page
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
AI
AI
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
PCI Perspectives
PCI Perspectives
S
Securelist
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
Forbes - Security
Forbes - Security
T
Tor Project blog
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
I
Intezer
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
博客园 - 司徒正美
W
WeLiveSecurity
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
P
Palo Alto Networks Blog
Google DeepMind News
Google DeepMind News
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
V
Vulnerabilities – Threatpost
Jina AI
Jina AI
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
Simon Willison's Weblog
Simon Willison's Weblog
Project Zero
Project Zero
T
Threatpost
P
Privacy International News Feed
人人都是产品经理
人人都是产品经理
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research

MoonLab

VSCode + OpenOCD 远程调试开发STM32 Clangd + VSCode使用方法 BTSNOOP is FUN! 算法 - 前缀和 2025蓝桥杯赛后总结 三星ZFold 3改造 JavaScript 逆向 Steam 登录二维码 快速求解平方根倒数算法 Protobuf Android设备安装Debian成为BT下载服务器 [双系统] Windows 更新摧毁了我的Linux系统 Reading List Golang embed 使用问题 Hexo博客自动备份插件 云盘备份支持 通过汇编分析栈、函数调用 esp&ebp Git push 出现 permisson denied error 403 坑:Litepal save方法返回true却没有保存 Android Shizuku源码分析 第二篇 Android Shizuku源码分析 Android 监听第三方Activity的一举一动 Android笔记#1 View的事件分发机制解析 知乎日报的问题 使用Hexo Hello World Ubnutu 无法启动网易云音乐 - 总结 Windows 好软推荐 | 这一定是良心软件 typecho - http转https 如何评价Android P MoonLab MoonLab MoonLab 关于 项目
Keil5 编译错误 error: call to undeclared function '__enable_irq'
LingC · 2025-09-06 · via MoonLab

stm32f1xx_hal_i2c.c__enable_irqdisable_irq 函数出现了报错:

error: call to undeclared function '__enable_irq'; ISO C99 and later do not support implicit of function declarations 

在 core_cm3.h -> cmsis_compiler.h -> cmsis_armclang.h (ARM Compiler 6) 或 cmsis_armcc.h (AC5) 中对这两个方法没有定义,只有一段注释:

__enable_irqdisable_irq 控制的是PRIMASK寄存器值。

是一种 intrinsic 函数,编译器会自动识别并替换为相关的指令,它们其实是编译器的一部分,实际的定义位于Keil的 arm_compat.h 中。

/*
 * Arm Compiler 6 (armclang)
 */
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  #include "cmsis_armclang.h"

在其中,这个头文件 arm_compat.h 本该是不存在的:

.\Drivers\CMSIS\Include 中多了一个arm_compat.h文件,这会导致覆盖编译器的头文件,所以会出现一系列错误。

出现这种错误的原因,大概率是因为vscode的代码提示默认会报错 cannot open source file "arm_compat.h" , AI编码尝试去处理这个错误,会自作聪明地加上一个arm_compat.h。

如果要修复这个报错,将Keil的 ARM CMSIS-DSP 库的头文件加入.vscode/c_cpp_properties.json:

"includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/Core/Inc",
        "${workspaceFolder}/Drivers/STM32F1xx_HAL_Driver/Inc",
        "${workspaceFolder}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy",
        "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F1xx/Include",
        "${workspaceFolder}/Drivers/CMSIS/Include",
        "${workspaceFolder}/Drivers/ThridParty",
        "D:\\software\\Keli\\Core\\ARM\\ARMCLANG\\include"
      ],

HAL_RCC_OscConfig 跳到 Error_Handler

SYSTICK 的时钟固定为HCLK 时钟的1/8,在这里我们选用内部时钟源72M,所以SYSTICK的时钟为9M,即SYSTICK定时器以9M的频率递减。SysTick 主要包含CTRL、LOAD、VAL、CALIB 等4 个寄存器。

CTRL: SysTick控制和状态寄存器 LOAD: SysTick重装载值寄存器 VAL: SysTick当前值寄存器 CALIB:SysTick校准值寄存器

SysTick->CTRL COUNTFLAG CLKSOURCE TICKINT ENABLE

SysTick-> LOAD RELOAD

SysTick-> VAL CURRENT