![]() |
Kinetis Bootloader Host
2.0.0
Host Tools for Kinetis devices
|
Peripheral that talks to the target device over COM port hardware. More...
#include <UartPeripheral.h>
Inheritance diagram for blfwk::UartPeripheral:
Collaboration diagram for blfwk::UartPeripheral:Public Types | |
| enum | _uart_peripheral_constants { kUartPeripheral_UnusedTimeout = 0, kUartPeripheral_DefaultReadTimeoutMs = 1000, kUartPeripheral_DefaultBaudRate = 9600 } |
| Constants. | |
Public Types inherited from blfwk::Peripheral | |
| enum | _host_peripheral_types { kHostPeripheralType_None, kHostPeripheralType_UART, kHostPeripheralType_BUSPAL_UART, kHostPeripheralType_USB_HID, kHostPeripheralType_SIM } |
Public Member Functions | |
| UartPeripheral (const char *port, long speed=kUartPeripheral_DefaultBaudRate) | |
| Parameterized constructor that opens the serial port. More... | |
| virtual | ~UartPeripheral () |
| Destructor. | |
| void | flushRX () |
| Flush. More... | |
| virtual status_t | read (uint8_t *buffer, uint32_t requestedBytes, uint32_t *actualBytes, uint32_t unused_timeoutMs) |
| Read bytes. More... | |
| virtual status_t | write (const uint8_t *buffer, uint32_t byteCount) |
| Write bytes. More... | |
Protected Member Functions | |
| bool | init (const char *port, long speed) |
| Initialize. More... | |
Protected Attributes | |
| int | m_fileDescriptor |
| Port file descriptor. | |
| uint8_t | m_buffer [kDefaultMaxPacketSize] |
| Buffer for bytes used to build read packet. | |
Peripheral that talks to the target device over COM port hardware.
| UartPeripheral::UartPeripheral | ( | const char * | port, |
| long | speed = kUartPeripheral_DefaultBaudRate |
||
| ) |
Parameterized constructor that opens the serial port.
Opens and configures the port. Throws exception if port configuration fails.
Note: following COM port configuration is assumed: 8 bits, 1 stop bit, no parity.
| port | OS file path for COM port. For example "COM1" on Windows. |
| speed | Port speed, e.g. 9600. |
| void UartPeripheral::flushRX | ( | ) |
Flush.
should be called on an open COM port in order to flush any remaining data in the UART RX buffer
|
protected |
Initialize.
Opens and configures the port.
Note: following COM port configuration is assumed: 8 bits, 1 stop bit, no parity.
| port | OS file path for COM port. For example "COM1" on Windows. |
| speed | Port speed, e.g. 9600. |
|
virtual |
Read bytes.
| buffer | Pointer to buffer. |
| requestedBytes | Number of bytes to read. |
| actualBytes | Number of bytes actually read. |
| timeoutMs | Time in milliseconds to wait for read to complete. |
Implements blfwk::Peripheral.
Reimplemented in blfwk::BusPalUartPeripheral.
|
virtual |
Write bytes.
| buffer | Pointer to buffer to write |
| byteCount | Number of bytes to write |
Implements blfwk::Peripheral.
Reimplemented in blfwk::BusPalUartPeripheral.