Zephyr Project API 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Pin Controller Interface

Pin Controller Interface. More...

Modules

 Dynamic Pin Control
 

Data Structures

struct  pinctrl_state
 Pin control state configuration. More...
 
struct  pinctrl_dev_config
 Pin controller configuration for a given device. More...
 

Macros

#define PINCTRL_REG_NONE   0U
 Utility macro to indicate no register is used.
 
#define PINCTRL_DT_DEV_CONFIG_DECLARE(node_id)
 Declare pin control configuration for a given node identifier.
 
#define PINCTRL_DT_DEFINE(node_id)
 Define all pin control information for the given node identifier.
 
#define PINCTRL_DT_INST_DEFINE(inst)   PINCTRL_DT_DEFINE(DT_DRV_INST(inst))
 Define all pin control information for the given compatible index.
 
#define PINCTRL_DT_DEV_CONFIG_GET(node_id)   &Z_PINCTRL_DEV_CONFIG_NAME(node_id)
 Obtain a reference to the pin control configuration given a node identifier.
 
#define PINCTRL_DT_INST_DEV_CONFIG_GET(inst)    PINCTRL_DT_DEV_CONFIG_GET(DT_DRV_INST(inst))
 Obtain a reference to the pin control configuration given current compatible instance number.
 

Functions

int pinctrl_lookup_state (const struct pinctrl_dev_config *config, uint8_t id, const struct pinctrl_state **state)
 Find the state configuration for the given state id.
 
int pinctrl_configure_pins (const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
 Configure a set of pins.
 
static int pinctrl_apply_state_direct (const struct pinctrl_dev_config *config, const struct pinctrl_state *state)
 Apply a state directly from the provided state configuration.
 
static int pinctrl_apply_state (const struct pinctrl_dev_config *config, uint8_t id)
 Apply a state from the given device configuration.
 

Pin control states

#define PINCTRL_STATE_DEFAULT   0U
 Default state (state used when the device is in operational state).
 
#define PINCTRL_STATE_SLEEP   1U
 Sleep state (state used when the device is in low power mode).
 
#define PINCTRL_STATE_PRIV_START   2U
 This and higher values refer to custom private states.
 

Detailed Description

Pin Controller Interface.

Since
3.0
Version
0.1.0

Macro Definition Documentation

◆ PINCTRL_DT_DEFINE

#define PINCTRL_DT_DEFINE (   node_id)

#include <include/zephyr/drivers/pinctrl.h>

Value:
Z_PINCTRL_STATE_PINS_DEFINE, (;), node_id); \
Z_PINCTRL_STATES_DEFINE(node_id) \
Z_PINCTRL_DEV_CONFIG_STATIC Z_PINCTRL_DEV_CONFIG_CONST \
struct pinctrl_dev_config Z_PINCTRL_DEV_CONFIG_NAME(node_id) = \
Z_PINCTRL_DEV_CONFIG_INIT(node_id)
#define DT_NUM_PINCTRL_STATES(node_id)
Get the number of pinctrl properties in a node.
Definition pinctrl.h:239
#define LISTIFY(LEN, F, sep,...)
Generates a sequence of code with configurable separator.
Definition util_macro.h:458
Pin controller configuration for a given device.
Definition pinctrl.h:62

Define all pin control information for the given node identifier.

This helper macro should be called together with device definition. It defines and initializes the pin control configuration for the device represented by node_id. Each pin control state (pinctrl-0, ..., pinctrl-N) is also defined and initialized. Note that states marked to be skipped will not be defined (refer to Z_PINCTRL_SKIP_STATE for more details).

Parameters
node_idNode identifier.

◆ PINCTRL_DT_DEV_CONFIG_DECLARE

#define PINCTRL_DT_DEV_CONFIG_DECLARE (   node_id)

#include <include/zephyr/drivers/pinctrl.h>

Value:
extern Z_PINCTRL_DEV_CONFIG_CONST struct pinctrl_dev_config \
Z_PINCTRL_DEV_CONFIG_NAME(node_id)

Declare pin control configuration for a given node identifier.

This macro should be used by tests or applications using runtime pin control to declare the pin control configuration for a device. PINCTRL_DT_DEV_CONFIG_GET can later be used to obtain a reference to such configuration.

