UART to I2C master(s) converter, targetting to emulate SC18IM700(NXP) chip
UART to I2C master(s) converter, targetting to emulate SC18IM700(NXP) chip
Features
up to 4x I2C master
- for LPC824 implement, we can use up to 4 channels of I2C masters
- 1x Fm+ and 3x Fm I2C channels
- for LPC1768 implement, we can use up to 2 channels of I2C masters
- 2x Fm I2C channels
- for LPC11U35 implement, only one channel for I2C master,
but program uses USB CDC class for UART communication (means no external USB-Serial converter chip)
- 1x Fm+ I2C channels
1x SPI master
up to 2x 8bit GPIO
Tested Platforms
LPC824
- https://developer.mbed.org/platforms/Switch-Science-mbed-LPC824/
- https://developer.mbed.org/platforms/LPCXpresso824-MAX/
LPC1768
LPC11U35
Quote:
LPC11U35 implement requires importing USBDevice library to use USBSerial class
visit https://github.com/K4zuki/tinyI2C for more information
Revision 85:4b1489cd5623, committed 2016-09-19
- Comitter:
- K4zuki
- Date:
- Mon Sep 19 17:56:32 2016 +0900
- Parent:
- 84:394b8cc7bef2
- Commit message:
- fix indents
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 14 22:52:24 2016 +0900
+++ b/main.cpp Mon Sep 19 17:56:32 2016 +0900
@@ -597,12 +597,12 @@
for(int j = 0; j < length; j += 2){
_data = 0xff & ((recieve[i+5+j+0]<<4) | (recieve[i+5+j+1]&0x0F));
ack = _spi.write(_data);
- // pc.printf("s%02X,",_data);
+ // pc.printf("s%02X,",_data);
send[j/2] = ack;
}
for(int j = length; j < (length+2*read); j+=2){
ack = _spi.write(0xAA); //dummy data to write
- // pc.printf("a%02X,",ack);
+ // pc.printf("a%02X,",ack);
send[j/2] = ack;
}
_cs.write(disabled);
@@ -617,15 +617,15 @@
}else{
_cs.write(enabled);
for(int j = 0; j < length; j += 4){
- _data = 0xffff & (((recieve[i+5+j+0] & 0x0F)<<12)|
- ((recieve[i+5+j+1] & 0x0F)<<8 )|
- ((recieve[i+5+j+2] & 0x0F)<<4 )|
- ((recieve[i+5+j+3] & 0x0F)<<0 )
- );
- ack = _spi.write(_data);
- // pc.printf("s%04X,",_data);
- send[(j/2)+0] = 0xFF & (ack>>8);
- send[(j/2)+1] = 0xFF & (ack>>0);
+ _data = 0xffff & (((recieve[i+5+j+0] & 0x0F)<<12)|
+ ((recieve[i+5+j+1] & 0x0F)<<8 )|
+ ((recieve[i+5+j+2] & 0x0F)<<4 )|
+ ((recieve[i+5+j+3] & 0x0F)<<0 )
+ );
+ ack = _spi.write(_data);
+ // pc.printf("s%04X,",_data);
+ send[(j/2)+0] = 0xFF & (ack>>8);
+ send[(j/2)+1] = 0xFF & (ack>>0);
}
for(int j = length; j < (length+2*read); j += 4){
ack = _spi.write(0xAAAA); //dummy data to write