Other Parts Discussed in Thread: CC1310
Tool/software: TI-RTOS
I'm trying to use CC1310 as I2C slave.
TI-RTOS version:
TI-RTOS for CC13xx and CC26xx 2.21.0.06
Compilation of my source works, but when linking, a particular object needed by TI-RTOS can't be resolved:
symbol: I2CSlave_config,
first referenced in: products/tidrivers_cc13xx_cc26xx_2_21_00_04/packages/ti/drivers/lib/drivers_cc13xxware.aem3<I2CSlave.oem3>
error:
unresolved symbol I2CSlave_config, first referenced in C:/ti/tirex-content/tirtos_cc13xx_cc26xx_2_21_00_06/products/tidrivers_cc13xx_cc26xx_2_21_00_04/packages/ti/drivers/lib/drivers_cc13xxware.aem3<I2CSlave.oem3>
Code:
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <xdc/cfg/global.h> // needed to get the global from the .cfg file
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/I2CSlave.h>
/* Example/Board Header files */
#include "Board.h"
uint8_t commandBuffer[10];
uint8_t mirrorRegister[100];
I2CSlave_Handle i2cSlave;
bool processBytes(uint8_t *command);
/*
* ======== fnTaskDisplay ========
* Handle (the optional) LCD display. The Task_sleep is determined by arg0 which
* is configured for the fnTaskDisplay Task instance.
*/
Void fnTaskI2CSlave(UArg arg0, UArg arg1) {
I2CSlave_Params i2cSlaveParams;
int i = 0;
/* Call driver init functions */
I2CSlave_init();
/* Initialize all buffers */
for (i = 0;i < 10; i++) {
/* Initializing the commandBuffer[0-9] = 0x00 */
commandBuffer[i] = 0x00;
}
for (i = 0;i < 100; i++) {
/* Initializing mirrorRegister[] with 1,2,3,....100 */
mirrorRegister[i] = 0x55;
}
/* Create I2CSlave for usage */
I2CSlave_Params_init(&i2cSlaveParams);
i2cSlaveParams.transferMode = I2CSLAVE_MODE_BLOCKING;
i2cSlave = I2CSlave_open(CC1310_LAUNCHXL_I2C0, &i2cSlaveParams);
if (NULL == i2cSlave) {
// log
}
/* Loop forever waiting for commands from master */
while (1) {
if (I2CSlave_read(i2cSlave, commandBuffer, 5))
if (!processBytes(commandBuffer)) {
// log
}
}
}
bool processBytes(uint8_t *command)
{
bool retVal = true;
switch (command[0])
{
/*
* Command: GETSTATUS Cmd from Master.
* command[0] = 0x01 [CMD]
* Response: I2CSlave_write contents of mirrorRegister[0]
* Content of mirrorRegister[0] is considered as Status byte
*/
case 0x01:
retVal = I2CSlave_write(i2cSlave, &mirrorRegister[0], 1);
break;
/*
* Command: SETSTATUS Cmd from Master.
* command[0] = 0x02 [CMD]
* command[1] = Status value to be updated
* Response: OverWrite content of mirrorRegister[0] with contents of
* command[1]
*/
case 0x02:
mirrorRegister[0] = command[1];
break;
/*
* READBLOCK Cmd from Master. I2CSlave_write requested bytes
* of mirrorRegister
* command[0] = 0x03 [READBLOCK CMD]
* command[1] = start offset of bytes to be read from mirrorRegister
* command[2] = numberOfBytes to be read
* buffer
*/
case 0x03:
retVal = I2CSlave_write(i2cSlave, &mirrorRegister[command[1]],
command[2]);
break;
/*
* Command: WRITEBLOCK Cmd from Master.
* command[0] = 0x04 [CMD]
* command[1] = start offset of bytes to be written to mirrorRegister
* command[2] = numberOfBytes to be written
* Response: Issue I2CSlave_read() to read command[2] number of bytes
* from master
*/
case 0x04:
retVal = I2CSlave_read(i2cSlave, &mirrorRegister[command[1]],
command[2]);
break;
}
return retVal;
}