api / mbed / trunk / SerialHalfDuplex
SerialHalfDuplex
class SerialHalfDuplex : public Serial
A serial port (UART) for communication with other devices, with a single shared transmit and receive line.
If the device both transmits and receives, then both (separate) pins need to be defined, and tied together externally.
Example
// Send a byte as a master, and receive a byte as a slave
#include "mbed.h"
SerialHalfDuplex master(p9, p10);
int main() {
int outbyte = master.putc(0x55);
int retbyte = master.getc();
printf("Wrote: %02X Read: %02X\n", outbyte, retbyte);
}| SerialHalfDuplex | A serial port (UART) for communication with other devices, with a single shared transmit and receive line. |
| Functions | |
| SerialHalfDuplex | Create a half-duplex serial port, connected to the specified transmit and receive pins. |
| baud | Set the baud rate of the serial port |
| format | |
| putc | Write a character |
| getc | Read a character |
| printf | Write a formated string |
| scanf | Read a formated string |
| readable | Determine if there is a character available to read |
| writeable | Determine if there is space available to write a character |
| attach | Attach a function to call whenever a serial interrupt is generated |
| attach | Attach a member function to call whenever a serial interrupt is generated |
format
void format( int bits = 8, Parity parity = Serial::None, int stop_bits = 1 )
- Set the transmission format used by the Serial port *
- Variables:
- bits - The number of bits in a word (5-8; default = 8)
- parity - The parity used (Serial::None, Serial::Odd, Serial::Even, Serial::Forced1, Serial::Forced0; default = Serial::None)
- stop - The number of stop bits (1 or 2; default = 1)
A serial port (UART) for communication with other devices, with a single shared transmit and receive line.
class SerialHalfDuplex : public Serial
Create a half-duplex serial port, connected to the specified transmit and receive pins.
SerialHalfDuplex( PinName tx, PinName rx, const char * name = NULL )
Set the baud rate of the serial port
void baud( int baudrate )
void format( int bits = 8, Parity parity = Serial::None, int stop_bits = 1 )
Write a character
int putc( int c )
Read a character
int getc()
Write a formated string
int printf( const char * format, ... )
Read a formated string
int scanf( const char * format, ... )
Determine if there is a character available to read
int readable()
Determine if there is space available to write a character
int writeable()
Attach a function to call whenever a serial interrupt is generated
void attach( void (*fptr)(void) )
