Commit e71f0ac4 authored by Christos Gentsos's avatar Christos Gentsos

Master: simple I2C sending test (works)

parent f1ef0e20
......@@ -13,6 +13,12 @@ int main(void)
uint16_t adc_val;
float adc_temp;
struct io_descriptor *I2C_0_io;
int n_written = 0;
i2c_m_sync_get_io_descriptor(&I2C_0, &I2C_0_io);
i2c_m_sync_enable(&I2C_0);
i2c_m_sync_set_slaveaddr(&I2C_0, 0x12, I2C_M_SEVEN);
/* Replace with your application code */
while (1) {
......@@ -21,7 +27,8 @@ int main(void)
if (i++ % 2) {
adc_sync_read_channel(&ADC_0, 0, (uint8_t*)&adc_val, 2);
adc_temp = ((adc_val / 4095.0) - 0.6)/0.01;
debug("iter %d, temp=%.1f", i/2, adc_temp);
n_written = io_write(I2C_0_io, (uint8_t *)"Hello World!", 12);
debug("iter %d, temp=%.1f, written=%d", i/2, adc_temp, n_written);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment