Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
pio_rpi_pico.h File Reference
#include <zephyr/devicetree/gpio.h>
#include <hardware/pio.h>

Go to the source code of this file.

Macros

#define RPI_PICO_PIO_DEFINE_PROGRAM(name, wrap_target, wrap, ...)
 Utility macro to define a PIO program.
 
#define RPI_PICO_PIO_GET_WRAP_TARGET(name)   name ## _wrap_target
 Utility macro to get the wrap target of a program.
 
#define RPI_PICO_PIO_GET_WRAP(name)   name ## _wrap
 Utility macro to get the wrap source of a program.
 
#define RPI_PICO_PIO_GET_PROGRAM(name)   &name ## _program
 Utility macro to get a pointer to a PIO program.
 
#define DT_RPI_PICO_PIO_PIN_BY_NAME(node_id, p_name, p_idx, g_name, g_idx)
 Get a pin number from a pinctrl / group name and index.
 
#define DT_INST_RPI_PICO_PIO_PIN_BY_NAME(inst, p_name, p_idx, g_name, g_idx)    DT_RPI_PICO_PIO_PIN_BY_NAME(DT_DRV_INST(inst), p_name, p_idx, g_name, g_idx)
 Get a pin number from a pinctrl / group name and index.
 
#define DT_INST_PIO_PIN_BY_NAME(inst, name)    DT_PIO_PIN_BY_NAME(DT_DRV_INST(inst), name)
 Get the pin number of a pin by its name.
 

Functions

PIO pio_rpi_pico_get_pio (const struct device *dev)
 Get PIO object.
 
int pio_rpi_pico_allocate_sm (const struct device *dev, size_t *sm)
 Allocate a state machine.
 

Macro Definition Documentation

◆ DT_INST_PIO_PIN_BY_NAME

#define DT_INST_PIO_PIN_BY_NAME (   inst,
  name 
)     DT_PIO_PIN_BY_NAME(DT_DRV_INST(inst), name)

Get the pin number of a pin by its name.

Parameters
instinstance number
namename of the pin (e.g. tx, rx, sck).

◆ DT_INST_RPI_PICO_PIO_PIN_BY_NAME

#define DT_INST_RPI_PICO_PIO_PIN_BY_NAME (   inst,
  p_name,
  p_idx,
  g_name,
  g_idx 
)     DT_RPI_PICO_PIO_PIN_BY_NAME(DT_DRV_INST(inst), p_name, p_idx, g_name, g_idx)

Get a pin number from a pinctrl / group name and index.

Parameters
instinstance number
p_namepinctrl name
p_idxpinctrl index
g_namegroup name
g_idxgroup index
Returns
pin number
See also
DT_RPI_PICO_PIO_PIN_BY_NAME

◆ DT_RPI_PICO_PIO_PIN_BY_NAME

#define DT_RPI_PICO_PIO_PIN_BY_NAME (   node_id,
  p_name,
  p_idx,
  g_name,
  g_idx 
)
Value:
RP2_GET_PIN_NUM(DT_PROP_BY_IDX( \
DT_CHILD(DT_PINCTRL_BY_NAME(node_id, p_name, p_idx), g_name), pinmux, g_idx))
#define DT_CHILD(node_id, child)
Get a node identifier for a child node.
Definition devicetree.h:423
#define DT_PROP_BY_IDX(node_id, prop, idx)
Get the value at index idx in an array type property.
Definition devicetree.h:809
#define DT_PINCTRL_BY_NAME(node_id, name, idx)
Get a node identifier for a phandle inside a pinctrl node by name.
Definition pinctrl.h:81

Get a pin number from a pinctrl / group name and index.

Example devicetree fragment(s):

pinctrl {
pio_child_default: pio_child_default {
tx_gpio {
pinmux = <PIO0_P0>, <PIO0_P2>;
};
rx_gpio {
pinmux = <PIO0_P1>;
input-enable;
};
};
};
pio {
status = "okay";
c: child {
pinctrl-0 = <&pio_child_default>;
pinctrl-names = "default";
};
};

Example usage:

DT_RPI_PICO_PIO_PIN_BY_NAME(node, default, 0, tx_gpio, 0) // 0
DT_RPI_PICO_PIO_PIN_BY_NAME(node, default, 0, tx_gpio, 1) // 2
DT_RPI_PICO_PIO_PIN_BY_NAME(node, default, 0, rx_gpio, 0) // 1
#define DT_RPI_PICO_PIO_PIN_BY_NAME(node_id, p_name, p_idx, g_name, g_idx)
Get a pin number from a pinctrl / group name and index.
Definition pio_rpi_pico.h:103
Parameters
node_idnode identifier
p_namepinctrl name
p_idxpinctrl index
g_namegroup name
g_idxgroup index
Returns
pin number

◆ RPI_PICO_PIO_DEFINE_PROGRAM

#define RPI_PICO_PIO_DEFINE_PROGRAM (   name,
  wrap_target,
  wrap,
  ... 
)
Value:
static const uint32_t name ## _wrap_target = wrap_target; \
static const uint32_t name ## _wrap = wrap; \
static const uint16_t name ## _program_instructions[] = { \
__VA_ARGS__ \
}; \
static const struct pio_program name ## _program = { \
.instructions = name ## _program_instructions, \
.length = ARRAY_SIZE(name ## _program_instructions), \
.origin = -1, \
}
#define ARRAY_SIZE(array)
Number of elements in the given array.
Definition util.h:127
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89

Utility macro to define a PIO program.

The program is a list of 16 bit instructions, generated by the pioasm tool.

Parameters
nameName of the program.
wrap_targetWrap target as specified by the PIO program.
wrapWrap source as specified by the PIO program.
...Comma separated list of PIO instructions.

◆ RPI_PICO_PIO_GET_PROGRAM

#define RPI_PICO_PIO_GET_PROGRAM (   name)    &name ## _program

Utility macro to get a pointer to a PIO program.

Parameters
nameName of the program.

◆ RPI_PICO_PIO_GET_WRAP

#define RPI_PICO_PIO_GET_WRAP (   name)    name ## _wrap

Utility macro to get the wrap source of a program.

Parameters
nameName of the program.

◆ RPI_PICO_PIO_GET_WRAP_TARGET

#define RPI_PICO_PIO_GET_WRAP_TARGET (   name)    name ## _wrap_target

Utility macro to get the wrap target of a program.

Parameters
nameName of the program.

Function Documentation

◆ pio_rpi_pico_allocate_sm()

int pio_rpi_pico_allocate_sm ( const struct device dev,
size_t sm 
)

Allocate a state machine.

Parameters
devPointer to device structure for rpi_pio device instance
smPointer to store allocated state machine
Return values
0on success
-EBUSYif no state machines were available

◆ pio_rpi_pico_get_pio()

PIO pio_rpi_pico_get_pio ( const struct device dev)

Get PIO object.

Parameters
devPointer to device structure for rpi_pio device instance
Returns
PIO object