program for conv1
Revision 4:9e2adff677ac, committed 2015-12-16
- Comitter:
- marcus255
- Date:
- Wed Dec 16 19:42:44 2015 +0000
- Parent:
- 3:45f63cbde7b3
- Commit message:
- Reading/Writting EEPROM works fine, Reading/Writting works fine when temperature sensor connected to the i2c bus. Device addresses must be hardcoded for now.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Dec 15 22:44:11 2015 +0000 +++ b/main.cpp Wed Dec 16 19:42:44 2015 +0000 @@ -9,12 +9,12 @@ void i2cStart(void){ SDA_interrupt.disable_irq(); char addr = (char)slave.read(); - if (addr == SLAVE_ADDR) { + if (addr == RTC_ADDR) { count = 0; char uart_rec; device.putc(DATA_TO_WRITE_CHAR); device.putc(addr); - while(!SDA_state) { + while(!SDA_state) { //writting to slave buffer = (char)slave.read(); for(int y = 0; y < 1024; y++){} //some delay required for signal establishment if(SDA_state) break; @@ -34,7 +34,7 @@ //slave.stop(); device.putc(END_OF_TRANSMISSION); } - else if (addr & 0x01 == 0x01){ + else if (addr & 0x01 == 0x01){ //reading from slave char uart_rec2; device.putc(DATA_TO_WRITE_CHAR); device.putc(addr); @@ -66,5 +66,5 @@ SDA_interrupt.fall(&i2cStart); slave.frequency(100000); device.baud(921600); - slave.address(SLAVE_ADDR); + slave.address(RTC_ADDR); } \ No newline at end of file
--- a/main.h Tue Dec 15 22:44:11 2015 +0000 +++ b/main.h Wed Dec 16 19:42:44 2015 +0000 @@ -3,6 +3,7 @@ #include <mbed.h> #define SLAVE_ADDR 0xA0 +#define RTC_ADDR 0xD0 #define RECBUFSIZE 64 #define UART_CONFIRMATION_CHAR 0x33 #define DATA_TO_WRITE_CHAR 0xCC