FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.
Dependencies: mbed FXOS8700CQ MODSERIAL
Revision 56:cb42ff383dab, committed 2016-07-28
- Comitter:
- stefanrousseau
- Date:
- Thu Jul 28 17:21:31 2016 +0000
- Parent:
- 55:3abf9e3f42e6
- Child:
- 57:d184175b6b03
- Commit message:
- Changes USB UART to use MODSERIAL library
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MODSERIAL.lib Thu Jul 28 17:21:31 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/MODSERIAL/#d8422efe4761
--- a/hardware.h Thu Jul 28 15:52:37 2016 +0000 +++ b/hardware.h Thu Jul 28 17:21:31 2016 +0000 @@ -1,7 +1,8 @@ #ifndef Hardware_H_ #define Hardware_H_ +#include "MODSERIAL.h" extern I2C i2c; //SDA, SCL -- define the I2C pins being used -extern Serial pc; //UART to USB host +extern MODSERIAL pc; //UART to USB host //Un-comment the definition below if you want to use the USB rx for another purpose. //otherwise the USB rx will be used to receive virtual sensor data from Avnet's
--- a/main.cpp Thu Jul 28 15:52:37 2016 +0000 +++ b/main.cpp Thu Jul 28 17:21:31 2016 +0000 @@ -40,7 +40,9 @@ #define WNC_WAIT_FOR_AT_CMD_MS 40 -Serial pc(USBTX, USBRX); +//Serial pc(USBTX, USBRX); +MODSERIAL pc(USBTX, USBRX, 256, 256); // tx, rx with default tx, rx buffer sizes + SerialBuffered mdm(PTD3, PTD2, 4096); DigitalOut led_green(LED_GREEN); DigitalOut led_red(LED_RED);
--- a/sensors.cpp Thu Jul 28 15:52:37 2016 +0000 +++ b/sensors.cpp Thu Jul 28 17:21:31 2016 +0000 @@ -471,17 +471,22 @@ //} } //ProcessUsbInterface() -void pcrx_callback() //Rx interrupt for USB serial port +// This function is called when a character goes into the RX buffer. +void UsbUartRxCallback(MODSERIAL_IRQ_INFO *info) { - // Note: you need to actually read from the serial to clear the RX interrupt - usb_uart_rx_buff[usb_uart_rx_buff_putptr++] = pc.getc(); + // Get the pointer to our MODSERIAL object that invoked this callback. + MODSERIAL *pc = info->serial; + while (pc->readable()) + { + usb_uart_rx_buff[usb_uart_rx_buff_putptr++] = pc->getcNb(); + } } #endif void sensors_init(void) { #ifdef USE_VIRTUAL_SENSORS - pc.attach(&pcrx_callback); + pc.attach(&UsbUartRxCallback, MODSERIAL::RxIrq); #endif Init_Si7020(); Init_Si1145();