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.

Can't get the interrupt acticaved for the I2C when using BIOS5 and CSL together

 Hi,

I can't seem to get the interrupt acticaved for the I2C when using BIOS5 and CSL together on a C5515 usb stick. I'm trying to use the CSL_I2C_IntcExample to use setup communication with the aic3204 codec, so that I don't need to poll (I need to make beeps and change the volume on the fly in the codec, while the DMA transfer of samples is running).
 
I have removed all the IRQ related code (IRQ_plug(I2C_EVENT.. and such), and add my i2c_isr to the  (This worked fine for me in the USB case using the CSL_USB_IntcExample where I also plugged in the usb_isr function using the Configuration tool).
 

 

I kept all the I2C Callbacks and the isr dispatch since I though it couldn't hurt to let the CSL take care of that. But I never get into the interrupt anyway. I most have overlooked something regarding enabling the interrupt, or maybe I setting the I2C up wrong for the codec. I have pasted the code below.
Thanks,
Stefan Gram
 

void init_I2C_for_codec_com() {

 CSL_Status         status;
 
 /* Initialize I2C module */
 status = I2C_init(CSL_I2C0);
 if(status != CSL_SOK)
 {
  LOG_printf(&trace, "I2C Init Failed!!\n");
  return;
 }
 
 /* Set the I2C call back function address */
    i2cIsrAddr.alAddr   = CSL_i2cAlCallback;
    i2cIsrAddr.nackAddr = CSL_i2cNackCallback;
    i2cIsrAddr.ardyAddr = CSL_i2cArdyCallback;
    i2cIsrAddr.rrdyAddr = CSL_i2cRxCallback;
    i2cIsrAddr.xrdyAddr = CSL_i2cTxCallback;
    i2cIsrAddr.scdAddr  = CSL_i2cScdCallback;
    i2cIsrAddr.aasAddr  = CSL_i2cAasCallback;
 
 status = I2C_setCallback(&i2cIsrAddr);
 if(status != CSL_SOK)
 {
  LOG_printf(&trace, "I2C Set callback Failed!!\n");
  return;
 }


 /* Configure I2C module for write */
 i2cConfig.icoar  = CSL_I2C_ICOAR_DEFVAL;
 i2cConfig.icimr  = CSL_I2C_ICIMR_DEFVAL;
 i2cConfig.icclkl = CSL_I2C_ICCLK_DEFVAL; // 35; //
 i2cConfig.icclkh = CSL_I2C_ICCLK_DEFVAL; // 35; //
 i2cConfig.iccnt  = 20; //CSL_I2C_DATA_SIZE + CSL_EEPROM_ADDR_SIZE;
 i2cConfig.icsar  = CSL_I2C_CODEC_ADDR; // CSL_I2C_ICSAR_DEFVAL;
 i2cConfig.icmdr  = CSL_I2C_ICMDR_WRITE_DEFVAL;
 i2cConfig.icemdr = CSL_I2C_ICEMDR_DEFVAL;
 i2cConfig.icpsc  = CSL_I2C_ICPSC_DEFVAL; // 0x0004; //

 status = I2C_config(&i2cConfig);
 if(status != CSL_SOK)
 {
  LOG_printf(&trace, "I2C Config Failed!!\n");
  return;
 }
 
 /* Read the configured values using I2C_getConfig function */
 status = I2C_getConfig(&i2cGetConfig);
 if(status != CSL_SOK)
 {
     LOG_printf(&trace, "I2C  Get Config Failed!!\n");
  return;
 }
 
 /* Verify the read configuration values */
 if((i2cConfig.icoar  != i2cGetConfig.icoar)  ||
    (i2cConfig.icimr  != i2cGetConfig.icimr)  ||
    (i2cConfig.icclkl != i2cGetConfig.icclkl) ||
    (i2cConfig.icclkl != i2cGetConfig.icclkh) ||
    (i2cConfig.iccnt  != i2cGetConfig.iccnt)  ||
    (i2cConfig.icsar  != i2cGetConfig.icsar)  ||
    (i2cConfig.icmdr  != i2cGetConfig.icmdr)  ||
    (i2cConfig.icemdr != i2cGetConfig.icemdr) ||
    (i2cConfig.icpsc  != i2cGetConfig.icpsc))
    {
     LOG_printf(&trace, "I2C get config not matching with config values!!\n");
  return;
 }

 i2cErrInTx = FALSE;
 i2cTxCount = 0;
 dataLength = i2cConfig.iccnt;

 /* Enable I2C NACK Error Event */
 status = I2C_eventEnable(CSL_I2C_EVENT_NACK);
 if(status != CSL_SOK)
 {
  LOG_printf(&trace, "I2C Event enable Failed!!\n");
  return;
 }

 /* Enable I2C Tx Ready Event */
 status = I2C_eventEnable(CSL_I2C_EVENT_ICXRDY);
 if(status != CSL_SOK)
 {
  LOG_printf(&trace, "I2C Event enable Failed!!\n");
  return;
 }


}

void Send_codec_commands_through_I2C(Uint16 *pSendBuffer)
{
 gSendBuffer = pSendBuffer;
 i2cTxCount = 0;
 
 //CSL_I2C_0_REGS->ICDXR = gSendBuffer[i2cTxCount++];
 /* Set the start bit */
 CSL_I2C_SETSTART();

}


/**
 *  \brief  I2C Arbitration loss callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cAlCallback(void)
{
 ;
}

/**
 *  \brief  I2C No acknowledgement callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cNackCallback(void)
{
 i2cErrInTx = TRUE;
}

/**
 *  \brief  I2C Access ready callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cArdyCallback(void)
{
 ;
}

/**
 *  \brief  I2C Receive ready callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cRxCallback(void)
{
 /*
 gI2cRdBuf[i2cRxCount++] = CSL_I2C_0_REGS->ICDRR;
 dataLength--;
 */
}

/**
 *  \brief  I2C Transmit ready callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cTxCallback(void)
{
 CSL_I2C_0_REGS->ICDXR = gSendBuffer[i2cTxCount++];
 dataLength--;
}

/**
 *  \brief  I2C Stop condition detected callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cScdCallback(void)
{
 stopDetected = TRUE;
}

/**
 *  \brief  I2C Address as slave callback
 *
 *  \param  None
 *
 *  \return None
 */
void CSL_i2cAasCallback(void)
{
 ;
}

/**
 *  \brief  I2C interrupt service routine
 *
 *  \param  None
 *
 *  \return None
 */
void i2c_isr(void)
{
 Uint16    eventId;

 eventId = I2C_getEventId();
 
 if(eventId != 0)
 {
  i2cHandle->I2C_isrDispatchTable[eventId - 1]();
 }
 
}