This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2541:向示例项目 TimeApp 添加 i2c 支持

Guru**** 664280 points
Other Parts Discussed in Thread: CC2541, CC2540
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1055470/cc2541-adding-i2c-support-to-the-sample-project-timeapp

器件型号:CC2541
主题中讨论的其他器件: CC2540
我的问题很简单、很容易重现。
下面是我要尝试做的:
我将 BLE-CC254x-1.4.0开发人员套件中的 TimeApp 示例用作起点。
此示例 使用 SPI 写入 LCD 显示屏。 我的显示屏使用 i2c 而不是 SPI。
我唯一想做的就是将与显示屏的通信从 SPI 更改为 I2C。
为此、我需要在项目中包含 i2c hal 驱动程序。 我可以看到、开发套件中有两个不同的 hal_i2c 驱动程序
我可以看到的第一个是在中  
C:\Texas Instruments\BLE-CC254x-1.4.0\Components\hal\target\CC2541ST  
另一个位于:
2. C:\Texas Instruments\BLE-CC254x-1.4.0\Components\hal\target\CC2541ARC
就我所看到的 hal_i2c.c 文件大小不同 、因此我不确定必须选择哪一个。 我可以看到 SensorTag 样本正在使用
C:\Texas Instruments\BLE-CC254x-1.4.0\Components\hal\target\CC2541ST  
驱动器。
我的下一个问题是:如何将驱动程序添加到 IAR EWB 中的 TimeApp 项目中。
无论我在项目窗口中的哪个位置右键点击(请参见所附图像)、我都可以选择添加。 从而不会清除项目窗口中的哪个分支  
添加驱动程序。
正如您在随附的图像中看到的、我将 hal_i2c.h 添加到了:
 HAL\include  分支  
将 hal_i2c.c 添加到:
HAL\Target\CC2540EB\Drivers 分支。
到目前为止都很好
以便使用 i2c 驱动程序  
#include "hal_i2c.h"
到 timeapp.c 文件的顶部 、并出现以下错误:
构建配置:TimeApp - CC2541EM 从设备
正在更新生成树...
timeApp_Main.c  
致命错误[Pe1696]:无法打开源文件"hal_i2c.h" C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\Source\timeApp_Main.c 50
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\Source\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\common\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\.\include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\Include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\target\
CC2540EB\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\osal\Include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\..\Components\services\
saddr\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Components\ble\include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
PHY\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
包含\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Components\ble\HCI\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Components\ble\host\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\common\CC2540\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Profiles\Roles\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Profiles\Baty\"
      搜索:"C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\"
      搜索:"C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\clib\"
运行 C/C++编译器时出错
timeapp.c  
致命错误[Pe1696]:无法打开源文件"hal_i2c.h" C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\Source\timeapp.c 50
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\Source\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\common\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\.\include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\Include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\target\
CC2540EB\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\osal\Include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\..\Components\services\
saddr\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Components\ble\include\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
PHY\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
包含\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Components\ble\HCI\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Components\ble\host\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\common\CC2540\"
      搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Profiles\Roles\"
      已搜索:"C:\Texas Instruments\BLE-CC254x-1.4.0\projects\ble\TimeApp\CC2541\..\..\Profiles\Baty\"
      搜索:"C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\"
      搜索:"C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\clib\"
运行 C/C++编译器时出错
 
错误总数:2.
警告总数:0  
总结 我的问题:
要使用哪个 I2C 驱动程序
2.如何将其添加到项目中
3.最后,解决编译错误(找不到 hal_i2c.h 文件)
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Itamar、

    我已将您的帖子分配给一位专家以提供帮助。 现在、这里是一些评论。

    [引用 userid="179214" URL"~/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1055470/cc2541-adding-i2c-support-to-the-sample-project-timeapp ]1. 要使用哪个 I2C 驱动程序[/quot]

    这可能取决于您的最终应用。  看起来 CC2541ARC 具有更多功能(即可用作 I2C 从设备)。 目前、您似乎只需要具有仅用作 I2C 主设备(CC2541ST)功能的其他版本。

    正如您提到的、SensorTag 应用实现了 I2C 驱动程序、因此我一定会开始查看该项目以获得有关#2和#3的帮助。

    [引用 userid="179214" URL"~/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1055470/cc2541-adding-i2c-support-to-the-sample-project-timeapp ]3. 最后、解决编译错误(找不到 hal_i2c.h 文件)

    您可能需要将其添加到文件搜索路径中、因为听起来 IAR 找不到项目中引用的文件。 确保添加 IAR 的路径、将其存储在您的本地计算机上。 IAR 更常从 各个位置链接文件、而无需将其导入工作区、因此请确保您告诉 IAR 此文件的确切位置。