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.
Fork of SC16IS752 by
Diff: SC16IS752.cpp
- Revision:
- 1:85070c9144a6
- Parent:
- 0:ad254d5f94b1
--- a/SC16IS752.cpp Wed Aug 10 03:40:03 2016 +0000 +++ b/SC16IS752.cpp Fri Aug 12 04:36:48 2016 +0000 @@ -16,11 +16,11 @@ if (_i2c.read(deviceAddress, &data[0], 1) != 0) { - dbg.printf(RED "I2C device is not detected\r\n" DEF); + dbg.printf("I2C device is not detected\r\n"); } else { - dbg.printf(GRE "I2C device is detected\r\n" DEF); + dbg.printf("I2C device is detected\r\n"); } data[0]=0; @@ -55,7 +55,24 @@ void SC16IS752::wrblock(const char *data, int len ) { int i; - + + _i2c.start(); + _i2c.write(_slaveAddress); + _i2c.write(THR | _channel); + + for (i=0; i<len; i++) + { + _i2c.write(data[i]); + wait_ms(1); + } + + _i2c.stop(); +} + +void SC16IS752::wrblock (const uint8_t *data, int len ) +{ + int i; + _i2c.start(); _i2c.write(_slaveAddress); _i2c.write(THR | _channel); @@ -72,8 +89,8 @@ char SC16IS752::rd(char adr) { char start = adr | _channel;; - if (_i2c.write(_slaveAddress, &start, 1, true) != 0) dbg.printf(RED "SPR No Ack!\r\n" DEF); - if (_i2c.read(_slaveAddress, r, 1) != 0) dbg.printf(RED "SPR No Ack!\r\n" DEF); + if (_i2c.write(_slaveAddress, &start, 1, true) != 0) dbg.printf("SPR No Ack!\r\n"); + if (_i2c.read(_slaveAddress, r, 1) != 0) dbg.printf("SPR No Ack!\r\n"); return r[0]; } @@ -253,12 +270,12 @@ { if (rd(LSR) & LSR_DR) // Data in Receiver Bit, at least one character waiting { - dbg.printf(GRE "Serial is readable\r\n" DEF); + dbg.printf("Serial is readable\r\n"); return true; } else { - dbg.printf(RED "Serial is not readable\r\n" DEF); + dbg.printf("Serial is not readable\r\n"); return false; } } @@ -274,12 +291,12 @@ { if (rd(LSR) & LSR_THRE) // THR Empty, space for at least one character { - dbg.printf(GRE "Serial is writeable\r\n" DEF); + dbg.printf("Serial is writeable\r\n"); return true; } else { - dbg.printf(RED "Serial is writeable\r\n" DEF); + dbg.printf("Serial is writeable\r\n"); return false; } }