PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
SF32LB

UART driver for the SF32LB USART. More...

Data Structures

struct  pbl_uart_sf32lb
 SF32LB serial port. More...
 

Macros

#define PBL_UART_SF32LB_RX_BUF_SIZE   256U
 Size of the receive buffer of a port with a receive DMA channel, in bytes.
 
#define PBL_UART_SF32LB_DEFINE(sym, _name, _base, _irq, _clk, _baudrate, _pinctrl, ...)
 Define a serial port on an SF32LB USART.
 

Functions

void pbl_uart_sf32lb_irq_handler (const struct pbl_uart_sf32lb *uart)
 USART interrupt handler, connected by PBL_UART_SF32LB_DEFINE().
 

Detailed Description

UART driver for the SF32LB USART.

Bytes are sent polled. Received bytes come from the receive interrupt or, with a receive DMA channel, from a cyclic transfer into a receive buffer, drained when the line goes idle and at each half of the buffer. Deep sleep is blocked while reception is enabled. An instance connects its interrupt itself, with priority CONFIG_UART_SF32LB_IRQ_PRIO:

static const struct pbl_dma_chan s_usart1_rx_dma =
PBL_UART_SF32LB_DEFINE(s_usart1, "usart1", 0x50084000, PBL_SOC_IRQN_USART1,
PBL_CLK(SF32LB_HPSYS_RCC, SF32LB52_HPSYS_CLK_PERI), 1000000,
&s_usart1_default, &s_usart1_rx_dma);
#define SF32LB_HPSYS_RCC
HPSYS RCC clock controller.
Definition sf32lb.h:27
#define PBL_CLK(_ctrl, _id)
Initializer for a struct pbl_clk.
Definition clk.h:132
#define SF32LB52_DMA_REQ_USART1_RX
Definition sf32lb.h:59
#define SF32LB_DMA_PL_MEDIUM
Medium priority.
Definition sf32lb.h:44
A channel, as used by a consumer.
Definition dma.h:91
#define PBL_DMA_CHAN(_ctrl, _channel, _request, _config)
Initializer for a struct pbl_dma_chan.
Definition dma.h:110
#define PBL_UART_SF32LB_DEFINE(sym, _name, _base, _irq, _clk, _baudrate, _pinctrl,...)
Define a serial port on an SF32LB USART.
Definition sf32lb.h:85

Data Structure Documentation

◆ pbl_uart_sf32lb

struct pbl_uart_sf32lb

SF32LB serial port.

Data Fields
uintptr_t base Registers.
struct pbl_clk clk Clock.
pbl_irq_t irq Interrupt line.
struct pbl_pinctrl pinctrl Pins.
uint8_t * rx_buf Receive buffer of PBL_UART_SF32LB_RX_BUF_SIZE bytes, with a receive DMA channel.
const struct pbl_dma_chan * rx_dma Receive DMA channel, or NULL.
struct pbl_uart_sf32lb_state * state Driver runtime state.
struct pbl_uart uart Serial port.

Macro Definition Documentation

◆ PBL_UART_SF32LB_DEFINE

#define PBL_UART_SF32LB_DEFINE (   sym,
  _name,
  _base,
  _irq,
  _clk,
  _baudrate,
  _pinctrl,
  ... 
)
Value:
static struct pbl_uart_sf32lb_state sym##_sf32lb_state; \
__VA_OPT__( \
PBL_DEVICE_INSTANCE(sym, struct pbl_uart_sf32lb, struct pbl_uart, uart){ \
.uart = PBL_UART_INIT(sym, _name, nullptr, &pbl_uart_sf32lb_ops, _baudrate), \
.state = &sym##_sf32lb_state, \
.base = (_base), \
.irq = (_irq), \
.clk = _clk, \
.pinctrl = PBL_PINCTRL(_pinctrl, nullptr, 0), \
.rx_dma = PBL_UART_SF32LB_FIRST_(__VA_ARGS__ __VA_OPT__(, ) nullptr), \
.rx_buf = PBL_UART_SF32LB_FIRST_(__VA_OPT__(sym##_rx_buf, ) nullptr), \
}; \
PBL_IRQ_CONNECT_NUM(_irq, CONFIG_UART_SF32LB_IRQ_PRIO, pbl_uart_sf32lb_irq_handler, &sym##_inst, \
0)
#define PBL_DEVICE_INSTANCE(sym, type, class_type, member)
Start the definition of a registered instance, followed by its initializer.
Definition device.h:243
#define PBL_PINCTRL(_default, _sleep, _reg)
Initializer for a struct pbl_pinctrl.
Definition pinctrl.h:132
SF32LB serial port.
Definition sf32lb.h:48
#define PBL_UART_SF32LB_RX_BUF_SIZE
Size of the receive buffer of a port with a receive DMA channel, in bytes.
Definition sf32lb.h:38
void pbl_uart_sf32lb_irq_handler(const struct pbl_uart_sf32lb *uart)
USART interrupt handler, connected by PBL_UART_SF32LB_DEFINE().
A serial port.
Definition uart.h:135
#define PBL_UART_STATE_DEFINE(sym)
Define the class state of port sym, for the PBL_UART_*_DEFINE() macro of a driver.
Definition uart.h:151
#define PBL_UART_INIT(sym, _name, _parent, _ops, _baudrate)
Initializer for the struct pbl_uart of port sym.
Definition uart.h:164
#define PBL_DCACHE_LINE_SIZE
Data cache line size in bytes, 1 without a data cache.
Definition cache.h:40
#define PBL_ALIGNED(bytes)
Align the symbol or type.
Definition compiler.h:87

Define a serial port on an SF32LB USART.

Parameters
symSymbol of the port.
_nameName.
_baseRegisters.
_irqInterrupt line.
_clkClock, from PBL_CLK().
_baudrateInitial baud rate, in bits per second.
_pinctrlDefault pin control state.
...Receive DMA channel, if any, which also gives the port its receive buffer.

◆ PBL_UART_SF32LB_RX_BUF_SIZE

#define PBL_UART_SF32LB_RX_BUF_SIZE   256U

Size of the receive buffer of a port with a receive DMA channel, in bytes.

Function Documentation

◆ pbl_uart_sf32lb_irq_handler()

void pbl_uart_sf32lb_irq_handler ( const struct pbl_uart_sf32lb *  uart)

USART interrupt handler, connected by PBL_UART_SF32LB_DEFINE().

Parameters
uartPort.