mbed-drivers
Public Member Functions | List of all members
mbed::RawSerial Class Reference

#include <RawSerial.h>

Inheritance diagram for mbed::RawSerial:
mbed::SerialBase

Public Member Functions

 RawSerial (PinName tx, PinName rx)
 
int putc (int c)
 
int getc ()
 
int puts (const char *str)
 
int printf (const char *format,...)
 
- Public Member Functions inherited from mbed::SerialBase
void baud (int baudrate)
 
void format (int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
 
int readable ()
 
int writeable ()
 
void attach (void(*fptr)(void), IrqType type=RxIrq)
 
template<typename T >
void attach (T *tptr, void(T::*mptr)(void), IrqType type=RxIrq)
 
void send_break ()
 
void set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC)
 
int write (void *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 
int write (const Buffer &buf, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 
void abort_write ()
 
int read (void *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)
 
int read (const Buffer &buffer, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)
 
void abort_read ()
 
int set_dma_usage_tx (DMAUsage usage)
 
int set_dma_usage_rx (DMAUsage usage)
 

Additional Inherited Members

- Public Types inherited from mbed::SerialBase
enum  Parity {
  None = 0, Odd, Even, Forced1,
  Forced0
}
 
enum  IrqType { RxIrq = 0, TxIrq }
 
enum  Flow { Disabled = 0, RTS, CTS, RTSCTS }
 
typedef mbed::util::FunctionPointer2< void, Buffer, int > event_callback_t
 
- Static Public Member Functions inherited from mbed::SerialBase
static void _irq_handler (uint32_t id, SerialIrq irq_type)
 
- Protected Types inherited from mbed::SerialBase
typedef OneWayTransaction< event_callback_ttransaction_data_t
 
typedef Transaction< SerialBase, transaction_data_ttransaction_t
 
- Protected Member Functions inherited from mbed::SerialBase
void start_read (const Buffer &buffer, char buffer_width, const event_callback_t &callback, int event, unsigned char char_match)
 
void start_write (const Buffer &buffer, char buffer_width, const event_callback_t &callback, int event)
 
void interrupt_handler_asynch (void)
 
 SerialBase (PinName tx, PinName rx)
 
int _base_getc ()
 
int _base_putc (int c)
 
- Protected Attributes inherited from mbed::SerialBase
CThunk< SerialBase_thunk_irq
 
transaction_data_t _current_tx_transaction
 
transaction_data_t _current_rx_transaction
 
DMAUsage _tx_usage
 
DMAUsage _rx_usage
 
serial_t _serial
 
mbed::util::FunctionPointer _irq [2]
 
int _baud
 

Detailed Description

A serial port (UART) for communication with other serial devices This is a variation of the Serial class that doesn't use streams, thus making it safe to use in interrupt handlers with the RTOS.

Can be used for Full Duplex communication, or Simplex by specifying one pin as NC (Not Connected)

Example:

// Send a char to the PC
#include "mbed.h"
RawSerial pc(USBTX, USBRX);
int main() {
pc.putc('A');
}

Constructor & Destructor Documentation

mbed::RawSerial::RawSerial ( PinName  tx,
PinName  rx 
)

Create a RawSerial port, connected to the specified transmit and receive pins

Parameters
txTransmit pin
rxReceive pin
Note
Either tx or rx may be specified as NC if unused

Member Function Documentation

int mbed::RawSerial::getc ( )

Read a char from the serial port

Returns
The char read from the serial port
int mbed::RawSerial::putc ( int  c)

Write a char to the serial port

Parameters
cThe char to write
Returns
The written char or -1 if an error occured
int mbed::RawSerial::puts ( const char *  str)

Write a string to the serial port

Parameters
strThe string to write
Returns
0 if the write succeeds, EOF for error

The documentation for this class was generated from the following files: