The HardwareSerial class implements methods for communicating with Hardware UARTs (Universal Asynchronous Receiver / Transmitter )
- 1 Detailed Introduction
- 2 Full library usage
- 2.1 HardwareSerial
- 2.1.1 Constructors
- 2.1.2 Public Functions
- 2.1.3 Virtual Private Functions
- 2.1.4 Print Class Functions
- 2.1.5 Conversion Operator
- 2.1 HardwareSerial
- 3 External Links
The HardwareSerial class is derived from class Stream. It's purpose is to provide methods for sending and receiving data over the available UARTs.
Full library usage
- Parent class: Stream
HardwareSerial(p32_uart * uartP, int irq, int vec, int ipl, int spl, isrFunc isrHandler, int pinT, int pinR, ppsFunctionType ppsT, ppsFunctionType ppsR);
Create a new HardwareSerial object for PIC32MX1XX, PIC32MX2XX, PIC32MZXX, PIC32MX47X based boards
HardwareSerial(p32_uart * uartP, int irq, int vec, int ipl, int spl, isrFunc isrHandler);
Create a new HardwareSerial object for boards based on microcontrollers not listed above.
|uartP||Pointer to base register for UART|
|irq||Base IRQ number for UART|
|vec||Interrupt vector for the UART|
|ipl||Interrupt priority level|
|spl||Interrupt sub-priority level|
|isrHandler||Interrupt Service Routine Handler|
|pinT||Digital pin number of TX|
|pinR||Digital pin number of RX|
|ppsT||Peripheral Pin Select for UART TX|
|ppsR||Peripheral Pin Select for UART RX|
This function is called by the interrupt service routine for the UART being used by this object. It's purpose is to process receive interrupts and place the received characters into the receive buffer.
void attachInterrupt(void (*callback)(int));
Attach the interrupt. The callback parameter takes a funtion pointer.
Detach the interrupt
void enableAddressDetection (void);
Sets the bit in the UART status register that enables address detection
Clears the bit in the UART status register that enables address detection
begin(unsigned long baudRate)
void begin(unsigned long baudRate);
Initialize the UART for use, setting the baud rate to the requested value, data size of 8-bits, and no parity.
begin(unsigned long baudRate, uint8_t address)
void begin(unsigned long baudRate, uint8_t address);
Initialize the UART for use, setting the baud rate to the requested value, data size of 9-bits, and no parity and address detection mode
Disable the UART and UART interrupts.
Virtual Private Functions
virtual in available(void);
Return the number of characters currently available in the receive buffer.
virtual int peek();
This returns the next character in the receive buffer without removing it from the buffer, or -1 if no characters are in the buffer.
virtual int read(void);
Return the next character from the receive buffer and remove it from the buffer, or -1 if no characters are available in the buffer.
virtual void flush(void);
Empty the send buffer by waiting for the fifo to empty and the transmitter to become idle
virtual void purge(void);
Empty the receive buffer by discarding any characters in the buffer.
virtual size_t write(uint8_t);
Wait until the transmitter is idle, and then transmit thespecified character.
Print Class Functions
The following write functions are pulled in from the Print class.
write(const char *str)
size_t write(const char *str);
write(const char *buffer, size_t size)
size_t write(const char *buffer, size_t size);
- https://github.com/chipKIT32/chipKIT-core/tree/master/pic32/cores/pic32 - The github repository for the PIC32 chipKIT Core