I have one USB to Serial going to a nmea interface /dev/ttyUSB0
The hardware serial port is going to a display /dev/ttyMFD1. Display is Tx and buttons are Rx
The terminal interface goes to a computer using PuTTY
I need another serial Rx port for a GPS chip. I have considered many options and nothing is an obvious choice. Here are the issues
1) Add a USB hub and a second USB to Serial. Edison will not boot with my hub connected and multiple USB to Serial converters connected. Lots of space taken up by the hardware. Really messy cabling wise.
2) Add an i2c to uart chip. I can't find code samples on how to make this work. It would be a good solution if I didn't think it would be another PhD thesis to get it working. https://www.sparkfun.com/products/9981 SparkFun I2C/SPI-to-UART Breakout - SC16IS750 - BOB-09981 - SparkFun Electronics
3) Give up on the input from the display and use the input for the GPS. But I want to use the buttons.
4) Do a bit bang serial read on the buttons using a GPIO port. The input is 9600 Baud and the keys don't get pressed very often.
There are four possible sentences.
Any advice and specifically any code to do the bit bang read? Would it work on an Edison?
Another option might be using an analog multiplexer. With an analog multiplexer you will be able to use more than one serial port (TX - RX) through the port /dev/ttyMFD1. With additional GPIOs you can select which serial port is going to be connected to /dev/ttyMFD1. The following IC might be useful for this approach: http://www.ti.com/lit/ds/symlink/sn74lv4052a.pdf http://www.ti.com/lit/ds/symlink/sn74lv4052a.pdf
On the other hand, the I2C/SPI-to-UART breakout board you pointed seems to have a library to make it work. SparkFun mentions it in the Documents section of the breakout board page: https://www.sparkfun.com/products/9981 SparkFun I2C/SPI-to-UART Breakout - SC16IS750 - BOB-09981 - SparkFun Electronics. Have you checked it?
Anyhow, if I were you I would try using the analog multiplexer. You would only need to use the /dev/ttyMFD1 and two additional GPIOs to select the UART port that you want to use.
The analog multiplexer would work for writes but I need one more read port and the data can come at any time. The SparkFun example is SPI and really written to do a WiFi task. The part also has many registers and was a little overwhelming. If I had a simple UART i2c example I would use it. I have used i2c but not SPI so that means more pins to solder and more wires to run and another thing to learn. Each learning experience is fun but as they said in American Graffiti, "next time can we have a little less fun?"
I think the ideal thing would be code that makes a UART out of a GPIO port as I only have to make the Rx work and the baud rate is low. Or an i2c simple UART example with the SparkFun part. Has anyone either with an Edison?
I ordered the Sparkfun board. If anyone has used it I would love to see the code. The sparkfun example is 25 files in C++ for an Adruino using SPI and does a WiFi connection with flow control. I need two files in C for an Edison using i2c. "Initialize" and "read byte" with no flow control as the buffer in the chip is enough.
On the other hand, if anyone has the code for a software uart and can tell me it will work on an Edison, I am interested in that as well.
Translation, I would like something that works on an Edison, turn key.
I've checked the SparkFun library and the files you need for the SPI-UART communication are the following:
The files Spi.h and Spi.cpp are used for the SPI functions: transferring data, selecting/deselecting the SPI device, initializing the SPI interface. If you want to use I2C instead of SPI, then you should replace those files with the I2C configurations.
The files SpiUart.h and SpiUart.cpp are used for the UART part. The configuration of the UART and other functions like write() and read() are defined there. The functions you should use are only two: write() and read(). With the write() function you send a byte, and with the read() function you receive a byte. The other functions are for configuration settings and for checking status.
I recommend you to use the SPI interface since the files were written for that purpose. The only detail is that the Spi.h and Spi.cpp seem to be written for the Arduino architecture (AVR) so, you should probably have to modify them a little bit to avoid the architecture dependencies.
If you want to use I2C instead, then you have to configure the I2C part by yourself. This means that you would have to write an i2c.h file and an i2c.cpp file in order to substitute the Spi.h and the Spi.cpp files. This change also implies that you would have to update the SpiUart.h and SpiUart.cpp files because they are based on SPI communication.
These changes might take a while to be done, but if you understand those four files you should be able to make it work. The datasheet might be useful too in case you want to check the registers and the functionality of the IC: https://www.sparkfun.com/datasheets/Components/SMD/SC16IS740_750_760.pdf https://www.sparkfun.com/datasheets/Components/SMD/SC16IS740_750_760.pdf
Thanks, I will give that a try. I have an i2c device running and hope to use that code as a template. I am hoping that this will be easier than translating from Arduino and C++ to mraa and C. I have looked at the datasheet and code and THINK all I need to do is set the baud rate and maybe the buffer. The sparkfun example has hardware flow control which I don't need and can't use.