Other Parts Discussed in Thread: SYSBIOS
Hi team,
Here's an issue from the customer may need your help:
Dynamic Switch I2C Slave Mode (to save power) is required. And the code is as follows:
int8_t hpi_i2c_open() { if(m_is_open == 0) { Power_setDependency(PowerCC26XX_PERIPH_I2C0); Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); i2cPinHandle = PIN_open(&i2cPinState, i2cPinTable); if ((PIN_SUCCESS == PINCC26XX_setMux(i2cPinHandle, CONFIG_PIN_2, IOC_PORT_MCU_I2C_MSSCL)) && (PIN_SUCCESS == PINCC26XX_setMux(i2cPinHandle, CONFIG_PIN_1,IOC_PORT_MCU_I2C_MSSDA))) { LOGI("I2C PIN set succ."); } else { LOGI("I2C PIN set failed."); } /* init i2c for slave-mode and enable interrupt */ I2CSlaveInit(I2C0_BASE, slaveAddress); LOGI("I2CSlaveInit."); /* Create an RTOS aware hardware interrupt */ Hwi_Params i2cSlave_hwiParams; Hwi_Params_init(&i2cSlave_hwiParams); LOGI("Hwi_Params_init."); i2cSlave_hwiParams.priority = INT_PRI_LEVEL7; //INTERRUPT_PRIORITY; i2cSlave_hwiHandle = Hwi_create(INT_I2C_IRQ, i2cCB, &i2cSlave_hwiParams,NULL); LOGI("Hwi_create."); if (NULL == i2cSlave_hwiHandle) { //some error occurred LOGI("i2c init error"); return -1; } I2CSlaveIntEnable(I2C0_BASE, I2C_SLAVE_INT_START | I2C_SLAVE_INT_STOP | I2C_SLAVE_INT_DATA); m_is_open = 1; LOGW("i2c open ok!!"); } return 0; } int8_t hpi_i2c_close() { if(m_is_open == 1) { PIN_close(i2cPinHandle); Hwi_delete(i2cSlave_hwiHandle); Power_releaseDependency(PowerCC26XX_PERIPH_I2C0); Power_releaseConstraint(PowerCC26XX_SB_DISALLOW); Power_releaseConstraint(PowerCC26XX_IDLE_PD_DISALLOW); m_is_open = 0; LOGW("i2c close ok!!"); } return 0; }
When at Open -> close -> open, it stuck at Hwi_create.
Could you help check this case? Thanks.
Best Regards,
Cherry