Hi ti:
I am working in simplelink_cc13x2_26x2_sdk_4_30_00_54 with LP_CC2652RB.
I want to realize a I2C slave project, but there is no example in SDK. So I try to do it by dreverlib.
Following is my parts of code, that I call init_i2c() in empty's mainThread().
#include <i2c.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>
#define I2C0_SCL0 IOID_4
#define I2C0_SDA0 IOID_5
void init_i2c(void)
{
//PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
Power_setDependency(PowerCC26XX_PERIPH_I2C0);
//PRCMLoadSet();
//PRCMPeripheralRunEnable(PRCM_PERIPH_I2C0); // Enable I2C module
//PRCMPeripheralRunEnable(PRCM_PERIPH_GPIO);
//PRCMLoadSet();
I2CSlaveInit(I2C0_BASE, 0x53);
I2CIntRegister(I2C0_BASE, i2c_callback);
I2CSlaveIntEnable(I2C0_BASE, I2C_SLAVE_INT_START | I2C_SLAVE_INT_STOP | I2C_SLAVE_INT_DATA);
}
void i2c_callback(void)
{
uint32_t val;
uint32_t status = I2CSlaveIntStatus(I2C0_BASE, true);
I2CSlaveIntClear(I2C0_BASE, status);
if(status & I2C_SLAVE_INT_DATA)
{
status = I2CSlaveStatus(I2C0_BASE);
if(status & I2C_SLAVE_ACT_RREQ)
{
val = I2CSlaveDataGet(I2C0_BASE);
GPIO_toggle(CONFIG_GPIO_LED_0);
}
}
}
However, when I run i2copt3001 example to test the I2C slave project. the red_led dose NOT blink(implicit I2C get some data), but the green_led work normal(implicit mainThread() work well).
So I'm here for asking your help:
1. How to realize a I2C slave by CC2652RB, is there some documents can be referred?
2. In my above code, there is some commented lines like PRCMxxx(), I can't find define of them, where are them?
3. Actually from my code, I am NOT maping the GPIO to I2C since I do not know how to do it. Could you show me how to map the specific GPIO for SCL and SDA function?
Thanks very much for your help!
