Serial port


bool miosix::IRQis_serial_enabled ()
bool miosix::serial_rx_check ()
bool miosix::serial_rx_lost ()
void miosix::serial_rx_flush ()

Detailed Description

Miosix serial port API

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

Function Documentation

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.

true if serial port is enabled.

bool miosix::serial_rx_check (  ) 

true if the read buffer is not empty
Can be used to read from the serial port in a nonblocking way. If returns true than there is at least one character in the buffer that can be read with getchar()
Cannot be used if the kernel is not started, paused, or inside an IRQ.

void miosix::serial_rx_flush (  ) 

Reset rx buffer.

bool miosix::serial_rx_lost (  ) 

true if some character in the rx queue has been lost and clears the lost flag. Cannot be used if the kernel is not started, paused, or inside an IRQ.

Generated on Fri Jun 19 15:19:04 2009 for Miosix by  doxygen 1.5.6