Only available if

CONFIG_PINCTRL_NON_STATIC 

is selected.

Parameters
node_idNode identifier.

◆ PINCTRL_DT_DEV_CONFIG_GET

#define PINCTRL_DT_DEV_CONFIG_GET (   node_id)    &Z_PINCTRL_DEV_CONFIG_NAME(node_id)

#include <include/zephyr/drivers/pinctrl.h>

Obtain a reference to the pin control configuration given a node identifier.

Parameters
node_idNode identifier.

◆ PINCTRL_DT_INST_DEFINE

#define PINCTRL_DT_INST_DEFINE (   inst)    PINCTRL_DT_DEFINE(DT_DRV_INST(inst))

#include <include/zephyr/drivers/pinctrl.h>

Define all pin control information for the given compatible index.

Parameters
instInstance number.
See also
PINCTRL_DT_DEFINE

◆ PINCTRL_DT_INST_DEV_CONFIG_GET

#define PINCTRL_DT_INST_DEV_CONFIG_GET (   inst)     PINCTRL_DT_DEV_CONFIG_GET(DT_DRV_INST(inst))

#include <include/zephyr/drivers/pinctrl.h>

Obtain a reference to the pin control configuration given current compatible instance number.

Parameters
instInstance number.
See also
PINCTRL_DT_DEV_CONFIG_GET

◆ PINCTRL_REG_NONE

#define PINCTRL_REG_NONE   0U

#include <include/zephyr/drivers/pinctrl.h>

Utility macro to indicate no register is used.

◆ PINCTRL_STATE_DEFAULT

#define PINCTRL_STATE_DEFAULT   0U

#include <include/zephyr/drivers/pinctrl.h>

Default state (state used when the device is in operational state).

◆ PINCTRL_STATE_PRIV_START

#define PINCTRL_STATE_PRIV_START   2U

#include <include/zephyr/drivers/pinctrl.h>

This and higher values refer to custom private states.

◆ PINCTRL_STATE_SLEEP

#define PINCTRL_STATE_SLEEP   1U

#include <include/zephyr/drivers/pinctrl.h>

Sleep state (state used when the device is in low power mode).

Function Documentation

◆ pinctrl_apply_state()

static int pinctrl_apply_state ( const struct pinctrl_dev_config config,
uint8_t  id 
)
inlinestatic

#include <include/zephyr/drivers/pinctrl.h>

Apply a state from the given device configuration.

Parameters
configPin control configuration.
idId of the state to be applied (see PINCTRL_STATES).
Return values
0If succeeded.
-ENOENTIf given state id does not exist.
-errnoNegative errno for other failures.

◆ pinctrl_apply_state_direct()

static int pinctrl_apply_state_direct ( const struct pinctrl_dev_config config,
const struct pinctrl_state state 
)
inlinestatic

#include <include/zephyr/drivers/pinctrl.h>

Apply a state directly from the provided state configuration.

Parameters
configPin control configuration.
stateState.
Return values
0If succeeded
-errnoNegative errno for other failures.

◆ pinctrl_configure_pins()

int pinctrl_configure_pins ( const pinctrl_soc_pin_t pins,
uint8_t  pin_cnt,
uintptr_t  reg 
)

#include <include/zephyr/drivers/pinctrl.h>

Configure a set of pins.

This function will configure the necessary hardware blocks to make the configuration immediately effective.

Warning
This function must never be used to configure pins used by an instantiated device driver.
Parameters
pinsList of pins to be configured.
pin_cntNumber of pins.
regDevice register (optional, use PINCTRL_REG_NONE if not used).
Return values
0If succeeded
-errnoNegative errno for other failures.

◆ pinctrl_lookup_state()

int pinctrl_lookup_state ( const struct pinctrl_dev_config config,
uint8_t  id,
const struct pinctrl_state **  state 
)

#include <include/zephyr/drivers/pinctrl.h>

Find the state configuration for the given state id.

Parameters
configPin controller configuration.
idPin controller state id (see PINCTRL_STATES).
stateFound state.
Return values
0If state has been found.
-ENOENTIf the state has not been found.