Functions | |
bool | miosix::IRQis_serial_enabled () |
bool | miosix::serial_rx_check () |
bool | miosix::serial_rx_lost () |
void | miosix::serial_rx_flush () |
These function allow to control the serial port on the LPC2138 mcrocontroller that is converted to USB and is used to transfer data to/from the PC.
The preferred way of reading/writing to the serial port is to use the C or C++ standard library function (printf(), cout... to print to the serial port; fgets(), getchar(), scanf(), cin, getline... to read from the serial port).
In addition, the serial port is automatically initialized by the kernel when the USB port is connected, and turned off when the USB port is dsconnected. If writing to the serial port when the USB port is disconnected, written data will be lost. If reading from the serial port when USB port is disconnected, the Thread that is reading will be blocked until the USB port is connected, an some data is received.
Data to be sent/received through serial port must be ASCII data; binary data transfer is not supported since the \n character will be converted in \r\n.
Serial port speed can be changed by changing the constant SERIAL_PORT_SPEED in file miosix_settings.h. Deafault value is 115200bit/s
bool miosix::IRQis_serial_enabled | ( | ) |
Can only be called when interrupts are disabled, inside an IRQ or before the kernel is started. If you need to query serial port status from normal code, disable interrupts before callng this function, and re-enable them after.
bool miosix::serial_rx_check | ( | ) |
void miosix::serial_rx_flush | ( | ) |
Reset rx buffer.
bool miosix::serial_rx_lost | ( | ) |