Pin Multiplexer Device Interface Functions More...
#include <stdbool.h>
#include <stdint.h>
#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
#include "sw/device/lib/dif/dif_base.h"
#include "sw/device/lib/dif/autogen/dif_pinmux_autogen.h"
Go to the source code of this file.
Data Structures | |
struct | dif_pinmux_pad_attr |
Pin multiplexer padring pad attributes. More... | |
struct | dif_pinmux_wakeup_config |
A Pin Multiplexer common wake-up configuration between different modes. More... | |
Typedefs | |
typedef enum dif_pinmux_pad_kind | dif_pinmux_pad_kind_t |
Pin Multiplexer connects peripheral input/output signals to the Padring MIO pad input/output signals. More... | |
typedef enum dif_pinmux_lock_target | dif_pinmux_lock_target_t |
Pin Multiplexer functionality locking. More... | |
typedef uint32_t | dif_pinmux_index_t |
Pin Multiplexer generic index. More... | |
typedef uint8_t | dif_pinmux_pad_slew_rate_t |
Pad slew rate value. More... | |
typedef uint8_t | dif_pinmux_pad_drive_strength_t |
Pad drive strength value. More... | |
typedef enum dif_pinmux_pad_attr_flags | dif_pinmux_pad_attr_flags_t |
Pad attribute flag values. More... | |
typedef struct dif_pinmux_pad_attr | dif_pinmux_pad_attr_t |
Pin multiplexer padring pad attributes. | |
typedef enum dif_pinmux_sleep_mode | dif_pinmux_sleep_mode_t |
A sleep mode for a Padring DIO/MIO pad. More... | |
typedef enum dif_pinmux_wakeup_mode | dif_pinmux_wakeup_mode_t |
A Pin Multiplexer wake-up detection mode (edge triggered). | |
typedef struct dif_pinmux_wakeup_config | dif_pinmux_wakeup_config_t |
A Pin Multiplexer common wake-up configuration between different modes. | |
Enumerations | |
enum | dif_pinmux_pad_kind { kDifPinmuxPadKindMio = 0, kDifPinmuxPadKindDio, kDifPinmuxPadKindCount } |
Pin Multiplexer connects peripheral input/output signals to the Padring MIO pad input/output signals. More... | |
enum | dif_pinmux_lock_target { kDifPinmuxLockTargetInsel = 0, kDifPinmuxLockTargetOutsel, kDifPinmuxLockTargetMioSleep, kDifPinmuxLockTargetDioSleep, kDifPinmuxLockTargetMioPadAttr, kDifPinmuxLockTargetDioPadAttr, kDifPinmuxLockTargetWakeupDetector } |
Pin Multiplexer functionality locking. More... | |
enum | dif_pinmux_pad_attr_flags { kDifPinmuxPadAttrInvertLevel = 1 << 0, kDifPinmuxPadAttrVirtualOpenDrain = 1 << 1, kDifPinmuxPadAttrPullResistorEnable = 1 << 2, kDifPinmuxPadAttrPullResistorUp = 1 << 3, kDifPinmuxPadAttrKeeper = 1 << 4, kDifPinmuxPadAttrSchmittTrigger = 1 << 5, kDifPinmuxPadAttrOpenDrain = 1 << 6, kDifPinmuxPadAttrInputDisable = 1 << 7 } |
Pad attribute flag values. More... | |
enum | dif_pinmux_sleep_mode { kDifPinmuxSleepModeLow = 0, kDifPinmuxSleepModeHigh, kDifPinmuxSleepModeHighZ, kDifPinmuxSleepModeKeep, kDifPinmuxSleepModeCount } |
A sleep mode for a Padring DIO/MIO pad. More... | |
enum | dif_pinmux_wakeup_mode { kDifPinmuxWakeupModePositiveEdge = 0, kDifPinmuxWakeupModeNegativeEdge, kDifPinmuxWakeupModeAnyEdge, kDifPinmuxWakeupModeTimedHigh, kDifPinmuxWakeupModeTimedLow, kDifPinmuxWakeupModeCount } |
A Pin Multiplexer wake-up detection mode (edge triggered). More... | |
Pin Multiplexer Device Interface Functions
Definition in file dif_pinmux.h.
struct dif_pinmux_pad_attr |
Pin multiplexer padring pad attributes.
Definition at line 154 of file dif_pinmux.h.
Data Fields | ||
---|---|---|
dif_pinmux_pad_drive_strength_t | drive_strength |
Drive strength pad attribute. A greater number produces a stronger drive. |
dif_pinmux_pad_attr_flags_t | flags |
A bit map of single-bit attribute flags. See dif_pinmux_pad_attr_flags_t for the mapping and definitions. |
dif_pinmux_pad_slew_rate_t | slew_rate |
Slew rate attribute. A greater number produces a faster slew rate. |
struct dif_pinmux_wakeup_config |
A Pin Multiplexer common wake-up configuration between different modes.
Definition at line 236 of file dif_pinmux.h.
Data Fields | ||
---|---|---|
uint8_t | counter_threshold |
Counter threshold for kDifPinmuxWakeupModeTimedLow and kDifPinmuxWakeupModeTimedHigh wake-up detector modes. The threshold is in terms of always-on clock cycles. |
dif_pinmux_wakeup_mode_t | mode | Wake-up detection mode. |
dif_pinmux_index_t | pad_select |
Selects a specific pad. In the case of MIO, the pad select index is the same as used for |
dif_pinmux_pad_kind_t | pad_type | Pad type (MIO or DIO) to enable the wake-up detection for. |
dif_toggle_t | signal_filter |
Signal filter - signal must be stable for 4 always-on clock cycles before the value is being forwarded. Can be used for debouncing. |
typedef uint32_t dif_pinmux_index_t |
Pin Multiplexer generic index.
The meaning of this index changes between APIs, and must be documented in the corresponding function description.
Definition at line 103 of file dif_pinmux.h.
typedef enum dif_pinmux_lock_target dif_pinmux_lock_target_t |
Pin Multiplexer functionality locking.
Represents a target functionality to be locked for a given pad/peripheral input.
typedef enum dif_pinmux_pad_attr_flags dif_pinmux_pad_attr_flags_t |
Pad attribute flag values.
This enum
is a bitfield, meaning that it is allowed to pass combined value of multiple individual attributes.
Some attributes have defined meanings, others are implementation defined. Not all pads will support all attributes, or attribute combinations. The Pin Multiplexer DIF checks for conflicting or unsupported attributes provided by the Write-Any Read-Legal (WARL) semantics of the underlying hardware. If the combination of attributes is not supported - some/all of these attributes will still be disabled (relevant bit unset in the attribute field).
IMPORTANT:
typedef uint8_t dif_pinmux_pad_drive_strength_t |
Pad drive strength value.
This selects between available drive strength values, where the largest number produces the highest drive strength. See the device's data sheet for the particular mapping.
Definition at line 121 of file dif_pinmux.h.
typedef enum dif_pinmux_pad_kind dif_pinmux_pad_kind_t |
Pin Multiplexer connects peripheral input/output signals to the Padring MIO pad input/output signals.
Every peripheral input signal is fed into a multiplexer, where selects determine which Padring MIO pad input or constants should be connected to it.
Every Padring MIO pad output signal is fed into a multiplexer, where selects determine which peripheral output or constants should be connected to it. Pin Multiplexer Padring pad kinds.
A pad can be a Multiplexed (MIO) or Dedicated (DIO).
typedef uint8_t dif_pinmux_pad_slew_rate_t |
Pad slew rate value.
This selects between available slew rate values, where the largest number produces the fastest slew rate. See the device's data sheet for the particular mapping.
Definition at line 112 of file dif_pinmux.h.
typedef enum dif_pinmux_sleep_mode dif_pinmux_sleep_mode_t |
A sleep mode for a Padring DIO/MIO pad.
This determines the behaviour of a pad in deep sleep state.
NOTE: After the chip has come back from deep sleep, the mode of the pad persists until it is explicitly cleared by dif_pinmux_sleep_clear_state
. Calling dif_pinmux_sleep_enable
will configure the pad mode for the next deep sleep, however it will not change the current mode.
Pin Multiplexer functionality locking.
Represents a target functionality to be locked for a given pad/peripheral input.
Definition at line 63 of file dif_pinmux.h.
Pad attribute flag values.
This enum
is a bitfield, meaning that it is allowed to pass combined value of multiple individual attributes.
Some attributes have defined meanings, others are implementation defined. Not all pads will support all attributes, or attribute combinations. The Pin Multiplexer DIF checks for conflicting or unsupported attributes provided by the Write-Any Read-Legal (WARL) semantics of the underlying hardware. If the combination of attributes is not supported - some/all of these attributes will still be disabled (relevant bit unset in the attribute field).
IMPORTANT:
Definition at line 140 of file dif_pinmux.h.
enum dif_pinmux_pad_kind |
Pin Multiplexer connects peripheral input/output signals to the Padring MIO pad input/output signals.
Every peripheral input signal is fed into a multiplexer, where selects determine which Padring MIO pad input or constants should be connected to it.
Every Padring MIO pad output signal is fed into a multiplexer, where selects determine which peripheral output or constants should be connected to it. Pin Multiplexer Padring pad kinds.
A pad can be a Multiplexed (MIO) or Dedicated (DIO).
Definition at line 43 of file dif_pinmux.h.
A sleep mode for a Padring DIO/MIO pad.
This determines the behaviour of a pad in deep sleep state.
NOTE: After the chip has come back from deep sleep, the mode of the pad persists until it is explicitly cleared by dif_pinmux_sleep_clear_state
. Calling dif_pinmux_sleep_enable
will configure the pad mode for the next deep sleep, however it will not change the current mode.
Definition at line 181 of file dif_pinmux.h.
A Pin Multiplexer wake-up detection mode (edge triggered).
Definition at line 205 of file dif_pinmux.h.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_input_select | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | peripheral_input, | ||
dif_pinmux_index_t | insel | ||
) |
Sets a connection between a peripheral input and a MIO pad input.
A peripheral input can be connected to any available MIO pad input.
pinmux | A Pin Multiplexer handle. |
peripheral_input | A Peripheral input index. |
insel | Input connection select - a MIO pad input to be connected to a peripheral input. |
Definition at line 148 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_is_locked | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | index, | ||
dif_pinmux_lock_target_t | target, | ||
bool * | is_locked | ||
) |
Obtains the Pin Multiplexer Pad lock status based on target
and index
.
pinmux | A Pin Multiplexer handle. | |
index | Exact meaning is determined by the target , however, it represents one of the following: peripheral input index, MIO pad index, DIO pad index or a wakeup detector index. | |
target | Target functionality to be locked. | |
[out] | is_locked | Out-param for the locked state. |
Definition at line 129 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_lock | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | index, | ||
dif_pinmux_lock_target_t | target | ||
) |
Locks out Pin Multiplexer functionality based on the target
and index
.
This function allows for a fine grained locking of the Pin Multiplexer parts. index
changes meaning dependent on the target
. For example, when target
is kDifPinmuxLockTargetInsel
, index
represents a peripheral input for which the MIO input select functionality should be locked.
NOTE: Locking an already locked register will succeed with the kDifOk
return code.
pinmux | A Pin Multiplexer handle. |
index | Exact meaning is determined by the target , however, it represents one of the following: peripheral input index, MIO pad index, DIO pad index or a wakeup detector index. |
target | Target functionality to be locked. |
Definition at line 114 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_output_select | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | mio_pad_output, | ||
dif_pinmux_index_t | outsel | ||
) |
Sets a connection between a MIO pad output and peripheral output.
A MIO pad output can be connected to any available peripheral output.
pinmux | A Pin Multiplexer handle. |
mio_pad_output | Padring MIO output index. |
outsel | Peripheral output connection select - a Peripheral output to be connected to a MIO pad output. |
Definition at line 172 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_pad_get_attrs | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | pad, | ||
dif_pinmux_pad_kind_t | type, | ||
dif_pinmux_pad_attr_t * | attrs | ||
) |
Get attributes for a pad.
pinmux | A Pin Multiplexer handle. |
pad | Pad index to obtain the attributes for. |
type | Pad type (MIO or DIO). |
attrs[out] | Obtained attributes. |
Definition at line 319 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_pad_sleep_clear_state | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | pad, | ||
dif_pinmux_pad_kind_t | type | ||
) |
Clears deep sleep mode for a particular pad.
When deep sleep mode is enabled for a pad, and the device has entered deep sleep mode; upon wake-up, the deep sleep status of this pad can only be cleared by calling this function. Re-configuring this pad will only take effect during the next deep sleep.
pinmux | A Pin Multiplexer handle. |
pad | Pad index. |
type | Padring pad type (MIO or DIO). |
Definition at line 445 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_pad_sleep_disable | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | pad, | ||
dif_pinmux_pad_kind_t | type | ||
) |
Disables deep sleep mode of a particular pad.
NOTE: After the chip has come back from deep sleep, the mode of a pad persists until is explicitly cleared by dif_pinmux_pad_sleep_clear_state
. Calling dif_pinmux_pad_sleep_enable
will configure a pad mode for the next deep sleep, however it will not change the current mode.
pinmux | A Pin Multiplexer handle. |
pad | Pad index. |
type | Pad type (MIO or DIO). |
Definition at line 395 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_pad_sleep_enable | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | pad, | ||
dif_pinmux_pad_kind_t | type, | ||
dif_pinmux_sleep_mode_t | mode | ||
) |
Enables deep sleep mode of a particular pad.
NOTE: After the chip has come back from deep sleep, the mode of a pad persists until is explicitly cleared by dif_pinmux_pad_sleep_clear_state
. Calling dif_pinmux_pad_sleep_enable
will configure a pad mode for the next deep sleep, however it will not change the current mode.
pinmux | A Pin Multiplexer handle. |
pad | Pad index. |
type | Pad type (MIO or DIO). |
mode | Pad deep sleep mode. |
Definition at line 337 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_pad_sleep_get_state | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | pad, | ||
dif_pinmux_pad_kind_t | type, | ||
bool * | in_sleep_mode | ||
) |
Returns the state of a particular pad.
When the pad is in deep sleep mode, the mode persists until is explicitly cleared via dif_pinmux_pad_sleep_clear_state
.
padmux | A Pin Multiplexer handle. | |
pad | Pad index. | |
type | Padring pad type (MIO or DIO). | |
[out] | in_sleep_mode | Pad state, true when in deep sleep mode. |
Definition at line 426 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_pad_write_attrs | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | pad, | ||
dif_pinmux_pad_kind_t | type, | ||
dif_pinmux_pad_attr_t | attrs_in, | ||
dif_pinmux_pad_attr_t * | attrs_out | ||
) |
Writes attributes for a pad.
This function completely overwrites the existing configuration of a pad, and has both enable and disable semantics.
Not all pads implement all attributes and some combinations cannot be enabled together. This function returns a kDifBadArg
error in case of invalid attrs_in
. Not all target platforms support all attribute values and the underlying hardware registers implement Write-Any Read-Legal (WARL) semantics. For example, the maximum supported slew rate and drive strength may vary between platforms. If the specified attribute values are valid but not supported by the hardware, this function returns kDifError
and the caller needs to decide on how to resolve the situation. Unsupported or conflicting attribute values can be identified by comparing attrs_in
to attrs_out
.
IMPORTANT: See dif_pinmux_pad_attr
for information on which attributes are compulsory and which invariants are mutually exclusive.
pinmux | A Pin Multiplexer handle. |
pad | Pad index to write the attributes for. |
type | Pad type (MIO or DIO). |
attrs_in | Attribute values to write. |
attrs_out[out] | The actual attributes written and accepted by the hardware. |
Definition at line 234 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_wakeup_cause_clear | ( | const dif_pinmux_t * | pinmux | ) |
Clears the wake-up cause information.
pinmux | A Pin Multiplexer handle. |
Definition at line 577 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_wakeup_cause_get | ( | const dif_pinmux_t * | pinmux, |
uint32_t * | detector_map | ||
) |
Retrieves the detectors that have detected wake-up patterns.
pinmux | A Pin Multiplexer handle. |
detector_map[out] | A bit map representing detectors that have detected wake-up patterns. |
Definition at line 585 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_wakeup_detector_disable | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | detector | ||
) |
Disables wake-up detection for a particular detector.
pinmux | A Pin Multiplexer handle. |
detector | A detector index. |
Definition at line 553 of file dif_pinmux.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_pinmux_wakeup_detector_enable | ( | const dif_pinmux_t * | pinmux, |
dif_pinmux_index_t | detector, | ||
dif_pinmux_wakeup_config_t | config | ||
) |
Enables wake-up mode detection for a particular detector.
pinmux | A Pin Multiplexer handle. |
detector | A detector index. |
config | A wake-up detector configuration. |
Definition at line 464 of file dif_pinmux.c.