工具与软件:
大家好!
问题说明:
我目前正在开发一个具有以下代码结构等特性的应用程序:
// File interface.h #pragma FUNC_ALWAYS_INLINE(some_function) void some_function(uint16_t some_argument);
//File interface_implementation.c #include "interface.h" void some_function(uint16_t some_argument) { // Some code that interacts with HW registers via pointers to volatiles // have also tried with code that does not access HW registers at all and also does not work }
// File user_file.c #include "interface.h" #pragma INTERRUPT(user_isr) static void user_isr(void) { uint16_t argument = 10U; some_function(argument); // ISR flag handling etc.. }
我的目标是在 user_isr 中断中内联 some_function 调用,而不必对 some_function 使用 static inline。 这样就不需要公开 some_function 实现的所有内部信息。 鉴于 user_file.c 文件只能看到 some_function 的声明、而不能看到其实现、我依赖链接器内联 some_function 调用。 根据文档 SPRU514Z 第2.11章、链接器应该能够内联函数。 如果我在这方面有误、请更正我、还有其他方法可以解决此问题。
通过查看分解的输出 文件、可以看到 LCR 指令用于调用 Soome_function、从而确认它没有被内联。
测试过的内容(但未能解决问题):
我已经查看了 SPRU514Z 文档以了解如何做到这一点、并提出了以下尝试(在我的情况下无法正常工作):
- CGT 版本:TI-CGT-C2000_20.2.1.LTS
- #pragma FUNC_ALWAYS_INLINE (some_function)恰好在函数声明之前。
- 编译器标志: -opt_level=4 --opt_for_speed=5
- 链接器标志: -opt_level=4 --opt_for_speed=5 (尽管我认为它不适用于链接器)
此外、我已经看到、 SPRU514Z 的第2.11.2节中 提到、在编译器"难以"执行内联的情况下、不会进行内联。 如果我没有错过任何东西,我不做任何这些。 "未声明内联项目符号..."让我感到怀疑,尽管我尝试明确使用内联键盘,但它没有帮助。
我肯定丢失了一些东西、但我不明白它是什么。 您能帮助我解决这个问题吗? 如果您 需要更多信息、我很乐意为您提供。
提前非常感谢您的帮助、
此致、
Francesc.