S32 SDK
scg_hal.h File Reference
#include "device_registers.h"
#include "status.h"
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  scg_system_clock_config_t
 SCG system clock configuration. Implements scg_system_clock_config_t_Class. More...
 
struct  scg_sosc_config_t
 SCG system OSC configuration. Implements scg_sosc_config_t_Class. More...
 
struct  scg_sirc_config_t
 SCG slow IRC clock configuration. Implements scg_sirc_config_t_Class. More...
 
struct  scg_firc_config_t
 SCG fast IRC clock configuration. Implements scg_firc_config_t_Class. More...
 
struct  scg_spll_config_t
 SCG system PLL configuration. Implements scg_spll_config_t_Class. More...
 
struct  scg_rtc_config_t
 SCG RTC configuration. Implements scg_rtc_config_t_Class. More...
 
struct  scg_clock_mode_config_t
 SCG Clock Mode Configuration structure. Implements scg_clock_mode_config_t_Class. More...
 
struct  scg_clockout_config_t
 SCG ClockOut Configuration structure. Implements scg_clockout_config_t_Class. More...
 
struct  scg_config_t
 SCG configure structure. Implements scg_config_t_Class. More...
 

Enumerations

enum  scg_async_clock_type_t { SCG_ASYNC_CLOCK_DIV1, SCG_ASYNC_CLOCK_DIV2, SCG_ASYNC_CLOCK_MAX }
 SCG asynchronous clock type. Implements scg_async_clock_type_t_Class. More...
 
enum  scg_async_clock_div_t {
  SCG_ASYNC_CLOCK_DISABLE = 0U, SCG_ASYNC_CLOCK_DIV_BY_1 = 1U, SCG_ASYNC_CLOCK_DIV_BY_2 = 2U, SCG_ASYNC_CLOCK_DIV_BY_4 = 3U,
  SCG_ASYNC_CLOCK_DIV_BY_8 = 4U, SCG_ASYNC_CLOCK_DIV_BY_16 = 5U, SCG_ASYNC_CLOCK_DIV_BY_32 = 6U, SCG_ASYNC_CLOCK_DIV_BY_64 = 7U
}
 SCG asynchronous clock divider value. Implements scg_async_clock_div_t_Class. More...
 
enum  scg_sosc_monitor_mode_t { SCG_SOSC_MONITOR_DISABLE = 0U, SCG_SOSC_MONITOR_INT = SCG_SOSCCSR_SOSCCM_MASK, SCG_SOSC_MONITOR_RESET }
 SCG system OSC monitor mode. Implements scg_sosc_monitor_mode_t_Class. More...
 
enum  scg_sosc_range_t { SCG_SOSC_RANGE_LOW = 1U, SCG_SOSC_RANGE_MID = 2U, SCG_SOSC_RANGE_HIGH = 3U }
 SCG OSC frequency range select Implements scg_sosc_range_t_Class. More...
 
enum  scg_sosc_gain_t { SCG_SOSC_GAIN_LOW, SCG_SOSC_GAIN_HIGH }
 SCG OSC high gain oscillator select. Implements scg_sosc_gain_t_Class. More...
 
enum  scg_sosc_ext_ref_t { SCG_SOSC_REF_EXT, SCG_SOSC_REF_OSC }
 SCG OSC external reference clock select. Implements scg_sosc_ext_ref_t_Class. More...
 
enum  scg_sirc_range_t { SCG_SIRC_RANGE_LOW, SCG_SIRC_RANGE_HIGH }
 SCG slow IRC clock frequency range. Implements scg_sirc_range_t_Class. More...
 
enum  scg_firc_range_t { SCG_FIRC_RANGE_48M, SCG_FIRC_RANGE_52M, SCG_FIRC_RANGE_56M, SCG_FIRC_RANGE_60M }
 SCG fast IRC clock frequency range. Implements scg_firc_range_t_Class. More...
 
