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

General Description

Functions

uint8_t SelfTest_Clock (TCPWM_Type *base, uint32_t cntNum)
 Performs Clock test and verifies if the measured clock frequency is in the accuracy range.
void SelfTest_Clock_ISR_TIMER (void)
 Handle Interrupt Service Routine.
void SelfTest_Clock_CSV_ISR (void)
 Summary: ISR handler for SelfTest_Clock_CSV.
uint8_t SelfTest_Clock_CSV (const stl_clock_csv_entry_t *entry)
 Summary: Runs the CSV functional self-test for the selected CLK_HF instance: triggers induced CSV fault by setting impossible supervision window, waits for the induced fault to propagate and register by SelfTest_Clock_CSV_ISR.

Function Documentation

◆ SelfTest_Clock()

uint8_t SelfTest_Clock ( TCPWM_Type * base,
uint32_t cntNum )

Performs Clock test and verifies if the measured clock frequency is in the accuracy range.

Parameters
baseThe pointer to a TCPWM instance
cntNumThe Counter instance number in the selected TCPWM
Note
Use a TCPWM counter dedicated to the clock self-test. The test programs the selected counter period/counter value and depends on SelfTest_Clock_ISR_TIMER being installed for the counter terminal-count interrupt.
Returns
ERROR_STATUS (1) - Test failed
PASS_STILL_TESTING_STATUS (2) - Still testing
PASS_COMPLETE_STATUS (3) - Test completed
ERROR_INCORRECT_USAGE_STATUS (4) - Incorrect usage

◆ SelfTest_Clock_ISR_TIMER()

void SelfTest_Clock_ISR_TIMER ( void )

Handle Interrupt Service Routine.

Source - Timer.

◆ SelfTest_Clock_CSV_ISR()

void SelfTest_Clock_CSV_ISR ( void )

Summary: ISR handler for SelfTest_Clock_CSV.

The application routes the fault-struct interrupt to this handler with Cy_SysInt_Init and enables the mux line before calling SelfTest_Clock_CSV.

The NVIC mux line is disabled by this function so the ISR doesn't re-enter while the impossible CSV window is still armed. SelfTest_Clock_CSV clears the interrupt mask and any residual pending edge during teardown.

◆ SelfTest_Clock_CSV()

uint8_t SelfTest_Clock_CSV ( const stl_clock_csv_entry_t * entry)

Summary: Runs the CSV functional self-test for the selected CLK_HF instance: triggers induced CSV fault by setting impossible supervision window, waits for the induced fault to propagate and register by SelfTest_Clock_CSV_ISR.

Parameters
entryPointer to stl_clock_csv_entry_t describing the CLK_HF under test, the app-provided fault structure, and the NVIC mux the fault-struct interrupt is routed to.
Returns
OK_STATUS - CSV self test pass ERROR_STATUS - Induced CSV fault was not observed within CSV_TEST_TIMEOUT_US poll iterations, or SelfTest_Clock_CSV_ISR recorded a fault source other than CY_SYSFAULT_SRSS_CSV. ERROR_BAD_PARAM - entry is NULL, clkHf is 0, faultStruct is NULL, the refClk frequency is 0 (e.g. ECO/EXT not configured), or Cy_SysClk_ClkHfCsvManualConfigure() rejected the configuration.
Note
Before calling this function the application MUST:
  1. Enable global interrupts (e.g. __enable_irq()). The self-test checks induced CSV fault using SelfTest_Clock_CSV_ISR interrupt handler.
  2. Route the fault-struct interrupt (e.g. cpuss_interrupts_fault_N_IRQn) to SelfTest_Clock_CSV_ISR using Cy_SysInt_Init with NVIC_ClearPendingIRQ and NVIC_EnableIRQ on stl_clock_csv_entry_t::nvicMux.
  3. Provide a valid stl_clock_csv_entry_t::faultStruct.
Side effects on entry:
  • The function reinitializes the provided fault structure, sets the CY_SYSFAULT_SRSS_CSV mask, and clears STATUS/INTR. Any prior application configuration of that fault structure is overwritten.
  • The CSV comparator on stl_clock_csv_entry_t::clkHf is disabled and temporarily reprogrammed with an impossible supervision window to force an immediate fault. Any previously programmed operational CSV window for specified CLK_HF is overwritten.
Side effects on exit:
  • CSV on stl_clock_csv_entry_t::clkHf is left disabled — the app must call Cy_SysClk_ClkHfCsvConfigure() and Cy_SysClk_ClkHfCsvEnable() with its expected accuracy window.
  • The fault-struct interrupt mask is cleared. On OK_STATUS the NVIC mux is also disabled (by SelfTest_Clock_CSV_ISR), otherwise it is left as the app configured it. The app must setup its own interrupt handler to handle operational CSV faults.
  • After the app re-arms its expected accuracy window, enabling CSV can latch STATUS.VALID while the CSV state machine settles. Clear STATUS (loop until Cy_SysFault_GetErrorSource() returns CY_SYSFAULT_NO_FAULT) and clear INTR before enabling the fault-struct interrupt mask and the NVIC mux to avoid false faults.
This function is intended to be called ONCE at startup, before operational CSV supervision is armed.
This function is blocking (polls up to CSV_TEST_TIMEOUT_US microseconds) and is not reentrant.