module/cdns_i2c/src/mod_cdns_i2c.c
static int i2c_slave_write_irq(
    fwk_id_t device_id,
    uint8_t *data,
    uint8_t length)
{
    struct cdns_i2c_dev_ctx *device_ctx;

    device_ctx = &i2c_ctx.device_ctx_table[fwk_id_get_element_idx(device_id)];

    fwk_assert((length != 0) && (data != NULL));

    if (device_ctx->irq_data_ctx.busy) {
        return FWK_E_BUSY;
    }

    device_ctx->irq_data_ctx.state = MOD_CDNS_I2C_STATE_TX;
    device_ctx->irq_data_ctx.data = data;
    device_ctx->irq_data_ctx.size = length;
    device_ctx->irq_data_ctx.index = 0;
    device_ctx->irq_data_ctx.busy = true;

    /* Clear FIFO */
    I2C_REG_RMW(
        device_ctx->reg->CR,
        I2C_CR_CLRFIFO_MASK,
        I2C_CR_CLRFIFO_SHIFT,
        I2C_CLRFIFO_ON);

    /* Set address in AR register */
    I2C_REG_W(
        device_ctx->reg->AR,
        I2C_AR_ADD7_MASK,
        I2C_AR_ADD7_SHIFT,
        device_ctx->config->slave_addr);

    /* Clear any pending IRQs and re-enable interrupts */
    device_ctx->reg->ISR = I2C_ISR_MASK;
    device_ctx->reg->IER =
        (I2C_IER_COMP_MASK | I2C_IER_DATA_MASK | I2C_IER_NACK_MASK |
         I2C_IER_RXOVF_MASK | I2C_IER_TXOVF_MASK | I2C_IER_RXUNF_MASK);

    /* ISR will take over from here */
    return FWK_SUCCESS;
}
/*
 * I2C slave interrupt mode driver API
 */
I2C slave interrupt mode driver API
I2C slave interrupt mode driver API
static int i2c_slave_write_irq(
    fwk_id_t device_id,
    uint8_t *data,
    uint8_t length)
{
    struct cdns_i2c_dev_ctx *device_ctx;
    device_ctx = &i2c_ctx.device_ctx_table[fwk_id_get_element_idx(device_id)];
    fwk_assert((length != 0) && (data != NULL));
    if (device_ctx->irq_data_ctx.busy) {
        return FWK_E_BUSY;
    }
    device_ctx->irq_data_ctx.state = MOD_CDNS_I2C_STATE_TX;
    device_ctx->irq_data_ctx.data = data;
    device_ctx->irq_data_ctx.size = length;
    device_ctx->irq_data_ctx.index = 0;
    device_ctx->irq_data_ctx.busy = true;
    I2C_REG_RMW(
        device_ctx->reg->CR,
        I2C_CR_CLRFIFO_MASK,
        I2C_CR_CLRFIFO_SHIFT,
        I2C_CLRFIFO_ON);
    I2C_REG_W(
        device_ctx->reg->AR,
        I2C_AR_ADD7_MASK,
        I2C_AR_ADD7_SHIFT,
        device_ctx->config->slave_addr);
    device_ctx->reg->ISR = I2C_ISR_MASK;
    device_ctx->reg->IER =
        (I2C_IER_COMP_MASK | I2C_IER_DATA_MASK | I2C_IER_NACK_MASK |
         I2C_IER_RXOVF_MASK | I2C_IER_TXOVF_MASK | I2C_IER_RXUNF_MASK);
    return FWK_SUCCESS;
}
static int i2c_slave_write_irq ( fwk_id_t device_id , uint8_t * data , uint8_t length ) { struct cdns_i2c_dev_ctx * device_ctx ; device_ctx = & i2c_ctx . device_ctx_table [ fwk_id_get_element_idx ( device_id ) ] ; fwk_assert ( ( length != 0 ) && ( data != NULL ) ) ; if ( device_ctx -> irq_data_ctx . busy ) { return FWK_E_BUSY ; } device_ctx -> irq_data_ctx . state = MOD_CDNS_I2C_STATE_TX ; device_ctx -> irq_data_ctx . data = data ; device_ctx -> irq_data_ctx . size = length ; device_ctx -> irq_data_ctx . index = 0 ; device_ctx -> irq_data_ctx . busy = true ; I2C_REG_RMW ( device_ctx -> reg -> CR , I2C_CR_CLRFIFO_MASK , I2C_CR_CLRFIFO_SHIFT , I2C_CLRFIFO_ON ) ; I2C_REG_W ( device_ctx -> reg -> AR , I2C_AR_ADD7_MASK , I2C_AR_ADD7_SHIFT , device_ctx -> config -> slave_addr ) ; device_ctx -> reg -> ISR = I2C_ISR_MASK ; device_ctx -> reg -> IER = ( I2C_IER_COMP_MASK | I2C_IER_DATA_MASK | I2C_IER_NACK_MASK | I2C_IER_RXOVF_MASK | I2C_IER_TXOVF_MASK | I2C_IER_RXUNF_MASK ) ; return FWK_SUCCESS ; }
I2C slave interrupt mode driver API
I2C slave interrupt mode driver API
/* Clear FIFO */ /* Set address in AR register */ /* Clear any pending IRQs and re-enable interrupts */ /* ISR will take over from here */