ADC Controller Device Interface Functions More...
Go to the source code of this file.
Data Structures | |
struct | dif_adc_ctrl_config |
Runtime configuration for an ADC Controller. More... | |
struct | dif_adc_ctrl_filter_config |
Runtime configuration for an ADC Controller filter. More... | |
Macros | |
#define | DIF_ADC_CTRL_CHANNEL_LIST(X) |
Helper X macro for defining enums and case statements related to ADC Controller channels. More... | |
#define | DIF_ADC_CTRL_FILTER_LIST(X) |
Helper X macro for defining enums and case statements related to ADC Controller filters. More... | |
#define | DIF_ADC_CTRL_CHANNEL_ENUM_INIT_(channel_) kDifAdcCtrlChannel##channel_ = channel_, |
Helper macro for defining a dif_adc_ctrl_channel_t enumeration constant. More... | |
#define | DIF_ADC_CTRL_FILTER_ENUM_INIT_(filter_) kDifAdcCtrlFilter##filter_ = filter_, |
Helper macro for defining a dif_adc_ctrl_filter_t enumeration constant. More... | |
#define | DIF_ADC_CTRL_IRQ_CAUSE_ENUM_INIT_(filter_cause_) kDifAdcCtrlIrqCauseFilter##filter_cause_ = 1U << filter_cause_, |
Helper macro for defining a dif_adc_ctrl_irq_cause_t enumeration constant. More... | |
Typedefs | |
typedef enum dif_adc_ctrl_channel | dif_adc_ctrl_channel_t |
An ADC Controller Channel. | |
typedef enum dif_adc_ctrl_filter | dif_adc_ctrl_filter_t |
An ADC Controller filter. More... | |
typedef enum dif_adc_ctrl_irq_cause | dif_adc_ctrl_irq_cause_t |
An ADC Controller IRQ cause. More... | |
typedef enum dif_adc_ctrl_mode | dif_adc_ctrl_mode_t |
Operation mode of the ADC Controller. | |
typedef struct dif_adc_ctrl_config | dif_adc_ctrl_config_t |
Runtime configuration for an ADC Controller. | |
typedef struct dif_adc_ctrl_filter_config | dif_adc_ctrl_filter_config_t |
Runtime configuration for an ADC Controller filter. | |
Enumerations | |
enum | dif_adc_ctrl_channel |
An ADC Controller Channel. | |
enum | dif_adc_ctrl_filter { kDifAdcCtrlTrans } |
An ADC Controller filter. More... | |
enum | dif_adc_ctrl_irq_cause { kDifAdcCtrlIrqCauseTrans = 1U << ADC_CTRL_ADC_INTR_STATUS_TRANS_BIT , kDifAdcCtrlIrqCauseOneshot = 1U << ADC_CTRL_ADC_INTR_STATUS_ONESHOT_BIT , kDifAdcCtrlIrqCauseAll } |
An ADC Controller IRQ cause. More... | |
enum | dif_adc_ctrl_mode { kDifAdcCtrlLowPowerScanMode = 0 , kDifAdcCtrlNormalPowerScanMode = 1 , kDifAdcCtrlOneshotMode = 2 } |
Operation mode of the ADC Controller. More... | |
ADC Controller Device Interface Functions
Definition in file dif_adc_ctrl.h.
struct dif_adc_ctrl_config |
Runtime configuration for an ADC Controller.
Definition at line 162 of file dif_adc_ctrl.h.
Data Fields | ||
---|---|---|
dif_adc_ctrl_mode_t | mode | The sampling mode to configure the ADC Controller in. |
uint8_t | num_low_power_samples |
The number of filter-matching samples to count in Low Power Scan mode before switching to Normal Power Scan mode. Only relevant in Low Power Scan mode. |
uint16_t | num_normal_power_samples | The number of filter-matching samples to count in Normal Power Scan mode before triggering a system wakeup and/or interrupt. |
uint8_t | power_up_time_aon_cycles |
The time to allow the ADC to power up. Units: always-on clock cycles |
uint32_t | wake_up_time_aon_cycles |
The sampling period when in Low Power Scan mode, i.e., how often the ADC Controller wakes up the ADC to take a sample. Units: always-on clock cycles Only relevant in Low Power Scan mode. |
struct dif_adc_ctrl_filter_config |
Runtime configuration for an ADC Controller filter.
Definition at line 199 of file dif_adc_ctrl.h.
Data Fields | ||
---|---|---|
dif_adc_ctrl_filter_t | filter | The ADC Controller filter this configuration applies to. |
bool | generate_irq_on_match |
Whether to generate a debug_cable interrupt on a filter match after saturating the num_normal_power_samples threshold in Normal Power Scan mode. |
bool | generate_wakeup_on_match |
Whether to generate a system wakeup on a filter match after saturating the num_normal_power_samples threshold in Normal Power Scan mode. |
bool | in_range | Where a filter hit is classfied as an (inclusive) in-range hit, or (exclusive) out-of-range hit. |
uint16_t | max_voltage |
The maximum voltage (inclusive) of the range defined by this filter. Valid range: [0, 1024) Units: 2.148 mV (i.e., range / 2 ^ 10) |
uint16_t | min_voltage |
The minimum voltage (inclusive) of the range defined by this filter. Valid range: [0, 1024) Units: 2.148 mV (i.e., range / 2 ^ 10) |
#define DIF_ADC_CTRL_CHANNEL_ENUM_INIT_ | ( | channel_ | ) | kDifAdcCtrlChannel##channel_ = channel_, |
Helper macro for defining a dif_adc_ctrl_channel_t
enumeration constant.
@channel_ ADC Controller channel of the enumeration constant.
Definition at line 49 of file dif_adc_ctrl.h.
#define DIF_ADC_CTRL_CHANNEL_LIST | ( | X | ) |
Helper X macro for defining enums and case statements related to ADC Controller channels.
If an additional channel is ever added to the hardware, this list can be updated.
Definition at line 26 of file dif_adc_ctrl.h.
#define DIF_ADC_CTRL_FILTER_ENUM_INIT_ | ( | filter_ | ) | kDifAdcCtrlFilter##filter_ = filter_, |
Helper macro for defining a dif_adc_ctrl_filter_t
enumeration constant.
@filter_ ADC Controller filter of the enumeration constant.
Definition at line 65 of file dif_adc_ctrl.h.
#define DIF_ADC_CTRL_FILTER_LIST | ( | X | ) |
Helper X macro for defining enums and case statements related to ADC Controller filters.
If an additional filter is ever added to the hardware, this list can be updated.
Definition at line 35 of file dif_adc_ctrl.h.
#define DIF_ADC_CTRL_IRQ_CAUSE_ENUM_INIT_ | ( | filter_cause_ | ) | kDifAdcCtrlIrqCauseFilter##filter_cause_ = 1U << filter_cause_, |
Helper macro for defining a dif_adc_ctrl_irq_cause_t
enumeration constant.
@filter_cause_ ADC Controller IRQ filter cause of the enumeration constant.
Definition at line 87 of file dif_adc_ctrl.h.
typedef enum dif_adc_ctrl_filter dif_adc_ctrl_filter_t |
An ADC Controller filter.
Each channel has a separate instance of each filter. For example, if there are two channels and eight filters, there would be a total of 16 filter instances that may be configured.
typedef enum dif_adc_ctrl_irq_cause dif_adc_ctrl_irq_cause_t |
An ADC Controller IRQ cause.
The ADC Controller can only generate a single interrupt (the debug_cable
interrupt). However, depending on how the ADC Controller is configured, there are several causes that could trigger this interrupt. These include filter matches (when in Normal Power Scan mode), or sample completion (when in Oneshot mode).
enum dif_adc_ctrl_filter |
An ADC Controller filter.
Each channel has a separate instance of each filter. For example, if there are two channels and eight filters, there would be a total of 16 filter instances that may be configured.
Definition at line 75 of file dif_adc_ctrl.h.
An ADC Controller IRQ cause.
The ADC Controller can only generate a single interrupt (the debug_cable
interrupt). However, depending on how the ADC Controller is configured, there are several causes that could trigger this interrupt. These include filter matches (when in Normal Power Scan mode), or sample completion (when in Oneshot mode).
Definition at line 99 of file dif_adc_ctrl.h.
enum dif_adc_ctrl_mode |
Operation mode of the ADC Controller.
Definition at line 124 of file dif_adc_ctrl.h.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_configure | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_config_t | config | ||
) |
Configures an ADC Controller.
adc_ctrl | An adc_ctrl handle. |
config | Runtime configuration parameters. |
Definition at line 29 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_configure_filter | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_channel_t | channel, | ||
dif_adc_ctrl_filter_config_t | config, | ||
dif_toggle_t | enabled | ||
) |
Configures a channel filter.
This should be invoked for each desired filter before the sampling sequence is enabled via dif_adc_ctrl_set_enabled()
.
This only applies in Low / Normal Power Scan sampling modes.
adc_ctrl | An adc_ctrl handle. |
channel | The channel of the filter to configure. |
config | Runtime configuration parameters for the filter. |
enabled | The enablement state to configure the filter in. |
Definition at line 86 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_filter_get_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_channel_t | channel, | ||
dif_adc_ctrl_filter_t | filter, | ||
dif_toggle_t * | enabled | ||
) |
Gets the enablement state of the specified filter for the specified channel.
adc_ctrl | An adc_ctrl handle. | |
channel | The channel the filter resides in. | |
filter | The filter to get the enablement state of. | |
[out] | is_enabled | The enablement state of the filter. |
Definition at line 316 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_filter_match_wakeup_get_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_filter_t | filter, | ||
dif_toggle_t * | is_enabled | ||
) |
Gets the enablement of generating system wakeups on a filter match.
adc_ctrl | An adc_ctrl handle. | |
filter | A filter to enable wakeup triggering for. | |
[out] | is_enabled | The enablement state retrieved. |
Definition at line 469 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_filter_match_wakeup_set_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_filter_t | filter, | ||
dif_toggle_t | enabled | ||
) |
Sets the enablement of generating system wakeups on a filter match.
Only relevant in Normal Power Scan mode (and Low Power Scan mode, which can transition to Normal Power Scan mode).
adc_ctrl | An adc_ctrl handle. |
filter | A filter to enable wakeup triggering for. |
enabled | The enablement state to set. |
Definition at line 451 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_filter_set_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_channel_t | channel, | ||
dif_adc_ctrl_filter_t | filter, | ||
dif_toggle_t | enabled | ||
) |
Sets the enablement state of the specified filter for the specified channel.
adc_ctrl | An adc_ctrl handle. |
channel | The channel the filter resides in. |
filter | The filter to set the enablement state of. |
enabled | The enablement state to configure the filter in. |
Definition at line 289 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_get_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_toggle_t * | is_enabled | ||
) |
Gets the enablement state of the ADC Controller.
If the ADC Controller is enabled, it is powered up, or being powered up.
adc_ctrl | An adc_ctrl handle. | |
[out] | is_enabled | The enablement state of the ADC Controller. |
Definition at line 197 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_get_filter_status | ( | const dif_adc_ctrl_t * | adc_ctrl, |
uint32_t * | status | ||
) |
Gets the filter status.
adc_ctrl | An adc_ctrl handle. | |
[out] | status | The current filter status. |
Definition at line 422 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_get_latest_value | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_channel_t | channel, | ||
uint16_t * | value | ||
) |
Get the latest sampled value from the specified channel.
Since in Normal Power Scan mode, sampling continues even after an IRQ has been raised, the value returned by this function may be different than the value returned by dif_adc_ctrl_get_irq_value()
.
Values are 10-bits in the range from 0V to 2.2V. Based on this, the resolution (and units) of the sample are in increments of 2.148mV.
adc_ctrl | An adc_ctrl handle. | |
channel | The channel to read the sample from. | |
[out] | value | The value of the sample. |
Definition at line 370 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_get_triggered_value | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_adc_ctrl_channel_t | channel, | ||
uint16_t * | value | ||
) |
Get the sampled value from the specified channel that triggered the IRQ.
Values are 10-bits in the range from 0V to 2.2V. Based on this, the resolution (and units) of the sample are in increments of 2.148mV.
adc_ctrl | An adc_ctrl handle. | |
channel | The channel to read the sample from. | |
[out] | value | The value of the sample. |
Definition at line 341 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_irq_cause_get_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
uint32_t * | enabled_causes | ||
) |
Gets the causes that will generate a debug_cable
IRQ.
adc_ctrl | An adc_ctrl handle. | |
[out] | enabled_causes | Causes (one or more dif_adc_ctrl_irq_cause_t s ORed together) that will generate the debug_cable IRQ. |
Definition at line 506 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_irq_cause_set_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
uint32_t | causes, | ||
dif_toggle_t | enabled | ||
) |
Sets the enablement of generating a debug_cable
IRQ for given cause(s).
Causes can be filter matches (in Normal Power Scan mode), or when a sample is complete (in Oneshot mode).
adc_ctrl | An adc_ctrl handle. |
causes | Causes (one or more dif_adc_ctrl_irq_cause_t s ORed together) to generate the debug_cable IRQ for. |
enabled | The enablement state to set. |
Definition at line 485 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_irq_clear_causes | ( | const dif_adc_ctrl_t * | adc_ctrl, |
uint32_t | causes | ||
) |
Clears the cause(s) of a debug_cable
IRQ.
TODO(lowRISC/opentitan:#11354): future releases of the HW should hide the filter and interrupt status registers behind the standardized IRQ registers. For now, the autogenerated dif_adc_ctrl_irq_acknowledge[_all]()
DIF may be used to clear the main IRQ status register, while this DIF may be used to clear the local cause / filter status registers.
adc_ctrl | An adc_ctrl handle. |
causes | The causes of the IRQ (one or more dif_adc_ctrl_irq_cause_t s ORed together). |
Definition at line 433 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_irq_get_causes | ( | const dif_adc_ctrl_t * | adc_ctrl, |
uint32_t * | causes | ||
) |
Gets the cause(s) of a debug_cable
IRQ.
IRQs can be triggered by filter matches in Normal Power Scan mode (after saturating the num_normal_power_samples
threshold), or after a single sample capture in Oneshot mode.
adc_ctrl | An adc_ctrl handle. | |
[out] | causes | The causes of the IRQ (one or more dif_adc_ctrl_irq_cause_t s ORed together). |
Definition at line 410 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_reset | ( | const dif_adc_ctrl_t * | adc_ctrl | ) |
Reset all ADC Controller FSMs and counters, and if enabled, begin sampling sequence.
adc_ctrl | An adc_ctrl handle. |
Definition at line 399 of file dif_adc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_adc_ctrl_set_enabled | ( | const dif_adc_ctrl_t * | adc_ctrl, |
dif_toggle_t | enabled | ||
) |
Sets the enablement state of the ADC Controller.
Enabling the ADC Controller powers it up, while disabling the ADC Controller powers it down and resets the sampling FSM. After powering up, sampling begins, regardless of the operation mode.
adc_ctrl | An adc_ctrl handle. |
enabled | The enablement state to configure the ADC Controller in. |
Definition at line 180 of file dif_adc_ctrl.c.
dif_result_t dif_adc_ctrl_wait_cdc_sync | ( | const dif_adc_ctrl_t * | adc_ctrl, |
uint32_t | aon_freq_hz | ||
) |
Wait enough time for CDC synchronization between block and CSRs.
Wait long enough for any CDC synchronization between the AON part of the block and the CSRs to be complete. This is particularly important for the FILTER_STATUS register: this register can be updated by the HW and any update may take a while to become visible by the SW.
adc_ctrl | An adc_ctrl handle. |
aon_freq_hz | Frequency of the AON clock in Hz. |
Definition at line 518 of file dif_adc_ctrl.c.