ModusToolbox Safety Test Library
Loading...
Searching...
No Matches

General Description

Functions

uint8_t SelfTest_ADC_Config_Save (PASS_SAR_Type *base, const stl_adc_config_mask_t *userMask, stl_adc_config_snapshot_t *snapshot)
 Captures a CRC-protected snapshot of one SAR2 ADC instance's configuration registers, applying the driver-known-fixed masks and the caller-provided userMask before storing each value.
uint8_t SelfTest_ADC_MMIO_Config_Save (PASS_EPASS_MMIO_Type *mmioBase, const stl_adc_mmio_config_mask_t *userMask, stl_adc_mmio_config_snapshot_t *snapshot)
 Captures a CRC-protected snapshot of the PASS-level registers shared by every SAR2 ADC instance, applying the driver-known-fixed mask and the caller-provided userMask before storing each value.
uint8_t SelfTest_ADC_Config_Verify (PASS_SAR_Type *base, const stl_adc_config_snapshot_t *snapshot)
 Verifies the live SAR2 ADC configuration registers against a snapshot previously captured by SelfTest_ADC_Config_Save.
uint8_t SelfTest_ADC_MMIO_Config_Verify (PASS_EPASS_MMIO_Type *mmioBase, const stl_adc_mmio_config_snapshot_t *snapshot)
 Verifies the live shared PASS-level registers against a snapshot previously captured by SelfTest_ADC_MMIO_Config_Save.

Function Documentation

◆ SelfTest_ADC_Config_Save()

uint8_t SelfTest_ADC_Config_Save ( PASS_SAR_Type * base,
const stl_adc_config_mask_t * userMask,
stl_adc_config_snapshot_t * snapshot )

Captures a CRC-protected snapshot of one SAR2 ADC instance's configuration registers, applying the driver-known-fixed masks and the caller-provided userMask before storing each value.

Shared PASS-level registers are captured separately by SelfTest_ADC_MMIO_Config_Save.

Any channel index with its bit set in userMask->channelSkipMask is zero-filled in the snapshot and excluded from SelfTest_ADC_Config_Verify.

Call this once after the ADC is fully configured (Cy_SAR2_Init and any subsequent Cy_SAR2_Channel_Init, Cy_SAR2_Diag_Init, or calibration setter calls), before entering the periodic self-test schedule. Because CTL.ENABLED and CH.ENABLE.CHAN_EN are masked, calling it before or after Cy_SAR2_Enable gives the same result.

Parameters
baseThe pointer to the SAR ADC instance whose registers are captured.
userMaskApplication-provided mask describing fields to exclude from future comparisons. Must not be NULL - pass an all-zero stl_adc_config_mask_t to compare every field in every channel.
snapshotDestination for the captured, CRC-protected snapshot. Stored snapshot used for later SelfTest_ADC_Config_Verify calls.
Returns
OK_STATUS (0) - Snapshot captured.
ERROR_BAD_PARAM (9) - base, userMask, or snapshot is NULL.

◆ SelfTest_ADC_MMIO_Config_Save()

uint8_t SelfTest_ADC_MMIO_Config_Save ( PASS_EPASS_MMIO_Type * mmioBase,
const stl_adc_mmio_config_mask_t * userMask,
stl_adc_mmio_config_snapshot_t * snapshot )

Captures a CRC-protected snapshot of the PASS-level registers shared by every SAR2 ADC instance, applying the driver-known-fixed mask and the caller-provided userMask before storing each value.

Call this once for the whole PASS block after initialization (including any Cy_SAR2_SetGenericTriggerInput, Cy_SAR2_SetGenericTriggerOutput, or Cy_SAR2_SetReferenceBufferMode calls), alongside SelfTest_ADC_Config_Save.

Parameters
mmioBaseThe pointer to the shared PASS top-level MMIO block (PASS0->EPASS_MMIO).
userMaskApplication-provided mask describing fields to exclude from future comparisons. Must not be NULL - pass an all-zero stl_adc_mmio_config_mask_t to compare every field.
snapshotDestination for the captured, CRC-protected snapshot. Stored snapshot used for later SelfTest_ADC_MMIO_Config_Verify calls.
Returns
OK_STATUS (0) - Snapshot captured.
ERROR_BAD_PARAM (9) - mmioBase, userMask, or snapshot is NULL.

◆ SelfTest_ADC_Config_Verify()

uint8_t SelfTest_ADC_Config_Verify ( PASS_SAR_Type * base,
const stl_adc_config_snapshot_t * snapshot )

Verifies the live SAR2 ADC configuration registers against a snapshot previously captured by SelfTest_ADC_Config_Save.

The snapshot's own CRC is checked first, a CRC mismatch returns ERROR_ADC_CONFIG_SNAPSHOT_INVALID without comparing any register. If the CRC matches, the live registers are read, masked with the driver-known-fixed masks and the snapshot's stored userMask, and then compared. Channels excluded by userMask.channelSkipMask are not compared.

Parameters
baseThe pointer to the SAR ADC instance to verify. Must be the same instance passed to SelfTest_ADC_Config_Save when snapshot was captured.
snapshotThe snapshot captured by SelfTest_ADC_Config_Save.
Returns
OK_STATUS (0) - Live configuration matches the snapshot.
ERROR_STATUS (1) - A masked comparison mismatch was found; the ADC configuration was unexpectedly changed or corrupted.
ERROR_ADC_CONFIG_SNAPSHOT_INVALID (7) - The snapshot failed its own CRC check.
ERROR_BAD_PARAM (9) - base or snapshot is NULL.

◆ SelfTest_ADC_MMIO_Config_Verify()

uint8_t SelfTest_ADC_MMIO_Config_Verify ( PASS_EPASS_MMIO_Type * mmioBase,
const stl_adc_mmio_config_snapshot_t * snapshot )

Verifies the live shared PASS-level registers against a snapshot previously captured by SelfTest_ADC_MMIO_Config_Save.

The snapshot's own CRC is checked first; a CRC mismatch returns ERROR_ADC_CONFIG_SNAPSHOT_INVALID without comparing any register. If the CRC matches, the live registers are read, masked with the driver-known-fixed mask and the snapshot's stored userMask, and then compared.

Parameters
mmioBaseThe pointer to the shared PASS top-level MMIO block (PASS0->EPASS_MMIO).
snapshotThe snapshot captured by SelfTest_ADC_MMIO_Config_Save.
Returns
OK_STATUS (0) - Live configuration matches the snapshot.
ERROR_STATUS (1) - A masked comparison mismatch was found; the shared PASS configuration was unexpectedly changed or corrupted.
ERROR_ADC_CONFIG_SNAPSHOT_INVALID (7) - The snapshot failed its own CRC check.
ERROR_BAD_PARAM (9) - mmioBase or snapshot is NULL.