Adding a serial port using the SC16IS740


#1

I added a library, SC16IS740RK, that makes it possible to use up to 4 SC16IS740 I2C UARTs off the I2C bus (D0 and D1). The chips support from 50 to 115200 baud and can go higher with different oscillators.

Basically, just create the object and call begin() and it works like a regular UART like Serial1:

#include "SC16IS740RK.h"

// Pick a debug level from one of these two:
SerialLogHandler logHandler;
// SerialLogHandler logHandler(LOG_LEVEL_TRACE);

SC16IS740 extSerial(Wire, 0);

char out = ' ';

void setup() {
	Serial.begin(9600);

	delay(5000);

	extSerial.begin(9600);
}

void loop() {
	while(extSerial.available()) {
		int c = extSerial.read();
		Log.info("received %d", c);
	}

	extSerial.print(out);
	if (++out >= 127) {
		out = ' ';
	}
	delay(100);
}

Tested with both the Photon and Electron and 0.7.0:

On the Github there’s also the Eagle CAD files for making the handy breakout board in the picture and the BOM.

This is just the first version and I’ll eventually add interrupt support, flow control, and possibly SPI interface support.


#2

@rickkas7, nice job on the library! Having interrupts and SPI would make those things fly!


#4

OK, I just designed a SPI with hardware flow control board and sent it off to fab, so I’ll write the software for those features when I get the boards back.