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.

CC1352P7: Using sysconfig tool to setup I2C in slave mode

Part Number: CC1352P7
Other Parts Discussed in Thread: SYSCONFIG, SYSBIOS

Merry Christmas TI,

Having dug around awhile in the Resource Explorer and experimenting with the I2C example (in master mode); and we have been able to establish communications with an on-hand sensor board.  This was our initial milestone, but in reality our first goal will be in configuring the CC1352P7-1 using TIRTOS7 for using the I2C bus in slave mode.  Is there a good example provided for this?  I have been having trouble locating these options in the sysconfig tool, so perhaps we must delve deeper into 1 of the drivers? ?  Will continue researching but your guidance would be much appreciated.

Best Regards,

Michael

  • Please see:  https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/816289/rtos-cc1352p-i2c-slave-mode and https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/969121/cc1352r-only-i2c-start-interrupt-but-no-data-interrupt

    "As far as I can tell the i2c driver in the SDK only supports master mode but the hardware does support slave mode."

    Most of the examples I've seen do not work properly, but here is one that does, at least for me:

    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>

    /* Driver Header files */
    #include <ti/display/Display.h>
    #include <ti/sysbios/runtime/System.h>

    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/i2c.h)

    /* Driver configuration */
    #include "ti_drivers_config.h"

    #define Board_I2C_SCL0 IOID_21
    #define Board_I2C_SDA0 IOID_5
    #define HANI_ADDR 0x68
    #define I2C_SLAVE_ADDR HANI_ADDR
    #define TASKSTACKSIZE 1024

    void *main_I2C_Slave_Thread(void *arg0)
    {
    uint8_t u8_Status;
    uint8_t DataIn; //A place to put a byte read from the master, if desired.
    uint8_t DataOut = 0; //Used to generate fake data to send to master.

    GPIO_init();
    Power_setDependency(PowerCC26XX_PERIPH_I2C0);
    IOCPinTypeI2c(I2C0_BASE, Board_I2C_SDA0, Board_I2C_SCL0);
    I2CSlaveInit(I2C0_BASE, I2C_SLAVE_ADDR);

    /*
    * In all cases below, if an interrupt flag is set, either a read or write to the slave data
    * register (I2C_O_SDR) is required to clear the flag. Otherwise, SCL will stay low indefinitely.
    *
    * RLED is used to indicate I2C_SLAVE_ACT_RREQ_FBR interrupt on a logic analyzer.
    * GLED is used to indicate I2C_SLAVE_ACT_RREQ interrupt on a logic analyzer.
    * GPIO_19 is used to indicate I2C_SLAVE_ACT_TREQ interrupt on a logic analyzer.
    */
    while (1)
    {
    u8_Status = I2CSlaveStatus(I2C0_BASE);

    switch (u8_Status)
    {
    case I2C_SLAVE_ACT_RREQ_FBR: //First byte after address received flag
    DataIn = I2CSlaveDataGet(I2C0_BASE); //Acknowledge by read of I2C_O_SDR
    GPIO_write(CONFIG_GPIO_RLED, CONFIG_GPIO_LED_ON);
    break;
    case I2C_SLAVE_ACT_RREQ: //Additional byte received
    DataIn = I2CSlaveDataGet(I2C0_BASE); //Acknowledge by read of I2C_O_SDR
    GPIO_write(CONFIG_GPIO_GLED, CONFIG_GPIO_LED_ON);
    break;
    case I2C_SLAVE_ACT_TREQ: //Master wants to read data.
    I2CSlaveDataPut(I2C0_BASE, DataOut); //Acknowledge by write to I2C_O_SDR
    GPIO_write(CONFIG_GPIO_19, CONFIG_GPIO_LED_ON);
    DataOut ++;
    break;
    }
    CPUdelay(500); //Delay so GPIO pulse is clearly seen on the logic analyzer.
    GPIO_write(CONFIG_GPIO_RLED, CONFIG_GPIO_LED_OFF);
    GPIO_write(CONFIG_GPIO_GLED, CONFIG_GPIO_LED_OFF);
    GPIO_write(CONFIG_GPIO_19, CONFIG_GPIO_LED_OFF);

    }
    return (NULL);

    }

    Correction...  The aforementioned "interrupt" flags are actually STATUS flags.

    Interrupt flags are I2C_SLAVE_INT_STOP, I2C_SLAVE_INT_START, AND I2C_SLAVE_INT_DATA.

  • Hi Michael

    I am afraid that our I2C driver only supports master mode, and I am not sure if slave mode support will be implemented.

    Since we do not have driver support for this, we do not have any examples either.

    I am very sorry for the inconvenience.

    BR

    SIri