I wnat to set P0.30 and P0.31 for I2C CLK and SDA.
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
err_code = nrf_drv_gpiote_out_init(30, &out_config1);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_out_init(31, &out_config1);
APP_ERROR_CHECK(err_code);
But I can not read SDA pin data, how can I do?
unsigned char I2C_Read(void)
{
char i=9;
char value=0;
// read data
while(--i)
{
value <<= 1;
i2c_wait();
nrf_gpio_pin_set(SCL);
i2c_wait2();
value |= nrf_gpio_pin_out_read(SDA);
i2c_wait2();
nrf_gpio_pin_clear(SCL);
}
// send acknowledge
i2c_wait2();
nrf_gpio_pin_set(SDA); //ACK
i2c_wait2();
nrf_gpio_pin_set(SCL);
i2c_wait();
nrf_gpio_pin_clear(SCL);
NRF_LOG_INFO("I2C_Read: %d \n\r", value);
return value;
}