Hi,
I'm trying to use the libmaple i2c implementation (hardware). The I2C device is currently disconnected, but the SDA and SCL pins are monitored on a logic analyzer.
I got the same results when the peripheral is connected, although I am not sure it received enough voltage to power up earlier (which is why I disconnected it in the first place).
What happens is, the first i2c header is sent out correctly followed, of course, by a NAK (as posted on the first image upload service i found, http://tinypic.com/view.php?pic=2m3jss9&s=6). After the initial header of the message is sent, the maple mini enters some state where the LED is glowing with a steady pulse ~ 1-2 Hz.
One of my thoughts is that I handle bus errors wrongly. I've tried i2c_bus_reset and i2c_master_enable inside the loop to re-enable the bus, but I obviously havn't gotten anything working yet.
This is a minimal example i've extracted from libmaple/examples/i2c-mcp4725-dac.cpp (is that the only source for API usage doc on i2c?)
#include <stdint.h>
#include <wirish/wirish.h>
#include <libmaple/i2c.h>
__attribute__((constructor)) void premain() {
init();
}
i2c_msg write_msg;
static uint8 write_msg_data[3];
void setup() {
pinMode(BOARD_LED_PIN, OUTPUT);
write_msg.addr = 0x16;
write_msg.flags = 0; // write, 7 bit address
write_msg.length = sizeof(write_msg_data);
write_msg.xferred = 0;
write_msg.data = write_msg_data;
i2c_master_enable(I2C1, I2C_FAST_MODE | I2C_BUS_RESET);
}
void loop() {
i2c_master_xfer(I2C1, &write_msg, 1, 100);
delay(2000);
//~ toggleLED();
}
int main(void) {
setup();
while (true) {
loop();
}
return 0;
}
Best regards,
Jonatan