Pin controller class.
More...
Pin controller class.
A pin controller is a struct pbl_pinctrl_controller device that routes peripheral signals to pins and sets their pad options. A pin is one 32-bit word in an encoding defined by the controller header, and a state is a list of pins defined by the board. A consumer holds a struct pbl_pinctrl with its default state, an optional sleep state, and its register base, which controllers without a pin multiplexer use to fill the peripheral's own pin select registers. It selects the default state before using the peripheral, and the sleep state, if any, after powering it down:
SF32LB52_PA19_USART1_TXD | ...,
SF32LB52_PA18_USART1_RXD | ...);
#define SF32LB52_PINCTRL
HPSYS pin controller.
Definition sf32lb52.h:120
#define PBL_PINCTRL_STATE_DEFINE(sym, _ctrl,...)
Define a pin state.
Definition pinctrl.h:97
int pbl_pinctrl_select_state(const struct pbl_pinctrl *pinctrl, enum pbl_pinctrl_state_id id)
Configure the pins of a state.
#define PBL_PINCTRL(_default, _sleep, _reg)
Initializer for a struct pbl_pinctrl.
Definition pinctrl.h:131
@ PBL_PINCTRL_STATE_DEFAULT
Pins in use.
Definition pinctrl.h:108
Controllers need no initialization, so states can be selected before the devices are initialized, e.g. for the debug console.
◆ pbl_pinctrl_controller
| struct pbl_pinctrl_controller |
◆ pbl_pinctrl_state
| Data Fields |
|
const struct pbl_pinctrl_controller * |
ctrl |
Controller of the pins. |
|
uint8_t |
num_pins |
Number of pins. |
|
const uint32_t * |
pins |
Pins, in the controller's encoding. |
◆ pbl_pinctrl
Pin states of a peripheral, as used by a consumer.
| Data Fields |
|
uintptr_t |
reg |
Register base of the peripheral. |
|
const struct pbl_pinctrl_state * |
states[PBL_PINCTRL_STATE_COUNT] |
States by identifier, NULL if the board gives none. |
◆ PBL_PINCTRL
| #define PBL_PINCTRL |
( |
|
_default, |
|
|
|
_sleep, |
|
|
|
_reg |
|
) |
| |
Value: { \
.reg = (_reg), \
}
@ PBL_PINCTRL_STATE_SLEEP
Pins of a powered-down peripheral.
Definition pinctrl.h:110
Initializer for a struct pbl_pinctrl.
- Parameters
-
| _default | Default state. |
| _sleep | Sleep state, or NULL. |
| _reg | Register base of the peripheral. |
◆ PBL_PINCTRL_CONTROLLER_INIT
| #define PBL_PINCTRL_CONTROLLER_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_ops, |
|
|
|
_num_pads |
|
) |
| |
Value: { \
.ops = (_ops), \
.num_pads = (_num_pads), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _deps, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:123
const struct pbl_device_class pbl_pinctrl_class
Class of the pin controllers.
Initializer for the struct pbl_pinctrl_controller of controller sym.
- Parameters
-
| sym | Symbol of the controller instance, with its state defined by PBL_DEVICE_STATE_DEFINE(). |
| _name | Name. |
| _ops | Driver operations. |
| _num_pads | Number of pads. |
◆ PBL_PINCTRL_STATE_DEFINE
| #define PBL_PINCTRL_STATE_DEFINE |
( |
|
sym, |
|
|
|
_ctrl, |
|
|
|
... |
|
) |
| |
Value: static const uint32_t sym##_pins[] = {__VA_ARGS__}; \
}
uint8_t num_pins
Number of pins.
Definition pinctrl.h:87
const struct pbl_pinctrl_controller * ctrl
Controller of the pins.
Definition pinctrl.h:83
const uint32_t * pins
Pins, in the controller's encoding.
Definition pinctrl.h:85
A pin state.
Definition pinctrl.h:81
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18
Define a pin state.
- Parameters
-
| sym | Symbol of the state. |
| _ctrl | Pin controller. |
| ... | Pins, in the controller's encoding. |
◆ pbl_pinctrl_state_id
State identifiers.
| Enumerator |
|---|
| PBL_PINCTRL_STATE_DEFAULT | Pins in use.
|
| PBL_PINCTRL_STATE_SLEEP | Pins of a powered-down peripheral.
|
◆ pbl_pinctrl_select_state()
Configure the pins of a state.
- Parameters
-
| pinctrl | Pin states of the peripheral. |
| id | State. |
- Returns
- 0,
-ENOENT if the board gives no such state, or another negative errno.
◆ pbl_pinctrl_class
Class of the pin controllers.