![]() |
AVR SD Safety Framework 1.0.0
|
Contains API prototypes and defines for the Clock Manager. More...
Files | |
| file | midware_clock_manager.c |
| Implements APIs for the Clock Manager. | |
| file | midware_clock_manager.h |
| Contains API prototypes and defines for the Clock Manager. | |
| file | midware_clock_manager_diag.c |
| Implements APIs for the Clock Manager Diagnostics. | |
| file | midware_clock_manager_diag.h |
| Contains API prototypes for the Clock Manager Diagnostics. | |
Data Structures | |
| struct | cfmWindow_t |
| Struct for configuring the Clock Frequency Measure window. More... | |
Enumerations | |
| enum | clkFrq_t |
| Type definitions for available High Frequency Oscillator output frequencies used for configuring the main clock. More... | |
| enum | clkFrqDiv_t |
| Type definitions for available pre-scaler division used for configuring the main clock. More... | |
| enum | cfdSource_t |
| Type definitions for available Clock Failure Detection (CFD) sources used for configuring the CFDs. More... | |
| enum | cfdReference_t |
| Type definitions for available Clock Failure Detection (CFD) references used for configuring the CFDs. More... | |
| enum | cfmSource_t |
| Type definitions for available Clock Frequency Measure (CFM) sources used for configuring the CFMs. More... | |
| enum | cfmReference_t |
| Type definitions for available Clock Frequency Measure (CFM) references used for configuring the CFMs. More... | |
Functions | |
| errFlag_t | MW_GetClearClockCfd0Error (void) |
| Reads and clears the flag indicating a clock failure detected by CFD0. | |
| errFlag_t | MW_GetClearClockCfd1Error (void) |
| Reads and clears the flag indicating a clock failure detected by CFD1. | |
| errFlag_t | MW_GetClearClockCfm0Error (void) |
| Reads and clears the flag indicating a clock frequency error measured by CFM0. | |
| errFlag_t | MW_GetClearClockCfm1Error (void) |
| Reads and clears the flag indicating a clock frequency error measured by CFM1. | |
| void | MW_ClearClockCfmDoneFlags (void) |
| Clears the Clock Frequency Measure Done (CFMDn) flags indicating that a clock frequency measurement is done. | |
| errFlag_t | MW_SetMainClockFrequency (clkFrq_t frequency, clkFrqDiv_t divider) |
| Initializes main clock with internal High Frequency Oscillator (OSCHF) as clock source. | |
| errFlag_t | MW_StartCfd0 (cfdSource_t src, cfdReference_t ref) |
| Starts Clock Failure Detect 0 (CFD0) to monitor the configured clock source with the configured reference. | |
| void | MW_StopCfd0 (void) |
| Disables Clock Failure Detect 0 (CFD0). | |
| errFlag_t | MW_StartCfd1 (cfdSource_t src, cfdReference_t ref) |
| Starts Clock Failure Detect 1 (CFD1) to monitor the configured clock source with the configured reference. | |
| void | MW_StopCfd1 (void) |
| Disables Clock Failure Detect 1 (CFD1). | |
| errFlag_t | MW_StartCfm0 (cfmSource_t src, cfmReference_t ref, cfmWindow_t window, bool useContinuous) |
| Starts Clock Frequency Measure 0 (CFM0) to monitor the configured clock source with the configured reference. | |
| void | MW_StopCfm0 (void) |
| Disables Clock Frequency Measure 0 (CFM0). | |
| errFlag_t | MW_StartCfm1 (cfmSource_t src, cfmReference_t ref, cfmWindow_t window, bool useContinuous) |
| Starts Clock Frequency Measure 1 (CFM1) to monitor the configured clock source with the configured reference. | |
| void | MW_StopCfm1 (void) |
| Disables Clock Frequency Measure 1 (CFM1). | |
| void | MW_EnableClockInterrupts (void) |
| Enables all Clock Failure Detect (CFD) and Clock Frequency Measure (CFM) interrupts. | |
| errFlag_t | MW_DiagClockCfd0Begin (void) |
| Starts error injection diagnostic to detect faults in the Clock Failure Detection 0 (CFD0) monitor. | |
| errFlag_t | MW_DiagClockCfd0End (void) |
| Completes error injection diagnostic to detect faults in the Clock Failure Detection 0 (CFD0) monitor. | |
| bool | MW_IsDiagCfd0Ongoing (void) |
| Checks whether the CFD0 error injection diagnostic is ongoing. | |
| errFlag_t | MW_DiagClockCfd1Begin (void) |
| Starts error injection diagnostic to detect faults in the Clock Failure Detection 1 (CFD1) monitor. | |
| errFlag_t | MW_DiagClockCfd1End (void) |
| Completes error injection diagnostic to detect faults in the Clock Failure Detection 1 (CFD1) monitor. | |
| bool | MW_IsDiagCfd1Ongoing (void) |
| Checks whether the CFD1 error injection diagnostic is ongoing. | |
| errFlag_t | MW_DiagClockCfm0 (void) |
| Performs error injection diagnostic to detect faults in the Clock Frequency Measure 0 (CFM0) monitor. | |
| errFlag_t | MW_DiagClockCfm1 (void) |
| Performs error injection diagnostic to detect faults in the Clock Frequency Measure 1 (CFM1) monitor. | |
Contains API prototypes and defines for the Clock Manager.
The Clock Manager provides services to Tasks to ensure correct interaction with features of the CLKCTRL peripheral.
| enum cfdReference_t |
Type definitions for available Clock Failure Detection (CFD) references used for configuring the CFDs.
| Enumerator | |
|---|---|
| CFD_REF_OSC32K | OSC32K as reference |
| CFD_REF_ONEDIV32 | 1MHz/32 as reference |
| CFD_REF_XOSC32K | XOSC32K as reference |
| CFD_REF_MAX | Reserved/invalid, used as sentinel value for CFD reference. |
| enum cfdSource_t |
Type definitions for available Clock Failure Detection (CFD) sources used for configuring the CFDs.
| enum cfmReference_t |
Type definitions for available Clock Frequency Measure (CFM) references used for configuring the CFMs.
| enum cfmSource_t |
Type definitions for available Clock Frequency Measure (CFM) sources used for configuring the CFMs.
| enum clkFrq_t |
Type definitions for available High Frequency Oscillator output frequencies used for configuring the main clock.
| enum clkFrqDiv_t |
Type definitions for available pre-scaler division used for configuring the main clock.
| void MW_ClearClockCfmDoneFlags | ( | void | ) |
Clears the Clock Frequency Measure Done (CFMDn) flags indicating that a clock frequency measurement is done.
| errFlag_t MW_DiagClockCfd0Begin | ( | void | ) |
Starts error injection diagnostic to detect faults in the Clock Failure Detection 0 (CFD0) monitor.
This function starts a CFD0 monitor diagnostic. If this function returns NO_ERROR, the diagnostic must be completed by calling MW_DiagClockCfd0End after sufficient time has elapsed.
The diagnostic configures OSC32K as the CFD0 reference clock. The CFD requires 10 reference clock cycles to complete one measurement period, but a previous measurement period may need to complete before the injected fault is detected. The calling function must therefore ensure that at least 20 OSC32K clock cycles elapse before calling MW_DiagClockCfd0End, because a missing CFD0 error flag may mean either that the measurement is not yet complete or that the injected fault was not detected.
MW_DiagClockCfd0End is called, the CFD0 interrupt remains disabled and clock faults that CFD0 was configured to monitor before the diagnostic may not be detected. The original configurations are restored by MW_DiagClockCfd0End.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection is not initiated if the Error Controller is not in NORMAL state, the CFD0 Error Channel is already set or a CFD0 diagnostic is already ongoing.
| ERROR | Error injection did not start. |
| NO_ERROR | CFD0 diagnostic successfully started. |
| errFlag_t MW_DiagClockCfd0End | ( | void | ) |
Completes error injection diagnostic to detect faults in the Clock Failure Detection 0 (CFD0) monitor.
This function completes the CFD0 monitor diagnostic started by MW_DiagClockCfd0Begin. It evaluates whether the injected fault set both the CFD0 error flag and CFD0 Error Channel status, then restores the original CFD0 configuration, CFD0 Error Channel configuration and CFD0 interrupt enable state.
This function must only be called after at least 20 OSC32K clock cycles have elapsed since MW_DiagClockCfd0Begin. Calling this function too early may cause the diagnostic to report ERROR because the injected fault has not yet been detected.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by finishing the error injection.
If no CFD0 diagnostic is ongoing, this function does nothing and returns ERROR to avoid modifying the CFD0 configuration or CFD0 Error Channel configuration.
| ERROR | Fault detected in the CFD0 monitor or diagnostic was not started. |
| NO_ERROR | No fault detected in the CFD0 monitor. |
| errFlag_t MW_DiagClockCfd1Begin | ( | void | ) |
Starts error injection diagnostic to detect faults in the Clock Failure Detection 1 (CFD1) monitor.
This function starts a CFD1 monitor diagnostic. If this function returns NO_ERROR, the diagnostic must be completed by calling MW_DiagClockCfd1End after sufficient time has elapsed.
The diagnostic configures OSC32K as the CFD1 reference clock. The CFD requires 10 reference clock cycles to complete one measurement period, but a previous measurement period may need to complete before the injected fault is detected. The calling function must therefore ensure that at least 20 OSC32K clock cycles elapse before calling MW_DiagClockCfd1End, because a missing CFD1 error flag may mean either that the measurement is not yet complete or that the injected fault was not detected.
MW_DiagClockCfd1End is called, the CFD1 interrupt remains disabled and clock faults that CFD1 was configured to monitor before the diagnostic may not be detected. The original configurations are restored by MW_DiagClockCfd1End.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection is not initiated if the Error Controller is not in NORMAL state, the CFD1 Error Channel is already set or a CFD1 diagnostic is already ongoing.
| ERROR | Error injection did not start. |
| NO_ERROR | CFD1 diagnostic successfully started. |
| errFlag_t MW_DiagClockCfd1End | ( | void | ) |
Completes error injection diagnostic to detect faults in the Clock Failure Detection 1 (CFD1) monitor.
This function completes the CFD1 monitor diagnostic started by MW_DiagClockCfd1Begin. It evaluates whether the injected fault set both the CFD1 error flag and CFD1 Error Channel status, then restores the original CFD1 configuration, CFD1 Error Channel configuration and CFD1 interrupt enable state.
This function must only be called after at least 20 OSC32K clock cycles have elapsed since MW_DiagClockCfd1Begin. Calling this function too early may cause the diagnostic to report ERROR because the injected fault has not yet been detected.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by finishing the error injection.
If no CFD1 diagnostic is ongoing, this function does nothing and returns ERROR to avoid modifying the CFD1 configuration or CFD1 Error Channel configuration.
| ERROR | Fault detected in the CFD1 monitor or diagnostic was not started. |
| NO_ERROR | No fault detected in the CFD1 monitor. |
| errFlag_t MW_DiagClockCfm0 | ( | void | ) |
Performs error injection diagnostic to detect faults in the Clock Frequency Measure 0 (CFM0) monitor.
This function performs a CFM0 monitor diagnostic by running measurements with different window configurations and evaluating the responses. The CFM0 Done flag must be set after the expected time has elapsed for each measurement. The diagnostic performs three checks:
This function backs up the current CFM0 configuration and CFM0 Error Channel configuration, then applies temporary diagnostic configurations. Normal CFM0 faults may be masked during execution. The original configurations are restored before this function returns.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
If the CFM0 reference clock stops while CPU execution continues, the CFM0 Done flag is not set. The diagnostic treats this as a failed measurement after a bounded delay, restores the saved configuration, and returns ERROR.
The diagnostic is not started if the Error Controller is not in NORMAL state or the CFM0 Error Channel is already set.
| ERROR | Fault detected in the CFM0 monitor or diagnostic did not start. |
| NO_ERROR | No fault detected in the CFM0 monitor. |
| errFlag_t MW_DiagClockCfm1 | ( | void | ) |
Performs error injection diagnostic to detect faults in the Clock Frequency Measure 1 (CFM1) monitor.
This function performs a CFM1 monitor diagnostic by running measurements with different window configurations and evaluating the responses. The CFM1 Done flag must be set after the expected time has elapsed for each measurement. The diagnostic performs three checks:
This function backs up the current CFM1 configuration and CFM1 Error Channel configuration, then applies temporary diagnostic configurations. Normal CFM1 faults may be masked during execution. The original configurations are restored before this function returns.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
If the CFM1 reference clock stops while CPU execution continues, the CFM1 Done flag is not set. The diagnostic treats this as a failed measurement after a bounded delay, restores the saved configuration, and returns ERROR.
The diagnostic is not started if the Error Controller is not in NORMAL state or the CFM1 Error Channel is already set.
| ERROR | Fault detected in the CFM1 monitor or diagnostic did not start. |
| NO_ERROR | No fault detected in the CFM1 monitor. |
| void MW_EnableClockInterrupts | ( | void | ) |
Enables all Clock Failure Detect (CFD) and Clock Frequency Measure (CFM) interrupts.
This function enables the Clock Frequency Measurement Error Detected interrupts for CFM0 and CFM1 and Clock Failure Detected interrupts for CFD0 and CFD1.
| errFlag_t MW_GetClearClockCfd0Error | ( | void | ) |
Reads and clears the flag indicating a clock failure detected by CFD0.
This function checks whether the CFD0 interrupt flag has been set or not. If set, clears the flag and returns ERROR.
| ERROR | Clock failure detected by CFD0. |
| NO_ERROR | Clock failure not detected by CFD0. |
| errFlag_t MW_GetClearClockCfd1Error | ( | void | ) |
Reads and clears the flag indicating a clock failure detected by CFD1.
This function checks whether the CFD1 interrupt flag has been set or not. If set, clears the flag and returns ERROR.
| ERROR | Clock failure detected by CFD1. |
| NO_ERROR | Clock failure not detected by CFD1. |
| errFlag_t MW_GetClearClockCfm0Error | ( | void | ) |
Reads and clears the flag indicating a clock frequency error measured by CFM0.
This function checks whether the CFM0 interrupt flag has been set or not. If set, clears the flag and returns ERROR.
| ERROR | Clock frequency error measured by CFM0. |
| NO_ERROR | No clock frequency error measured by CFM0. |
| errFlag_t MW_GetClearClockCfm1Error | ( | void | ) |
Reads and clears the flag indicating a clock frequency error measured by CFM1.
This function checks whether the CFM1 interrupt flag has been set or not. If set, clears the flag and returns ERROR.
| ERROR | Clock frequency error measured by CFM1. |
| NO_ERROR | No clock frequency error measured by CFM1. |
| bool MW_IsDiagCfd0Ongoing | ( | void | ) |
Checks whether the CFD0 error injection diagnostic is ongoing.
This function returns whether the CFD0 diagnostic has been successfully started by MW_DiagClockCfd0Begin and has not yet been ended by MW_DiagClockCfd0End.
| true | The CFD0 diagnostic has been started and not yet ended. |
| false | The CFD0 diagnostic is not ongoing. |
| bool MW_IsDiagCfd1Ongoing | ( | void | ) |
Checks whether the CFD1 error injection diagnostic is ongoing.
This function returns whether the CFD1 diagnostic has been successfully started by MW_DiagClockCfd1Begin and has not yet been ended by MW_DiagClockCfd1End.
| true | The CFD1 diagnostic has been started and not yet ended. |
| false | The CFD1 diagnostic is not ongoing. |
| errFlag_t MW_SetMainClockFrequency | ( | clkFrq_t | frequency, |
| clkFrqDiv_t | divider ) |
Initializes main clock with internal High Frequency Oscillator (OSCHF) as clock source.
This function always configures the main clock to use the High Frequency Oscillator (OSCHF) as the clock source.
| frequency | The OSCHF main clock frequency to use. |
| divider | The division factor to divide the selected frequency by. |
| ERROR | Invalid frequency or division selected, main clock not configured. |
| NO_ERROR | All inputs are valid, clock configured correctly. |
| errFlag_t MW_StartCfd0 | ( | cfdSource_t | src, |
| cfdReference_t | ref ) |
Starts Clock Failure Detect 0 (CFD0) to monitor the configured clock source with the configured reference.
The CFD expects the MW_EnableClockInterrupts to be run before any error can be reported through an interrupt. Regardless of interrupt configuration, a CFD error will always be reported to the error controller.
If the CFD0 is already enabled, an error can be reported during re-configuration. To prevent this, call MW_StopCfd0 first.
| src | The clock source to be monitored by CFD0. |
| ref | The clock reference to be used by CFD0. |
| ERROR | Invalid clock source or reference selected, CFD0 not configured. |
| NO_ERROR | All inputs are valid, CFD0 configured correctly. |
| errFlag_t MW_StartCfd1 | ( | cfdSource_t | src, |
| cfdReference_t | ref ) |
Starts Clock Failure Detect 1 (CFD1) to monitor the configured clock source with the configured reference.
The CFD expects the MW_EnableClockInterrupts to be run before any error can be reported through an interrupt. Regardless of interrupt configuration, a CFD error will always be reported to the error controller.
If the CFD1 is already enabled, an error can be reported during re-configuration. To prevent this, call MW_StopCfd1 first.
| src | The clock source to be monitored by CFD1. |
| ref | The clock reference to be used by CFD1. |
| ERROR | Invalid clock source or reference selected, CFD1 not configured. |
| NO_ERROR | All inputs are valid, CFD1 configured correctly. |
| errFlag_t MW_StartCfm0 | ( | cfmSource_t | src, |
| cfmReference_t | ref, | ||
| cfmWindow_t | window, | ||
| bool | useContinuous ) |
Starts Clock Frequency Measure 0 (CFM0) to monitor the configured clock source with the configured reference.
The CFM expects the MW_EnableClockInterrupts to be run before any error can be reported through an interrupt. Regardless of interrupt configuration, a CFM error will always be reported to the error controller.
If the CFM0 is already enabled, an error can be reported during re-configuration. To prevent this, call MW_StopCfm0 first.
| src | The clock source to be monitored by CFM0. |
| ref | The clock reference to be used by CFM0. |
| window | The window configuration for the measurement. |
| useContinuous | Selects between continuous mode (true) and one-shot mode (false). |
| ERROR | Invalid clock source or reference selected, CFM0 not configured. |
| NO_ERROR | All inputs are valid, CFM0 configured correctly. |
| errFlag_t MW_StartCfm1 | ( | cfmSource_t | src, |
| cfmReference_t | ref, | ||
| cfmWindow_t | window, | ||
| bool | useContinuous ) |
Starts Clock Frequency Measure 1 (CFM1) to monitor the configured clock source with the configured reference.
The CFM expects the MW_EnableClockInterrupts to be run before any error can be reported through an interrupt. Regardless of interrupt configuration, a CFM error will always be reported to the error controller.
If the CFM1 is already enabled, an error can be reported during re-configuration. To prevent this, call MW_StopCfm1 first.
| src | The clock source to be monitored by CFM1. |
| ref | The clock reference to be used by CFM1. |
| window | The window configuration for the measurement. |
| useContinuous | Selects between continuous mode (true) and one-shot mode (false). |
| ERROR | Invalid clock source or reference selected, CFM1 not configured. |
| NO_ERROR | All inputs are valid, CFM1 configured correctly. |
| void MW_StopCfd0 | ( | void | ) |
Disables Clock Failure Detect 0 (CFD0).
This function disables CFD0 without changing its configuration. It is intended to be used before reconfiguration of CFD0 or entering Standby or Power-Down sleep modes.
During transitions into or out of sleep, the monitored clock source may be disabled or not yet stable. If CFD0 remains enabled during these transitions, a clock failure may be reported. Disabling CFD0 avoids spurious error reporting related to clock transitions.
| void MW_StopCfd1 | ( | void | ) |
Disables Clock Failure Detect 1 (CFD1).
This function disables CFD1 without changing its configuration. It is intended to be used before reconfiguration of CFD1 or entering Standby or Power-Down sleep modes.
During transitions into or out of sleep, the monitored clock source may be disabled or not yet stable. If CFD1 remains enabled during these transitions, a clock failure may be reported. Disabling CFD1 avoids spurious error reporting related to clock transitions.
| void MW_StopCfm0 | ( | void | ) |
Disables Clock Frequency Measure 0 (CFM0).
This function disables CFM0 without changing its configuration. It is intended to be used before reconfiguration of CFM0 or entering Standby or Power-Down sleep modes.
During transitions into or out of sleep, the monitored clock source may be disabled or not yet stable. If CFM0 remains enabled during these transitions, a clock frequency measurement error may be reported. Disabling CFM0 avoids spurious error reporting related to clock transitions.
| void MW_StopCfm1 | ( | void | ) |
Disables Clock Frequency Measure 1 (CFM1).
This function disables CFM1 without changing its configuration. It is intended to be used before reconfiguration of CFM1 or entering Standby or Power-Down sleep modes.
During transitions into or out of sleep, the monitored clock source may be disabled or not yet stable. If CFM1 remains enabled during these transitions, a clock frequency measurement error may be reported. Disabling CFM1 avoids spurious error reporting related to clock transitions.