PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
Serial port drivers

Interface for serial port drivers. More...

Data Structures

struct  pbl_uart_ops
 Port driver operations. More...
 
struct  pbl_uart
 A serial port. More...
 

Macros

#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.
 

Functions

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.
 

Detailed Description

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.


Data Structure Documentation

◆ pbl_uart

struct pbl_uart

A serial port.

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.

Macro Definition Documentation

◆ PBL_UART_INIT

#define PBL_UART_INIT (   sym,
  _name,
  _parent,
  _ops,
  _baudrate 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_uart_dev_init, _parent, &pbl_uart_class), \
.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
symSymbol of the port instance, with its state defined by PBL_UART_STATE_DEFINE().
_nameName.
_parentParent device, or NULL.
_opsDriver operations.
_baudrateInitial 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
symSymbol of the port instance.

Function Documentation

◆ 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
devPort device.
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
uartPort.
cByte.
Returns
true if reception is still enabled, false if the driver must hold further bytes back.