Interface for serial port drivers.
More...
|
| #define | PBL_UART_STATE_DEFINE(sym) |
| | Define the class state of port sym, for the PBL_UART_*_DEFINE() macro of a driver.
|
| |
| #define | PBL_UART_INIT(sym, _name, _parent, _ops, _baudrate) |
| | Initializer for the struct pbl_uart of port sym.
|
| |
|
| int | pbl_uart_dev_init (const struct pbl_device *dev) |
| | Device init of every port: calls the driver's init, then applies the line settings, the early console's if the port was one.
|
| |
| bool | pbl_uart_receive (const struct pbl_uart *uart, uint8_t c) |
| | Hand a received byte to the receive callback.
|
| |
Interface for serial port drivers.
A driver embeds a struct pbl_uart in its instance, sets it up with PBL_UART_STATE_DEFINE() and PBL_UART_INIT(), and implements the struct pbl_uart_ops the class calls.
◆ pbl_uart
| Data Fields |
|
uint32_t |
baudrate |
Initial baud rate, in bits per second. |
|
struct pbl_device |
dev |
Device. |
|
const struct pbl_uart_ops * |
ops |
Driver operations. |
|
struct pbl_uart_state * |
state |
Runtime state. |
◆ PBL_UART_INIT
| #define PBL_UART_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops, |
|
|
|
_baudrate |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_uart_state, \
.baudrate = (_baudrate), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153
int pbl_uart_dev_init(const struct pbl_device *dev)
Device init of every port: calls the driver's init, then applies the line settings,...
Initializer for the struct pbl_uart of port sym.
- Parameters
-
| sym | Symbol of the port instance, with its state defined by PBL_UART_STATE_DEFINE(). |
| _name | Name. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| _baudrate | Initial baud rate, in bits per second. |
◆ PBL_UART_STATE_DEFINE
| #define PBL_UART_STATE_DEFINE |
( |
|
sym | ) |
|
Value:
static struct pbl_uart_state sym##_uart_state
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
Define the class state of port sym, for the PBL_UART_*_DEFINE() macro of a driver.
- Parameters
-
| sym | Symbol of the port instance. |
◆ pbl_uart_dev_init()
| int pbl_uart_dev_init |
( |
const struct pbl_device * |
dev | ) |
|
Device init of every port: calls the driver's init, then applies the line settings, the early console's if the port was one.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_uart_receive()
| bool pbl_uart_receive |
( |
const struct pbl_uart * |
uart, |
|
|
uint8_t |
c |
|
) |
| |
Hand a received byte to the receive callback.
Called by the port driver from its interrupt.
- Parameters
-
- Returns
- true if reception is still enabled, false if the driver must hold further bytes back.