CORE2 v1.0.0
hFramework::hSerial Class Reference

Serial port (UART) interface. More...

#include <hSerial.h>

Inheritance diagram for hFramework::hSerial:
[legend]
Collaboration diagram for hFramework::hSerial:
[legend]

Public Member Functions

 hSerial (hSerial_ID no)
 
void init (uint32_t baudrate=460800, Parity parity=Parity::None, StopBits stopBits=StopBits::One)
 Initialize serial port. More...
 
int write (const void *data, int len, uint32_t timeout=INFINITE) override
 Write data to the underlying device. More...
 
int read (void *data, int len, uint32_t timeout=INFINITE) override
 Read data from the underlying device. If less than len bytes is available then less might be returned. More...
 
void setBaudrate (uint32_t baudrate) override
 
void flushRx () override
 Flush the RX queue.
 
uint32_t available () override
 Return number of bytes waiting in the RX queue. More...
 
bool waitForData (uint32_t timeout)
 
void selectGPIO ()
 
void selectSerial ()
 
- Public Member Functions inherited from hFramework::hStreamDev
int readAll (void *data, int len, uint32_t timeout=0xffffffff)
 Read data from the underlying device. More...
 
int writeAll (const void *data, int len, uint32_t timeout=0xffffffff)
 Write data to the underlying device. More...
 
int printf (const char *format,...)
 Write formatted string to the underlying device. More...
 
virtual int vprintf (const char *format, va_list arg)
 Write formatted string to the underlying device. More...
 
int putchar (char c)
 Put single character. More...
 
int getch ()
 Return single character. More...
 

Public Attributes

hGPIO pinTx
 
hGPIO pinRx
 

Friends

class hExt
 

Detailed Description

Serial port (UART) interface.

You should never need to construct this class directly. Use Serial and Edison variables. Serials for hExts are in hExt::serial variables (e.g. hExt1.serial)

Member Function Documentation

uint32_t hFramework::hSerial::available ( )
overridevirtual

Return number of bytes waiting in the RX queue.

Returns
bytes waiting in RX queue.

Implements hFramework::ISerial.

void hFramework::hSerial::init ( uint32_t  baudrate = 460800,
Parity  parity = Parity::None,
StopBits  stopBits = StopBits::One 
)

Initialize serial port.

Parameters
baudratea baudrate value
uparan UART parity value (NONE, ODD, EVEN)
ustopbusart stop bits (ONE, TWO)
int hFramework::hSerial::read ( void *  data,
int  len,
uint32_t  timeout = INFINITE 
)
overridevirtual

Read data from the underlying device. If less than len bytes is available then less might be returned.

Parameters
datadata to be read
lennumber of bytes to read
timeoutmaximum timeout of the operation
Returns
Number of read bytes.

Implements hFramework::hStreamDev.

int hFramework::hSerial::write ( const void *  data,
int  len,
uint32_t  timeout = INFINITE 
)
overridevirtual

Write data to the underlying device.

Parameters
datadata to be written
lennumber of bytes to write
timeoutmaximum timeout of the operation
Returns
Number of written bytes.

Implements hFramework::hStreamDev.


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