Driver API for OSCCTRL (plib_oscctrl.h) More...
Macros | |
| #define | EXTERNAL_GCLKIN_FREQ (12000000UL) |
| #define | EXTERNAL_XOSC_FREQ (12000000UL) |
| #define | EXTERNAL_FDPLL96M_FREQ (96000000UL) |
Typedefs | |
| typedef void(* | OSCCTRL_CALLBACK) (OSCCTRL_IRQ_SOURCE source) |
| OSCCTRL callback function type. | |
Enumerations | |
| enum | OSCCTRL_IRQ_SOURCE { OSCCTRL_IRQ_OSC48MRDY = 0U , OSCCTRL_IRQ_XOSCRDY = 1U , OSCCTRL_IRQ_XOSCFAIL = 2U , OSCCTRL_IRQ_DPLLLCKR = 3U , OSCCTRL_IRQ_DPLLLCKF = 4U , OSCCTRL_IRQ_DPLLLTO = 5U , OSCCTRL_IRQ_DPLLLDRTO = 6U } |
| OSCCTRL interrupt source 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_Initialize (void) |
| Initializes the OSCCTRL interrupt handling. | |
| void | OSCCTRL_OSC48M_Enable (void) |
| Enables the OSC48M internal oscillator. | |
| void | OSCCTRL_OSC48M_Disable (void) |
| Disables the OSC48M internal oscillator. | |
| void | OSCCTRL_OSC48M_SetDivider (uint8_t div_sel) |
| Sets the OSC48M divider value. | |
| uint32_t | OSCCTRL_OSC48M_GetFrequency (void) |
| Returns the current OSC48M output frequency in Hz. | |
| void | OSCCTRL_OSC48M_SetStartUpTime (uint8_t startup_sel) |
| Sets the OSC48M startup delay. | |
| bool | OSCCTRL_OSC48M_GetDividerSyncBusy (void) |
| Checks if OSC48M divider synchronization is busy. | |
| void | OSCCTRL_OSC48M_EnableOnDemand (void) |
| Enables On-Demand mode for OSC48M. | |
| void | OSCCTRL_OSC48M_DisableOnDemand (void) |
| Disables On-Demand mode for OSC48M. | |
| void | OSCCTRL_OSC48M_EnableRunInStandby (void) |
| Enables Run-In-Standby mode for OSC48M. | |
| void | OSCCTRL_OSC48M_DisableRunInStandby (void) |
| Disables Run-In-Standby mode for OSC48M. | |
| bool | OSCCTRL_OSC48M_IsReady (void) |
| Checks if OSC48M is ready. | |
| void | OSCCTRL_EnableInterrupt (OSCCTRL_IRQ_SOURCE irq_source) |
| Enables the specified OSCCTRL interrupt source. | |
| void | OSCCTRL_DisableInterrupt (OSCCTRL_IRQ_SOURCE irq_source) |
| Disables the specified OSCCTRL interrupt source. | |
| bool | OSCCTRL_InterruptFlagIsSet (OSCCTRL_IRQ_SOURCE irq_source) |
| Checks if the specified OSCCTRL interrupt flag is set. | |
| void | OSCCTRL_ClearInterruptFlag (OSCCTRL_IRQ_SOURCE irq_source) |
| Clears the specified OSCCTRL interrupt flag. | |
| void | OSCCTRL_SetCallbackHandler (OSCCTRL_CALLBACK callback) |
| Registers a callback function for OSCCTRL interrupt events. | |
| void | OSCCTRL_XOSC_Enable (void) |
| Enables the external crystal oscillator (XOSC). | |
| void | OSCCTRL_XOSC_Disable (void) |
| Disables the external crystal oscillator (XOSC). | |
| void | OSCCTRL_XOSC_EnableCrystal (void) |
| Enables crystal mode for XOSC. | |
| void | OSCCTRL_XOSC_DisableCrystal (void) |
| Disables crystal mode for XOSC. | |
| void | OSCCTRL_XOSC_EnableFailureDetector (void) |
| Enables the XOSC clock failure detector. | |
| void | OSCCTRL_XOSC_DisableFailureDetector (void) |
| Disables the XOSC clock failure detector. | |
| void | OSCCTRL_XOSC_EnableOnDemand (void) |
| Enables On-Demand mode for XOSC. | |
| void | OSCCTRL_XOSC_DisableOnDemand (void) |
| Disables On-Demand mode for XOSC. | |
| void | OSCCTRL_XOSC_EnableRunInStandby (void) |
| Enables Run-In-Standby mode for XOSC. | |
| void | OSCCTRL_XOSC_DisableRunInStandby (void) |
| Disables Run-In-Standby mode for XOSC. | |
| void | OSCCTRL_XOSC_SetGain (uint16_t gain) |
| Sets the XOSC gain. | |
| void | OSCCTRL_XOSC_SetStartUpTime (uint16_t startup) |
| Sets the XOSC startup time. | |
| bool | OSCCTRL_XOSC_IsReady (void) |
| Checks if XOSC is ready. | |
| bool | OSCCTRL_XOSC_FailureIsDetected (void) |
| Checks if XOSC failure is detected. | |
| bool | OSCCTRL_XOSC_ClockIsSwitchedToSafe (void) |
| Checks if XOSC clock has switched to the safe clock. | |
| void | OSCCTRL_CFD_SetPrescaler (uint8_t presc) |
| Sets the clock failure detector prescaler. | |
| void | OSCCTRL_CFD_EnableEventOutput (void) |
| Enables clock failure detector event output. | |
| void | OSCCTRL_CFD_DisableEventOutput (void) |
| Disables clock failure detector event output. | |
| void | OSCCTRL_DPLL_Enable (void) |
| Enables the DPLL. | |
| void | OSCCTRL_DPLL_Disable (void) |
| Disables the DPLL. | |
| void | OSCCTRL_DPLL_EnableOnDemand (void) |
| Enables On-Demand mode for DPLL. | |
| void | OSCCTRL_DPLL_DisableOnDemand (void) |
| Disables On-Demand mode for DPLL. | |
| void | OSCCTRL_DPLL_EnableRunInStandby (void) |
| Enables Run-In-Standby mode for DPLL. | |
| void | OSCCTRL_DPLL_DisableRunInStandby (void) |
| Disables Run-In-Standby mode for DPLL. | |
| void | OSCCTRL_DPLL_SetReference (uint32_t refclk) |
| Sets the DPLL reference clock. | |
| void | OSCCTRL_DPLL_SetFilter (uint32_t filter) |
| Sets the DPLL filter selection. | |
| void | OSCCTRL_DPLL_SetLockTime (uint32_t ltime) |
| Sets the DPLL lock time. | |
| void | OSCCTRL_DPLL_EnableLowPowerMode (void) |
| Enables DPLL low-power mode. | |
| void | OSCCTRL_DPLL_DisableLowPowerMode (void) |
| Disables DPLL low-power mode. | |
| void | OSCCTRL_DPLL_SetRatio (uint16_t ldr, uint8_t ldrfrac) |
| Sets the DPLL ratio. | |
| void | OSCCTRL_DPLL_SetDivider (uint16_t div) |
| Sets the DPLL output divider. | |
| void | OSCCTRL_DPLL_SetPrescaler (uint8_t presc) |
| Sets the DPLL prescaler. | |
| bool | OSCCTRL_DPLL_GetEnableSyncBusy (void) |
| Checks if DPLL enable synchronization is busy. | |
| bool | OSCCTRL_DPLL_GetRatioSyncBusy (void) |
| Checks if DPLL ratio synchronization is busy. | |
| bool | OSCCTRL_DPLL_GetPrescalerSyncBusy (void) |
| Checks if DPLL prescaler synchronization is busy. | |
| bool | OSCCTRL_DPLL_IsLocked (void) |
| Checks if the DPLL is locked. | |
| bool | OSCCTRL_DPLL_ClockIsReady (void) |
| Checks if the DPLL clock output is ready. | |
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 EXTERNAL_FDPLL96M_FREQ (96000000UL) |
| #define EXTERNAL_GCLKIN_FREQ (12000000UL) |
| #define EXTERNAL_XOSC_FREQ (12000000UL) |
| typedef void(* OSCCTRL_CALLBACK) (OSCCTRL_IRQ_SOURCE source) |
OSCCTRL callback function type.
| enum OSCCTRL_IRQ_SOURCE |
| 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_CFD_DisableEventOutput | ( | void | ) |
Disables clock failure detector event output.
| None. |
| void OSCCTRL_CFD_EnableEventOutput | ( | void | ) |
Enables clock failure detector event output.
| None. |
| void OSCCTRL_CFD_SetPrescaler | ( | uint8_t | presc | ) |
Sets the clock failure detector prescaler.
| presc | Prescaler value to be set (2^presc divider). |
| void OSCCTRL_ClearInterruptFlag | ( | OSCCTRL_IRQ_SOURCE | irq_source | ) |
Clears the specified OSCCTRL interrupt flag.
| irq_source | Interrupt source. |
| void OSCCTRL_DisableInterrupt | ( | OSCCTRL_IRQ_SOURCE | irq_source | ) |
Disables the specified OSCCTRL interrupt source.
| irq_source | Interrupt source. |
| bool OSCCTRL_DPLL_ClockIsReady | ( | void | ) |
Checks if the DPLL clock output is ready.
| None. |
| void OSCCTRL_DPLL_Disable | ( | void | ) |
Disables the DPLL.
| None. |
| void OSCCTRL_DPLL_DisableLowPowerMode | ( | void | ) |
Disables DPLL low-power mode.
| None. |
| void OSCCTRL_DPLL_DisableOnDemand | ( | void | ) |
Disables On-Demand mode for DPLL.
| None. |
| void OSCCTRL_DPLL_DisableRunInStandby | ( | void | ) |
Disables Run-In-Standby mode for DPLL.
| None. |
| void OSCCTRL_DPLL_Enable | ( | void | ) |
Enables the DPLL.
| None. |
| void OSCCTRL_DPLL_EnableLowPowerMode | ( | void | ) |
Enables DPLL low-power mode.
| None. |
| void OSCCTRL_DPLL_EnableOnDemand | ( | void | ) |
Enables On-Demand mode for DPLL.
| None. |
| void OSCCTRL_DPLL_EnableRunInStandby | ( | void | ) |
Enables Run-In-Standby mode for DPLL.
| None. |
| bool OSCCTRL_DPLL_GetEnableSyncBusy | ( | void | ) |
Checks if DPLL enable synchronization is busy.
| None. |
| bool OSCCTRL_DPLL_GetPrescalerSyncBusy | ( | void | ) |
Checks if DPLL prescaler synchronization is busy.
| None. |
| bool OSCCTRL_DPLL_GetRatioSyncBusy | ( | void | ) |
Checks if DPLL ratio synchronization is busy.
| None. |
| bool OSCCTRL_DPLL_IsLocked | ( | void | ) |
Checks if the DPLL is locked.
| None. |
| void OSCCTRL_DPLL_SetDivider | ( | uint16_t | div | ) |
Sets the DPLL output divider.
| div | Divider value to be set. |
| void OSCCTRL_DPLL_SetFilter | ( | uint32_t | filter | ) |
Sets the DPLL filter selection.
| filter | Filter selection value to be set. |
| void OSCCTRL_DPLL_SetLockTime | ( | uint32_t | ltime | ) |
Sets the DPLL lock time.
| ltime | Lock time selection value to be set. |
| void OSCCTRL_DPLL_SetPrescaler | ( | uint8_t | presc | ) |
Sets the DPLL prescaler.
| presc | Prescaler selection value to be set. |
| void OSCCTRL_DPLL_SetRatio | ( | uint16_t | ldr, |
| uint8_t | ldrfrac ) |
Sets the DPLL ratio.
| ldr | Loop divider ratio value to be set. |
| ldrfrac | Fractional part of the loop divider ratio. |
| void OSCCTRL_DPLL_SetReference | ( | uint32_t | refclk | ) |
Sets the DPLL reference clock.
| refclk | Reference clock selection value to be set. |
| void OSCCTRL_EnableInterrupt | ( | OSCCTRL_IRQ_SOURCE | irq_source | ) |
Enables the specified OSCCTRL interrupt source.
| irq_source | Interrupt source. |
| void OSCCTRL_Initialize | ( | void | ) |
Initializes the OSCCTRL interrupt handling.
| None. |
| bool OSCCTRL_InterruptFlagIsSet | ( | OSCCTRL_IRQ_SOURCE | irq_source | ) |
Checks if the specified OSCCTRL interrupt flag is set.
| irq_source | Interrupt source. |
| void OSCCTRL_OSC48M_Disable | ( | void | ) |
Disables the OSC48M internal oscillator.
| None. |
| void OSCCTRL_OSC48M_DisableOnDemand | ( | void | ) |
Disables On-Demand mode for OSC48M.
| None. |
| void OSCCTRL_OSC48M_DisableRunInStandby | ( | void | ) |
Disables Run-In-Standby mode for OSC48M.
| None. |
| void OSCCTRL_OSC48M_Enable | ( | void | ) |
Enables the OSC48M internal oscillator.
| None. |
| void OSCCTRL_OSC48M_EnableOnDemand | ( | void | ) |
Enables On-Demand mode for OSC48M.
| None. |
| void OSCCTRL_OSC48M_EnableRunInStandby | ( | void | ) |
Enables Run-In-Standby mode for OSC48M.
| None. |
| bool OSCCTRL_OSC48M_GetDividerSyncBusy | ( | void | ) |
Checks if OSC48M divider synchronization is busy.
| None. |
| uint32_t OSCCTRL_OSC48M_GetFrequency | ( | void | ) |
Returns the current OSC48M output frequency in Hz.
| None. |
| bool OSCCTRL_OSC48M_IsReady | ( | void | ) |
Checks if OSC48M is ready.
| None. |
| void OSCCTRL_OSC48M_SetDivider | ( | uint8_t | div_sel | ) |
Sets the OSC48M divider value.
| div_sel | Divider selection value to be set. |
| void OSCCTRL_OSC48M_SetStartUpTime | ( | uint8_t | startup_sel | ) |
Sets the OSC48M startup delay.
| startup_sel | Startup time selection value to be set. |
| void OSCCTRL_SetCallbackHandler | ( | OSCCTRL_CALLBACK | callback | ) |
Registers a callback function for OSCCTRL interrupt events.
| callback | Pointer to the callback function to be registered. |
| bool OSCCTRL_XOSC_ClockIsSwitchedToSafe | ( | void | ) |
Checks if XOSC clock has switched to the safe clock.
| None. |
| void OSCCTRL_XOSC_Disable | ( | void | ) |
Disables the external crystal oscillator (XOSC).
| None. |
| void OSCCTRL_XOSC_DisableCrystal | ( | void | ) |
Disables crystal mode for XOSC.
| None. |
| void OSCCTRL_XOSC_DisableFailureDetector | ( | void | ) |
Disables the XOSC clock failure detector.
| None. |
| void OSCCTRL_XOSC_DisableOnDemand | ( | void | ) |
Disables On-Demand mode for XOSC.
| None. |
| void OSCCTRL_XOSC_DisableRunInStandby | ( | void | ) |
Disables Run-In-Standby mode for XOSC.
| None. |
| void OSCCTRL_XOSC_Enable | ( | void | ) |
Enables the external crystal oscillator (XOSC).
| None. |
| void OSCCTRL_XOSC_EnableCrystal | ( | void | ) |
Enables crystal mode for XOSC.
| None. |
| void OSCCTRL_XOSC_EnableFailureDetector | ( | void | ) |
Enables the XOSC clock failure detector.
| None. |
| void OSCCTRL_XOSC_EnableOnDemand | ( | void | ) |
Enables On-Demand mode for XOSC.
| None. |
| void OSCCTRL_XOSC_EnableRunInStandby | ( | void | ) |
Enables Run-In-Standby mode for XOSC.
| None. |
| bool OSCCTRL_XOSC_FailureIsDetected | ( | void | ) |
Checks if XOSC failure is detected.
| None. |
| bool OSCCTRL_XOSC_IsReady | ( | void | ) |
Checks if XOSC is ready.
| None. |
| void OSCCTRL_XOSC_SetGain | ( | uint16_t | gain | ) |
Sets the XOSC gain.
| gain | Gain selection value to be set. |
| void OSCCTRL_XOSC_SetStartUpTime | ( | uint16_t | startup | ) |
Sets the XOSC startup time.
| startup | Startup time selection value to be set. |
|
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.