PebbleOS v4.43.0-47-g70dbc56d2
Loading...
Searching...
No Matches
Pin control

Pin controller class. More...

Modules

 SF32LB52 pin controller
 Pin control controller of the SF32LB52 HPSYS pads.
 

Data Structures

struct  pbl_pinctrl_controller_ops
 Pin controller driver operations. More...
 
struct  pbl_pinctrl_controller
 A pin controller. More...
 
struct  pbl_pinctrl_state
 A pin state. More...
 
struct  pbl_pinctrl
 Pin states of a peripheral, as used by a consumer. More...
 

Macros

#define PBL_PINCTRL_CONTROLLER_INIT(sym, _name, _ops, _num_pads)
 Initializer for the struct pbl_pinctrl_controller of controller sym.
 
#define PBL_PINCTRL_STATE_DEFINE(sym, _ctrl, ...)
 Define a pin state.
 
#define PBL_PINCTRL(_default, _sleep, _reg)
 Initializer for a struct pbl_pinctrl.
 

Enumerations

enum  pbl_pinctrl_state_id { PBL_PINCTRL_STATE_DEFAULT , PBL_PINCTRL_STATE_SLEEP }
 State identifiers. More...
 

Functions

int pbl_pinctrl_select_state (const struct pbl_pinctrl *pinctrl, enum pbl_pinctrl_state_id id)
 Configure the pins of a state.
 

Variables

const struct pbl_device_class pbl_pinctrl_class
 Class of the pin controllers.
 

Detailed Description

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 | ...);
.pinctrl = PBL_PINCTRL(&s_uart1_default, nullptr, 0),
#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.


Data Structure Documentation

◆ pbl_pinctrl_controller

struct pbl_pinctrl_controller

A pin controller.

Data Fields
struct pbl_device dev Device.
uint16_t num_pads Number of pads.
const struct pbl_pinctrl_controller_ops * ops Driver operations.

◆ pbl_pinctrl_state

struct pbl_pinctrl_state

A pin 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

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

Macro Definition Documentation

◆ PBL_PINCTRL

#define PBL_PINCTRL (   _default,
  _sleep,
  _reg 
)
Value:
{ \
.states = {[PBL_PINCTRL_STATE_DEFAULT] = (_default), [PBL_PINCTRL_STATE_SLEEP] = (_sleep)}, \
.reg = (_reg), \
}
@ PBL_PINCTRL_STATE_SLEEP
Pins of a powered-down peripheral.
Definition pinctrl.h:110

Initializer for a struct pbl_pinctrl.

Parameters
_defaultDefault state.
_sleepSleep state, or NULL.
_regRegister base of the peripheral.

◆ PBL_PINCTRL_CONTROLLER_INIT

#define PBL_PINCTRL_CONTROLLER_INIT (   sym,
  _name,
  _ops,
  _num_pads 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, nullptr, nullptr, nullptr, &pbl_pinctrl_class), \
.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
symSymbol of the controller instance, with its state defined by PBL_DEVICE_STATE_DEFINE().
_nameName.
_opsDriver operations.
_num_padsNumber of pads.

◆ PBL_PINCTRL_STATE_DEFINE

#define PBL_PINCTRL_STATE_DEFINE (   sym,
  _ctrl,
  ... 
)
Value:
static const uint32_t sym##_pins[] = {__VA_ARGS__}; \
static const struct pbl_pinctrl_state sym = { \
.ctrl = (_ctrl), \
.pins = sym##_pins, \
.num_pins = ARRAY_LENGTH(sym##_pins), \
}
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
symSymbol of the state.
_ctrlPin controller.
...Pins, in the controller's encoding.

Enumeration Type Documentation

◆ pbl_pinctrl_state_id

State identifiers.

Enumerator
PBL_PINCTRL_STATE_DEFAULT 

Pins in use.

PBL_PINCTRL_STATE_SLEEP 

Pins of a powered-down peripheral.

Function Documentation

◆ pbl_pinctrl_select_state()

int pbl_pinctrl_select_state ( const struct pbl_pinctrl *  pinctrl,
enum pbl_pinctrl_state_id  id 
)

Configure the pins of a state.

Parameters
pinctrlPin states of the peripheral.
idState.
Returns
0, -ENOENT if the board gives no such state, or another negative errno.

Variable Documentation

◆ pbl_pinctrl_class

const struct pbl_device_class pbl_pinctrl_class
extern

Class of the pin controllers.