diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2011-10-13 20:33:30 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2011-10-13 20:33:30 +0200 |
commit | 5d9d373a959271b498710817d08c2ea8e153aa6e (patch) | |
tree | 6867e887454a850b4e15616000ef342a1c661c7e /firmware/i2c.c | |
parent | 35a36b0a6c69ce136fd6ea2a203d34e48e1291e8 (diff) | |
download | mini-octopus-5d9d373a959271b498710817d08c2ea8e153aa6e.tar.gz mini-octopus-5d9d373a959271b498710817d08c2ea8e153aa6e.zip |
correct firmware??
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); } |