embedded/projects/osp-steval-mki109v2/sources/app/i2c_slavecomm_t.c
static void I2C_Slave_init( void )
{
    GPIO_InitTypeDef  GPIO_InitStructure;
    NVIC_InitTypeDef  NVIC_InitStructure;

    /* Reset the peripheral (this allows soft restarts to recover the bus in case of hangups) */
    I2C_DeInit(I2C_SLAVE_BUS);

    /* Enable Clocks to the peripheral and GPIOs used */
    RCC_APB1PeriphClockCmd(RCC_Periph_I2C_SLAVE_BUS, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_Periph_I2C_SLAVE_BUS_GPIO, ENABLE ); //for I2C port GPIO

    /* NVIC/Interrupt config */
    /* Configure and enable I2C event interrupt -------------------------------*/
    NVIC_InitStructure.NVIC_IRQChannel = I2C_SLAVE_BUS_EVENT_IRQ_CH;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = I2C_SLAVE_BUS_INT_PREEMPT_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = I2C_SLAVE_BUS_EVENT_INT_SUB_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    /* Configure and enable I2C error interrupt -------------------------------*/  
    NVIC_InitStructure.NVIC_IRQChannel = I2C_SLAVE_BUS_ERROR_IRQ_CH;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = I2C_SLAVE_BUS_ERROR_INT_SUB_PRIORITY;
    NVIC_Init(&NVIC_InitStructure);

    /* GPIO Configuration for CLK and SDA signals */
    GPIO_InitStructure.GPIO_Pin = I2C_SLAVE_BUS_CLK_PIN  | I2C_SLAVE_BUS_SDA_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init( I2C_SLAVE_BUS_GPIO_GRP, &GPIO_InitStructure );

    /* Sensor Hub Host interrupt pin */
    RCC_APB2PeriphClockCmd(SH_INT_RCC, ENABLE );
    SensorHubIntLow(); //ensure output is deasserted when initialized.
    GPIO_InitStructure.GPIO_Pin = SH_INT_GPIO_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; //Because we are interfacing 3.3V to 1.8V
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init( SH_INT_GPIO_GRP, &GPIO_InitStructure );

    /* Initialize the I2C slave interface */
    I2C_Slave_Initialise();
}
/****************************************************************************************************
 * @fn      I2C_Slave_init
 *          Initialize the Sensor Hub I2C Slave hardware
 *
 ***************************************************************************************************/
@fn      I2C_Slave_init
Initialize the Sensor Hub I2C Slave hardware
@fn I2C_Slave_init Initialize the Sensor Hub I2C Slave hardware
static void I2C_Slave_init( void )
{
    GPIO_InitTypeDef  GPIO_InitStructure;
    NVIC_InitTypeDef  NVIC_InitStructure;
    I2C_DeInit(I2C_SLAVE_BUS);
    RCC_APB1PeriphClockCmd(RCC_Periph_I2C_SLAVE_BUS, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_Periph_I2C_SLAVE_BUS_GPIO, ENABLE ); 
    NVIC_InitStructure.NVIC_IRQChannel = I2C_SLAVE_BUS_EVENT_IRQ_CH;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = I2C_SLAVE_BUS_INT_PREEMPT_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = I2C_SLAVE_BUS_EVENT_INT_SUB_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    NVIC_InitStructure.NVIC_IRQChannel = I2C_SLAVE_BUS_ERROR_IRQ_CH;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = I2C_SLAVE_BUS_ERROR_INT_SUB_PRIORITY;
    NVIC_Init(&NVIC_InitStructure);
    GPIO_InitStructure.GPIO_Pin = I2C_SLAVE_BUS_CLK_PIN  | I2C_SLAVE_BUS_SDA_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init( I2C_SLAVE_BUS_GPIO_GRP, &GPIO_InitStructure );
    RCC_APB2PeriphClockCmd(SH_INT_RCC, ENABLE );
    SensorHubIntLow(); 
    GPIO_InitStructure.GPIO_Pin = SH_INT_GPIO_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; 
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init( SH_INT_GPIO_GRP, &GPIO_InitStructure );
    I2C_Slave_Initialise();
}
static void I2C_Slave_init ( void ) { GPIO_InitTypeDef GPIO_InitStructure ; NVIC_InitTypeDef NVIC_InitStructure ; I2C_DeInit ( I2C_SLAVE_BUS ) ; RCC_APB1PeriphClockCmd ( RCC_Periph_I2C_SLAVE_BUS , ENABLE ) ; RCC_APB2PeriphClockCmd ( RCC_Periph_I2C_SLAVE_BUS_GPIO , ENABLE ) ; NVIC_InitStructure . NVIC_IRQChannel = I2C_SLAVE_BUS_EVENT_IRQ_CH ; NVIC_InitStructure . NVIC_IRQChannelPreemptionPriority = I2C_SLAVE_BUS_INT_PREEMPT_PRIORITY ; NVIC_InitStructure . NVIC_IRQChannelSubPriority = I2C_SLAVE_BUS_EVENT_INT_SUB_PRIORITY ; NVIC_InitStructure . NVIC_IRQChannelCmd = ENABLE ; NVIC_Init ( & NVIC_InitStructure ) ; NVIC_InitStructure . NVIC_IRQChannel = I2C_SLAVE_BUS_ERROR_IRQ_CH ; NVIC_InitStructure . NVIC_IRQChannelSubPriority = I2C_SLAVE_BUS_ERROR_INT_SUB_PRIORITY ; NVIC_Init ( & NVIC_InitStructure ) ; GPIO_InitStructure . GPIO_Pin = I2C_SLAVE_BUS_CLK_PIN | I2C_SLAVE_BUS_SDA_PIN ; GPIO_InitStructure . GPIO_Mode = GPIO_Mode_AF_OD ; GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ; GPIO_Init ( I2C_SLAVE_BUS_GPIO_GRP , & GPIO_InitStructure ) ; RCC_APB2PeriphClockCmd ( SH_INT_RCC , ENABLE ) ; SensorHubIntLow ( ) ; GPIO_InitStructure . GPIO_Pin = SH_INT_GPIO_PIN ; GPIO_InitStructure . GPIO_Mode = GPIO_Mode_Out_OD ; GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ; GPIO_Init ( SH_INT_GPIO_GRP , & GPIO_InitStructure ) ; I2C_Slave_Initialise ( ) ; }
@fn      I2C_Slave_init
          Initialize the Sensor Hub I2C Slave hardware
@fn I2C_Slave_init Initialize the Sensor Hub I2C Slave hardware
/* Reset the peripheral (this allows soft restarts to recover the bus in case of hangups) */ /* Enable Clocks to the peripheral and GPIOs used */ //for I2C port GPIO /* NVIC/Interrupt config */ /* Configure and enable I2C event interrupt -------------------------------*/ /* Configure and enable I2C error interrupt -------------------------------*/ /* GPIO Configuration for CLK and SDA signals */ /* Sensor Hub Host interrupt pin */ //ensure output is deasserted when initialized. //Because we are interfacing 3.3V to 1.8V /* Initialize the I2C slave interface */