enum  scg_spll_monitor_mode_t { SCG_SPLL_MONITOR_DISABLE = 0U, SCG_SPLL_MONITOR_INT = SCG_SPLLCSR_SPLLCM_MASK, SCG_SPLL_MONITOR_RESET }
 SCG system PLL monitor mode. Implements scg_spll_monitor_mode_t_Class. More...
 
SCG Clockout.
enum  scg_clockout_src_t {
  SCG_CLOCKOUT_SRC_SCG_SLOW = 0U, SCG_CLOCKOUT_SRC_SOSC = 1U, SCG_CLOCKOUT_SRC_SIRC = 2U, SCG_CLOCKOUT_SRC_FIRC = 3U,
  SCG_CLOCKOUT_SRC_SPLL = 6U
}
 SCG ClockOut type. Implements scg_clockout_src_t_Class. More...
 

Functions

SCG Clockout Configuration
static scg_clockout_src_t SCG_HAL_GetClockoutSourceSel (const SCG_Type *base)
 Get SCG ClockOut source select. More...
 
static void SCG_HAL_SetClockoutSourceSel (SCG_Type *base, scg_clockout_src_t source)
 Set SCG ClockOut source select. More...
 
System OSC Clock.
void SCG_HAL_GetSysOscDefaultConfig (scg_sosc_config_t *config)
 Get the default system OSC configuration. More...
 
status_t SCG_HAL_InitSysOsc (SCG_Type *base, scg_sosc_config_t const *config)
 Initialize SCG system OSC. More...
 
status_t SCG_HAL_DeinitSysOsc (SCG_Type *base)
 De-initialize SCG system OSC. More...
 
uint32_t SCG_HAL_GetSysOscFreq (const SCG_Type *base)
 Get SCG system OSC clock frequency (SYSOSC). More...
 
uint32_t SCG_HAL_GetSysOscAsyncFreq (const SCG_Type *base, scg_async_clock_type_t type)
 Get SCG asynchronous clock frequency from system OSC. More...
 
Slow IRC Clock.
void SCG_HAL_GetSircDefaultConfig (scg_sirc_config_t *config)
 Get the default slow IRC clock configuration. More...
 
status_t SCG_HAL_InitSirc (SCG_Type *base, const scg_sirc_config_t *config)
 Initialize SCG slow IRC clock. More...
 
status_t SCG_HAL_DeinitSirc (SCG_Type *base)
 De-initialize SCG slow IRC. More...
 
uint32_t SCG_HAL_GetSircFreq (const SCG_Type *base)
 Get SCG SIRC clock frequency. More...
 
uint32_t SCG_HAL_GetSircAsyncFreq (const SCG_Type *base, scg_async_clock_type_t type)
 Get SCG asynchronous clock frequency from SIRC. More...
 
Fast IRC Clock.
void SCG_HAL_GetFircDefaultConfig (scg_firc_config_t *config)
 Get the default fast IRC clock configuration. More...
 
status_t SCG_HAL_InitFirc (SCG_Type *base, const scg_firc_config_t *config)
 Initialize SCG fast IRC clock. More...
 
status_t SCG_HAL_DeinitFirc (SCG_Type *base)
 De-initialize SCG fast IRC. More...
 
uint32_t SCG_HAL_GetFircFreq (const SCG_Type *base)
 Get SCG FIRC clock frequency. More...
 
uint32_t SCG_HAL_GetFircAsyncFreq (const SCG_Type *base, scg_async_clock_type_t type)
 Get SCG asynchronous clock frequency from FIRC. More...
 
static scg_system_clock_src_t SCG_HAL_GetSystemClockSrc (const SCG_Type *base)
 Get SCG system clock source. More...
 
uint32_t SCG_HAL_GetSystemClockFreq (const SCG_Type *base, scg_system_clock_type_t type)
 Get SCG system clock frequency. More...
 
System PLL Clock.
void SCG_HAL_GetSysPllDefaultConfig (scg_spll_config_t *config)
 Get the default system PLL configuration. More...
 
status_t SCG_HAL_InitSysPll (SCG_Type *base, scg_spll_config_t const *config)
 Initialize SCG system PLL. More...
 
