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: Adding i2c support to the sample project TimeApp

Part Number: CC2541
Other Parts Discussed in Thread: CC2540

My issue is very simple and simple to reproduce.
Here is what I am trying to do:
I am using the TimeApp sample in the BLE-CC254x-1.4.0 developer kit as starting point.
This sample is using SPI to write to an LCD display. My display is using i2c and not SPI.
The only thing I want to do is to change the communication with the display from SPI to I2c.
To do this I need to include the i2c hal driver in my project. I can see that there are two different hal_i2c drivers in the development kit
The first I can see is in the 
1. C:\Texas Instruments\BLE-CC254x-1.4.0\Components\hal\target\CC2541ST 
The other is in the:
2. C:\Texas Instruments\BLE-CC254x-1.4.0\Components\hal\target\CC2541ARC
As far as I can see the hal_i2c.c files are different in size  so I am not sure which one I have to choose. I can see that the SensorTag sample is using the
C:\Texas Instruments\BLE-CC254x-1.4.0\Components\hal\target\CC2541ST 
driver.
My next problem is : How to add the driver to the TimeApp project in IAR EWB.
No matter where I right click in the project Window (see attached image) I can select Add.. from the context menu so it is not clear which branch in the project window I have 
to add the driver to.
As you can see in the attached image I added the hal_i2c.h to the:
 HAL\include branch 
and the hal_i2c.c to the :
HAL\Target\CC2540EB\Drivers branch.
So far so good
In order to use the i2c driver I added 
#include "hal_i2c.h"
to the top of the timeapp.c file  and got the following error:
Building configuration: TimeApp - CC2541EM Slave
Updating build tree...
timeApp_Main.c  
Fatal Error[Pe1696]: cannot open source file "hal_i2c.h" C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\Source\timeApp_Main.c 50
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\Source\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\common\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\target\
CC2540EB\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\osal\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\services\
saddr\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
phy\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\hci\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\host\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\common\cc2540\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\Profiles\Roles\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\Profiles\Batt\"
            searched: "C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\"
            searched: "C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\clib\"
Error while running C/C++ Compiler
timeapp.c  
Fatal Error[Pe1696]: cannot open source file "hal_i2c.h" C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\Source\timeapp.c 50
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\Source\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\common\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\hal\target\
CC2540EB\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\osal\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\services\
saddr\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
phy\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\controller\
include\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\hci\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\..\..\Components\ble\host\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\common\cc2540\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\Profiles\Roles\"
            searched: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\TimeApp\CC2541\..\..\Profiles\Batt\"
            searched: "C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\"
            searched: "C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.4\8051\inc\clib\"
Error while running C/C++ Compiler
 
Total number of errors: 2
Total number of warnings: 0 
To summarize my issues :
1. Which I2C driver to use
2. How to add it to the project
3. Lastely, solve the compilation error (could not find the hal_i2c.h file)
  • Hey Itamar,

    I've assigned your post to an expert to help with. For now, here are some comments.

    1. Which I2C driver to use

    This will likely depend on your end application. It looks like the CC2541ARC has more functionality (i.e. can act as a I2C slave). For now, it sounds like you just need the other version which only has functionality to act as an I2C master ( CC2541ST).

    As you mention, the SensorTag application implements the I2C driver so I would definitely start looking at that project for help with #2 and #3.

    3. Lastely, solve the compilation error (could not find the hal_i2c.h file)

    You might have to add this to the file search path since it sounds like IAR is not finding the file referenced in the project. Make sure to add the path to IAR where it is stored on your local machine. IAR more commonly links files from locations without the need to import it to the workspace, so be sure you are telling IAR exactly where this file is.