Driver API for OSCCTRL (plib_oscctrl.h) More...
Macros | |
| #define | GCLKIN_CLOCK_FREQ (12000000UL) |
| #define | OSCCTRL_WP_KEY (0x4F5343U) |
| Write protection key for OSCCTRL registers. | |
Typedefs | |
| typedef void(* | OSCCTRL_CALLBACK) (void) |
| OSCHF ready event callback function type. | |
Enumerations | |
| enum | OSCCTRL_OSCHF_FREQ { OSCCTRL_OSCHF_FREQ_1M = 0x00U , OSCCTRL_OSCHF_FREQ_2M = 0x01U , OSCCTRL_OSCHF_FREQ_3M = 0x02U , OSCCTRL_OSCHF_FREQ_4M = 0x03U , OSCCTRL_OSCHF_FREQ_8M = 0x05U , OSCCTRL_OSCHF_FREQ_12M = 0x06U , OSCCTRL_OSCHF_FREQ_16M = 0x07U , OSCCTRL_OSCHF_FREQ_20M = 0x08U , OSCCTRL_OSCHF_FREQ_24M = 0x09U } |
| OSCHF frequency selection enumeration. More... | |
Functions | |
| uint32_t | CLOCK_GetPeripheralChannelFreq (uint32_t peripheral_channel_id) |
| Fetches the clock frequency for a specific peripheral channel in Hz. | |
| void | OSCCTRL_OSCHF_Initialize (void) |
| Initializes the OSCHF oscillator. | |
| void | OSCCTRL_OSCHF_SetFrequency (OSCCTRL_OSCHF_FREQ freq_sel) |
| This function sets the frequency selection value for the internal OSCHF Oscillator. | |
| uint32_t | OSCCTRL_OSCHF_GetFrequency (void) |
| Returns the current frequency of the internal OSCHF Oscillator. | |
| void | OSCCTRL_OSCHF_EnableAutotune (void) |
| Enables automatic tuning for the OSCHF Oscillator. | |
| void | OSCCTRL_OSCHF_DisableAutotune (void) |
| Disables automatic tuning for the OSCHF Oscillator. | |
| bool | OSCCTRL_OSCHF_AutotuneIsEnabled (void) |
| Checks if the autotune feature is enabled for the OSCHF oscillator. | |
| void | OSCCTRL_OSCHF_EnableOnDemand (void) |
| Enables On-Demand mode for the OSCHF Oscillator. | |
| void | OSCCTRL_OSCHF_DisableOnDemand (void) |
| Disables On-Demand mode for the OSCHF Oscillator. | |
| bool | OSCCTRL_OSCHF_OnDemandIsEnabled (void) |
| Checks if the On-Demand feature is enabled for the OSCHF oscillator. | |
| void | OSCCTRL_EnableWriteProtection (void) |
| Enables write protection for the OSCHF Oscillator registers. | |
| void | OSCCTRL_DisableWriteProtection (void) |
| Disables write protection for the OSCHF Oscillator registers. | |
| bool | OSCCTRL_WriteProtectionIsEnabled (void) |
| Checks if write protection is enabled for the OSCHF oscillator registers. | |
| void | OSCCTRL_WPCTRL_EnableWriteLock (void) |
| Enables the write protection lock for the WPCTRL register. | |
| bool | OSCCTRL_WPCTRL_WriteLockIsEnabled (void) |
| Checks if the Write Protection Lock is enabled for the WPCTRL register. | |
| void | OSCCTRL_OSCHF_SetManualTune (uint8_t tune_value) |
| Sets the manual tuning value for the OSCHF Oscillator. Note that Autotune must be disabled to use manual tuning. Failing to do so will issue a pslverr. | |
| uint8_t | OSCCTRL_OSCHF_GetFrequencyTune (void) |
| Gets the current manual tuning value of the OSCHF oscillator. | |
| bool | OSCCTRL_OSCHF_IsReady (void) |
| Checks if the OSCHF Oscillator is ready. | |
| void | OSCCTRL_OSCHF_EnableReadyInterrupt (void) |
| Enables the ready interrupt for the OSCHF Oscillator. | |
| bool | OSCCTRL_OSCHF_ReadyInterruptIsEnabled (void) |
| Checks if the ready interrupt is enabled for the OSCHF oscillator. | |
| void | OSCCTRL_OSCHF_DisableReadyInterrupt (void) |
| Disables the ready interrupt for the OSCHF Oscillator. | |
| bool | OSCCTRL_OSCHF_InterruptFlagIsSet (void) |
| Checks if the ready interrupt flag is set for the OSCHF oscillator. | |
| void | OSCCTRL_OSCHF_ClearInterruptFlag (void) |
| Clears the ready interrupt flag for the OSCHF oscillator. | |
| void | OSCCTRL_OSCHF_SetReadyInterruptFlag (void) |
| Asserts the ready interrupt flag for the OSCHF Oscillator. It is used for testing purposes to simulate the interrupt condition. | |
| void | OSCCTRL_OSCHF_SetReadyCallbackHandler (OSCCTRL_CALLBACK callback) |
| Registers a callback function for the OSCHF ready interrupt. This function stores a user-provided callback to be called when the OSCHF Oscillator ready interrupt occurs. | |
Variables | |
| uint32_t | SystemCoreClock |
| System core clock frequency. This global variable holds the current core (CPU) clock frequency in Hertz. Update the value with SystemCoreClockUpdate() whenever the core clock is changed. | |
Driver API for OSCCTRL (plib_oscctrl.h)
The following example demonstrates typical usage of the OSCCTRL peripheral:
| #define GCLKIN_CLOCK_FREQ (12000000UL) |
| #define OSCCTRL_WP_KEY (0x4F5343U) |
Write protection key for OSCCTRL registers.
| typedef void(* OSCCTRL_CALLBACK) (void) |
OSCHF ready event callback function type.
| None. |
| enum OSCCTRL_OSCHF_FREQ |
| uint32_t CLOCK_GetPeripheralChannelFreq | ( | uint32_t | peripheral_channel_id | ) |
Fetches the clock frequency for a specific peripheral channel in Hz.
This function calculates and returns the frequency of a peripheral channel (GCLK peripheral control) by reading the assigned GCLK generator, its source, and division settings. It uses existing PLIB GCLK and OSCCTRL APIs to determine the actual frequency.
| peripheral_channel_id | The peripheral channel ID (e.g., SERCOM0_GCLK_ID_CORE, TC0_GCLK_ID). This must be a valid peripheral channel identifier from the device header. |
| void OSCCTRL_DisableWriteProtection | ( | void | ) |
Disables write protection for the OSCHF Oscillator registers.
| None. |
| void OSCCTRL_EnableWriteProtection | ( | void | ) |
Enables write protection for the OSCHF Oscillator registers.
| None. |
| bool OSCCTRL_OSCHF_AutotuneIsEnabled | ( | void | ) |
Checks if the autotune feature is enabled for the OSCHF oscillator.
| None. |
| void OSCCTRL_OSCHF_ClearInterruptFlag | ( | void | ) |
Clears the ready interrupt flag for the OSCHF oscillator.
| None. |
| void OSCCTRL_OSCHF_DisableAutotune | ( | void | ) |
Disables automatic tuning for the OSCHF Oscillator.
| None. |
| void OSCCTRL_OSCHF_DisableOnDemand | ( | void | ) |
Disables On-Demand mode for the OSCHF Oscillator.
| None. |
| void OSCCTRL_OSCHF_DisableReadyInterrupt | ( | void | ) |
Disables the ready interrupt for the OSCHF Oscillator.
| None. |
| void OSCCTRL_OSCHF_EnableAutotune | ( | void | ) |
Enables automatic tuning for the OSCHF Oscillator.
| None. |
| void OSCCTRL_OSCHF_EnableOnDemand | ( | void | ) |
Enables On-Demand mode for the OSCHF Oscillator.
| None. |
| void OSCCTRL_OSCHF_EnableReadyInterrupt | ( | void | ) |
Enables the ready interrupt for the OSCHF Oscillator.
| None. |
| uint32_t OSCCTRL_OSCHF_GetFrequency | ( | void | ) |
Returns the current frequency of the internal OSCHF Oscillator.
| None. |
| uint8_t OSCCTRL_OSCHF_GetFrequencyTune | ( | void | ) |
Gets the current manual tuning value of the OSCHF oscillator.
| None. |
| void OSCCTRL_OSCHF_Initialize | ( | void | ) |
Initializes the OSCHF oscillator.
| None. |
| bool OSCCTRL_OSCHF_InterruptFlagIsSet | ( | void | ) |
Checks if the ready interrupt flag is set for the OSCHF oscillator.
| None. |
| bool OSCCTRL_OSCHF_IsReady | ( | void | ) |
Checks if the OSCHF Oscillator is ready.
| None. |
| bool OSCCTRL_OSCHF_OnDemandIsEnabled | ( | void | ) |
Checks if the On-Demand feature is enabled for the OSCHF oscillator.
| None. |
| bool OSCCTRL_OSCHF_ReadyInterruptIsEnabled | ( | void | ) |
Checks if the ready interrupt is enabled for the OSCHF oscillator.
| None. |
| void OSCCTRL_OSCHF_SetFrequency | ( | OSCCTRL_OSCHF_FREQ | freq_sel | ) |
This function sets the frequency selection value for the internal OSCHF Oscillator.
| freq_sel | Frequency selection value to be set. |
| void OSCCTRL_OSCHF_SetManualTune | ( | uint8_t | tune_value | ) |
Sets the manual tuning value for the OSCHF Oscillator. Note that Autotune must be disabled to use manual tuning. Failing to do so will issue a pslverr.
| tune_value | The manual tuning value to be set (2's complement format). |
| void OSCCTRL_OSCHF_SetReadyCallbackHandler | ( | OSCCTRL_CALLBACK | callback | ) |
Registers a callback function for the OSCHF ready interrupt. This function stores a user-provided callback to be called when the OSCHF Oscillator ready interrupt occurs.
| callback | Pointer to the callback function to be registered. |
| void OSCCTRL_OSCHF_SetReadyInterruptFlag | ( | void | ) |
Asserts the ready interrupt flag for the OSCHF Oscillator. It is used for testing purposes to simulate the interrupt condition.
| None. |
| void OSCCTRL_WPCTRL_EnableWriteLock | ( | void | ) |
Enables the write protection lock for the WPCTRL register.
| None. |
| bool OSCCTRL_WPCTRL_WriteLockIsEnabled | ( | void | ) |
Checks if the Write Protection Lock is enabled for the WPCTRL register.
| None. |
| bool OSCCTRL_WriteProtectionIsEnabled | ( | void | ) |
Checks if write protection is enabled for the OSCHF oscillator registers.
| None. |
|
extern |
System core clock frequency. This global variable holds the current core (CPU) clock frequency in Hertz. Update the value with SystemCoreClockUpdate() whenever the core clock is changed.