status_t SCG_HAL_DeinitSysPll (SCG_Type *base)
 De-initialize SCG system PLL. More...
 
uint32_t SCG_HAL_GetSysPllFreq (const SCG_Type *base)
 Get SCG system PLL clock frequency. More...
 
uint32_t SCG_HAL_GetSysPllAsyncFreq (const SCG_Type *base, scg_async_clock_type_t type)
 Get SCG asynchronous clock frequency from system PLL. More...
 
RTC Clock.
void SCG_HAL_SetRtcClkInFreq (SCG_Type *base, uint32_t frequency)
 Set SCG RTC CLKIN clock frequency. More...
 
uint32_t SCG_HAL_GetRtcClkInFreq (SCG_Type *base)
 Get SCG RTC CLKIN clock frequency. More...
 

Variables

uint32_t g_xtal0ClkFreq
 
uint32_t g_RtcClkInFreq
 

System Clock.

enum  scg_system_clock_type_t { SCG_SYSTEM_CLOCK_CORE, SCG_SYSTEM_CLOCK_BUS, SCG_SYSTEM_CLOCK_SLOW, SCG_SYSTEM_CLOCK_MAX }
 SCG system clock type. Implements scg_system_clock_type_t_Class. More...
 
enum  scg_system_clock_src_t {
  SCG_SYSTEM_CLOCK_SRC_SYS_OSC = 1U, SCG_SYSTEM_CLOCK_SRC_SIRC = 2U, SCG_SYSTEM_CLOCK_SRC_FIRC = 3U, SCG_SYSTEM_CLOCK_SRC_SYS_PLL = 6U,
  SCG_SYSTEM_CLOCK_SRC_NONE
}
 SCG system clock source. Implements scg_system_clock_src_t_Class. More...
 
enum  scg_system_clock_mode_t {
  SCG_SYSTEM_CLOCK_MODE_CURRENT = 0U, SCG_SYSTEM_CLOCK_MODE_RUN = 1U, SCG_SYSTEM_CLOCK_MODE_VLPR = 2U, SCG_SYSTEM_CLOCK_MODE_HSRUN = 3U,
  SCG_SYSTEM_CLOCK_MODE_NONE
}
 SCG system clock modes. Implements scg_system_clock_mode_t_Class. More...
 
enum  scg_system_clock_div_t {
  SCG_SYSTEM_CLOCK_DIV_BY_1 = 0U, SCG_SYSTEM_CLOCK_DIV_BY_2 = 1U, SCG_SYSTEM_CLOCK_DIV_BY_3 = 2U, SCG_SYSTEM_CLOCK_DIV_BY_4 = 3U,
  SCG_SYSTEM_CLOCK_DIV_BY_5 = 4U, SCG_SYSTEM_CLOCK_DIV_BY_6 = 5U, SCG_SYSTEM_CLOCK_DIV_BY_7 = 6U, SCG_SYSTEM_CLOCK_DIV_BY_8 = 7U,
  SCG_SYSTEM_CLOCK_DIV_BY_9 = 8U, SCG_SYSTEM_CLOCK_DIV_BY_10 = 9U, SCG_SYSTEM_CLOCK_DIV_BY_11 = 10U, SCG_SYSTEM_CLOCK_DIV_BY_12 = 11U,
  SCG_SYSTEM_CLOCK_DIV_BY_13 = 12U, SCG_SYSTEM_CLOCK_DIV_BY_14 = 13U, SCG_SYSTEM_CLOCK_DIV_BY_15 = 14U, SCG_SYSTEM_CLOCK_DIV_BY_16 = 15U
}
 SCG system clock divider value. Implements scg_system_clock_div_t_Class. More...
 
status_t SCG_HAL_SetSystemClockConfig (SCG_Type *base, scg_system_clock_mode_t mode, scg_system_clock_config_t const *config)
 Set the system clock configuration in specified mode. More...
 
void SCG_HAL_GetSystemClockConfig (const SCG_Type *base, scg_system_clock_mode_t mode, scg_system_clock_config_t *config)
 Get the system clock configuration for specified mode. More...