Files
hpw421/component/xc6xx_drivers/Drivers/xc_driver/xc_drv_clock.h
T
2026-06-06 16:49:48 +08:00

114 lines
3.4 KiB
C

/*!
* \file xc_drv_clock.h
*
* \brief The header of xc_drv_clock.c
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
*
* _ __ _ ________ _
* | |/ /(_)___ / ____/ /_ (_)___
* | // / __ \/ / / __ \/ / __ \
* / |/ / / / / /___/ / / / / /_/ /
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
* /_/
* (C) 2022-2025 XinChip
*
* \endcode
*
* \author ( XinChip ) Alex-J
*
* \author ( XinChip )
*/
#ifndef _XC_DRV_CLOCK_H_
#define _XC_DRV_CLOCK_H_
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include <stdbool.h>
#include <stdio.h>
#include "xc6xxx.h"
/*------------------------------------------------------------------------------------
Macros
-------------------------------------------------------------------------------------*/
#define CLOCK_SRC_OSC32M 0x00
#define CLOCK_SRC_BBPLL 0x01
#define CLOCK_SRC_BBPLL_DIV 0x02
#define CLOCK_SRC_RC16M 0x03
/*------------------------------------------------------------------------------------
TypeDef
-------------------------------------------------------------------------------------*/
typedef enum
{
CLOCK_LFCLK_SRC_RC = 0, /* Internal 32 KHz RC oscillator. */
CLOCK_LFCLK_SRC_XTAL = 1, /* External 32 KHz crystal oscillator. */
} CLOCK_LFCLK_Src_Typedef;
typedef enum
{
CLOCK_LFCLK_IN_32K = 32000,
CLOCK_LFCLK_IN_32768 = 32768,
} CLOCK_LFCLK_In_Typedef;
typedef enum
{
CLOCK_HFCLK_SRC_RC = 0, /* Internal 16 MHz RC oscillator. */
CLOCK_HFCLK_SRC_XTAL = 1, /* External 32 MHz crystal oscillator. */
} CLOCK_HFCLK_Src_Typedef;
typedef enum
{
CLOCK_HFCLK_IN_16M = 16000000,
CLOCK_HFCLK_IN_32M = 32000000,
CLOCK_HFCLK_IN_48M = 48000000,
CLOCK_HFCLK_IN_64M = 64000000,
CLOCK_HFCLK_IN_96M = 96000000,
CLOCK_HFCLK_IN_128M = 128000000,
} CLOCK_HFCLK_In_Typedef;
typedef enum
{
SYSTICK_UNIT_IN_16M = 16,
SYSTICK_UNIT_IN_32M = 32,
SYSTICK_UNIT_IN_48M = 48,
SYSTICK_UNIT_IN_64M = 64,
SYSTICK_UNIT_IN_96M = 96
} Systick_Unit_Typedef;
typedef struct
{
CLOCK_HFCLK_Src_Typedef hfclk_src;
CLOCK_HFCLK_In_Typedef hfclk_in;
CLOCK_LFCLK_Src_Typedef lfclk_src;
CLOCK_LFCLK_In_Typedef lfclk_in;
Systick_Unit_Typedef systick_unit;
} CLOCK_InitCfg_t;
/*------------------------------------------------------------------------------------
Global Variables
-------------------------------------------------------------------------------------*/
extern CLOCK_InitCfg_t clock_cb;
/*------------------------------------------------------------------------------------
Exported Functions
-------------------------------------------------------------------------------------*/
void xc_clock_bbpll_common_cfg(void);
void xc_clock_init_cfg(CLOCK_InitCfg_t *clock_cfg);
CLOCK_HFCLK_In_Typedef xc_clock_hfclk_in_get(void);
CLOCK_LFCLK_In_Typedef xc_clock_lfclk_in_get(void);
CLOCK_HFCLK_Src_Typedef xc_clock_hfclk_src_get(void);
CLOCK_LFCLK_Src_Typedef xc_clock_lfclk_src_get(void);
Systick_Unit_Typedef xc_systick_unit_get(void);
#endif // _XC_DRV_CLOCK_H_