Interface for SPI controller drivers.
More...
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.
◆ PBL_SPI_BUS_INIT
| #define PBL_SPI_BUS_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_spi_state, \
.cs_gpios = 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
-
| sym | Symbol of the bus instance, with its state defined by PBL_SPI_BUS_STATE_DEFINE(). |
| _name | Name. |
| _parent | Parent device, or NULL. |
| _ops | Driver 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
-
| sym | Symbol of the bus instance. |
| ... | Chip select GPIOs, from PBL_GPIO(). |
◆ 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
-
| bus | Bus. |
| status | 0 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
-
- Returns
- 0 or a negative errno.