PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
SPI controller drivers

Interface for SPI controller drivers. More...

Data Structures

struct  pbl_spi_bus_ops
 Bus driver operations. More...
 

Macros

#define PBL_SPI_BUS_STATE_DEFINE(sym, ...)
 Define the class state of bus sym, for the PBL_SPI_*_DEFINE() macro of a driver.
 
#define PBL_SPI_BUS_INIT(sym, _name, _parent, _ops)
 Initializer for the struct pbl_spi_bus of bus sym.
 

Functions

int pbl_spi_bus_dev_init (const struct pbl_device *dev)
 Device init of every bus: sets the class state up, then calls the driver's init.
 
void pbl_spi_bus_complete (const struct pbl_spi_bus *bus, int status)
 Report the outcome of the transfer in flight.
 

Detailed Description

Interface for SPI controller drivers.

A driver embeds a struct pbl_spi_bus in its instance, sets it up with PBL_SPI_BUS_STATE_DEFINE() and PBL_SPI_BUS_INIT(), and implements the struct pbl_spi_bus_ops the class calls.

Macro Definition Documentation

◆ PBL_SPI_BUS_INIT

#define PBL_SPI_BUS_INIT (   sym,
  _name,
  _parent,
  _ops 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_spi_bus_dev_init, _parent, &pbl_spi_bus_class), \
.ops = (_ops), \
.state = &sym##_spi_state, \
.cs_gpios = sym##_cs_gpios, \
.num_cs = PBL_ARRAY_SIZE(sym##_cs_gpios), \
}
#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_spi_bus_dev_init(const struct pbl_device *dev)
Device init of every bus: sets the class state up, then calls the driver's init.
#define PBL_ARRAY_SIZE(array)
Get the number of elements of an array.
Definition size.h:40

Initializer for the struct pbl_spi_bus of bus sym.

Parameters
symSymbol of the bus instance, with its state defined by PBL_SPI_BUS_STATE_DEFINE().
_nameName.
_parentParent device, or NULL.
_opsDriver operations.

◆ PBL_SPI_BUS_STATE_DEFINE

#define PBL_SPI_BUS_STATE_DEFINE (   sym,
  ... 
)
Value:
static struct pbl_spi_bus_state sym##_spi_state; \
static const struct pbl_gpio sym##_cs_gpios[] = {__VA_ARGS__}
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
A pin as wired on the board.
Definition gpio.h:110

Define the class state of bus sym, for the PBL_SPI_*_DEFINE() macro of a driver.

Parameters
symSymbol of the bus instance.
...Chip select GPIOs, from PBL_GPIO().

Function Documentation

◆ pbl_spi_bus_complete()

void pbl_spi_bus_complete ( const struct pbl_spi_bus *  bus,
int  status 
)

Report the outcome of the transfer in flight.

Called by the bus driver from its interrupt handler. Starts the next transfer, or ends the sequence and calls its callback.

Parameters
busBus.
status0 or a negative errno.

◆ pbl_spi_bus_dev_init()

int pbl_spi_bus_dev_init ( const struct pbl_device *  dev)

Device init of every bus: sets the class state up, then calls the driver's init.

Parameters
devBus device.
Returns
0 or a negative errno.