Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of minimal_i2c_mother by
master.cpp@2:4709985cf716, 2014-12-02 (annotated)
- Committer:
- rrbeauch
- Date:
- Tue Dec 02 20:24:18 2014 +0000
- Revision:
- 2:4709985cf716
- Parent:
- 1:92677fbab5f1
serial and outputting
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nghansen | 0:d3bdf717512e | 1 | #include "mbed.h" |
| rrbeauch | 1:92677fbab5f1 | 2 | #define ROWSIZE (3) |
| rrbeauch | 1:92677fbab5f1 | 3 | #define SELECTSIZE (0x04) |
| nghansen | 0:d3bdf717512e | 4 | |
| rrbeauch | 1:92677fbab5f1 | 5 | //BusOut toCells(p5,p6,p7,p8,p9,p10,p11,p12); |
| rrbeauch | 1:92677fbab5f1 | 6 | //BusOut select(p13,p14,p15); |
| rrbeauch | 1:92677fbab5f1 | 7 | |
| nghansen | 0:d3bdf717512e | 8 | I2C Bus(p28, p27); |
| rrbeauch | 1:92677fbab5f1 | 9 | //I2CSlave Self(p9, p10); |
| rrbeauch | 1:92677fbab5f1 | 10 | |
| rrbeauch | 1:92677fbab5f1 | 11 | int slaveAddressRow1; |
| rrbeauch | 1:92677fbab5f1 | 12 | int slaveAddressRow2; |
| nghansen | 0:d3bdf717512e | 13 | |
| nghansen | 0:d3bdf717512e | 14 | Serial Usb(USBTX, USBRX); |
| rrbeauch | 2:4709985cf716 | 15 | //char buffer[16] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x00}; |
| rrbeauch | 2:4709985cf716 | 16 | //char buffer[16] = {'$', 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF}; |
| rrbeauch | 2:4709985cf716 | 17 | char buffer[16]; |
| nghansen | 0:d3bdf717512e | 18 | int ack; |
| nghansen | 0:d3bdf717512e | 19 | |
| rrbeauch | 1:92677fbab5f1 | 20 | char slaveBuffer[16]; |
| nghansen | 0:d3bdf717512e | 21 | DigitalOut sent(LED1); |
| nghansen | 0:d3bdf717512e | 22 | DigitalOut received(LED2); |
| nghansen | 0:d3bdf717512e | 23 | |
| nghansen | 0:d3bdf717512e | 24 | void resetBus() |
| nghansen | 0:d3bdf717512e | 25 | { |
| nghansen | 0:d3bdf717512e | 26 | Bus.stop(); |
| nghansen | 0:d3bdf717512e | 27 | Bus.start(); |
| nghansen | 0:d3bdf717512e | 28 | return; |
| nghansen | 0:d3bdf717512e | 29 | } |
| nghansen | 0:d3bdf717512e | 30 | |
| nghansen | 0:d3bdf717512e | 31 | int main() |
| nghansen | 0:d3bdf717512e | 32 | { |
| rrbeauch | 1:92677fbab5f1 | 33 | slaveAddressRow1 = 0x02; |
| rrbeauch | 2:4709985cf716 | 34 | |
| nghansen | 0:d3bdf717512e | 35 | resetBus(); |
| nghansen | 0:d3bdf717512e | 36 | |
| nghansen | 0:d3bdf717512e | 37 | while (1) |
| nghansen | 0:d3bdf717512e | 38 | { |
| rrbeauch | 2:4709985cf716 | 39 | for(int i = 0; i < sizeof buffer; buffer[i++]=0x00); |
| nghansen | 0:d3bdf717512e | 40 | |
| rrbeauch | 2:4709985cf716 | 41 | Usb.scanf("%16s", buffer); |
| rrbeauch | 2:4709985cf716 | 42 | Usb.printf("%s \n\r", buffer); |
| rrbeauch | 2:4709985cf716 | 43 | while( Bus.write(slaveAddressRow1 & 0xFE, buffer, 16) != 0); |
| rrbeauch | 2:4709985cf716 | 44 | //if(ack1 == 0) |
| rrbeauch | 2:4709985cf716 | 45 | Usb.printf("Row one sent\n\r"); |
| nghansen | 0:d3bdf717512e | 46 | } |
| nghansen | 0:d3bdf717512e | 47 | } |
