Quantcast
Channel: Renesas Synergy Platform
Viewing all articles
Browse latest Browse all 23645

Forum Post: need help on I2C callback

$
0
0
Hi, Please help to point out what wrong with my callback. I create an I2c driver as below My callback function UINT adc_event = 100; void g_adc128_callback (i2c_callback_args_t *p_args) { adc_event = p_args->event; GX_EVENT gxe = { .gx_event_type = GX_NULL, .gx_event_sender = GX_ID_NONE, .gx_event_target = GX_ID_NONE, .gx_event_display_handle = GX_ID_NONE }; if (p_args->event == I2C_EVENT_RX_COMPLETE) { gxe.gx_event_type = APP_EVENT_ADC_CHANGED; gx_system_event_send(&gxe); } } while (1) { // Loop through all 8 analog input channel for (read_reg = ADC128_CH0; read_reg write(g_adc_chip_i2c.p_ctrl, &read_reg, 1, false, TX_WAIT_FOREVER); if (SSP_SUCCESS != status) { g_adc_chip_i2c.p_api->reset(g_adc_chip_i2c.p_ctrl, TX_WAIT_FOREVER); } // Reading 2 bytes from ADC128 status = g_adc_chip_i2c.p_api->read(g_adc_chip_i2c.p_ctrl, (uint8_t*)&data_buf[0], sizeof(data_buf), false, TX_WAIT_FOREVER ); if (SSP_SUCCESS != status) { g_adc_chip_i2c.p_api->reset(g_adc_chip_i2c.p_ctrl, TX_WAIT_FOREVER); } analog_input[read_reg-ADC128_CH0] = adc_value(data_buf[0]); } } I monitor the variable adc_event and it always = 100, which means the callback function never been called. All the ADC counts are monitored in the expressions table. Those values are updated accordingly to the voltage input. This means the i2c works correctly. Please share your advice. Thanks.

Viewing all articles
Browse latest Browse all 23645

Trending Articles