diff options
Diffstat (limited to 'firmware/i2c.c')
-rw-r--r-- | firmware/i2c.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/firmware/i2c.c b/firmware/i2c.c index 4baa7bb..fca24ac 100644 --- a/firmware/i2c.c +++ b/firmware/i2c.c @@ -36,6 +36,7 @@ #include "common.h" #include "protocol.h" #include "i2c.h" +#include "debug.h" #define I2C_WAIT_FOR_COMPLETE() while (!(TWCR & (1<<TWINT))); void i2c_parser(char *buf) @@ -103,8 +104,8 @@ void i2c_deinit_usb(void) int i2c_deinit(void) { TWCR &= ~(1<<TWEN); // deinit - octopus.ports[12]=PIN_NONE; - octopus.ports[13]=PIN_NONE; + octopus.ports[12]=PIN_NONE; // XXX correct? + octopus.ports[13]=PIN_NONE; // XXX correct? return RSP_OK; } @@ -112,7 +113,7 @@ int i2c_deinit(void) void i2c_set_bitrate_usb(char bitrate) { answer[1] = (unsigned char)i2c_set_bitrate(bitrate); - answer[2] = 0; + answer[2] = '\0'; CommandAnswer(3); } @@ -129,7 +130,7 @@ int i2c_set_bitrate(char bitrate) { void i2c_send_start_usb(void) { answer[1] = (unsigned char)i2c_send_start(); - answer[2] = 0; + answer[2] = '\0'; CommandAnswer(3); } @@ -169,7 +170,7 @@ void i2c_send_usb(int length, char *data) i2c_send(data, length); answer[1] = RSP_OK; - answer[2] = 0; + answer[2] = '\0'; CommandAnswer(3); } @@ -192,12 +193,16 @@ void i2c_recv_usb(int address, int length) answer[0]=CMD_I2C_RECV; answer[1]=RSP_OK; - for(i = 0; i < length; i++) + debug_init(); + for(i = 0; i < length; i++) { + debug_write("recv\r\n\0"); answer[2+i] = i2c_recv_byte(); + debug_write("recved\r\n\0"); + } answer[length+2] = 0; - CommandAnswer(3+length); + CommandAnswer(length+2); } |