73 lines
2.5 KiB
C
73 lines
2.5 KiB
C
/*!
|
|
* \file clock.c
|
|
*
|
|
* \brief Target clock implementation
|
|
*
|
|
* \copyright Revised BSD License, see section \ref LICENSE.
|
|
*
|
|
* \code
|
|
*
|
|
* _ __ _ ________ _
|
|
* | |/ /(_)___ / ____/ /_ (_)___
|
|
* | // / __ \/ / / __ \/ / __ \
|
|
* / |/ / / / / /___/ / / / / /_/ /
|
|
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
|
* /_/
|
|
* (C) 2022-2025 XinChip
|
|
*
|
|
* \endcode
|
|
*
|
|
* \author ( XinChip ) Alex-J
|
|
*
|
|
* \author ( XinChip )
|
|
*/
|
|
|
|
/*-----------------------------------------------------------------------------------
|
|
INCLUDE HEADE FILES
|
|
------------------------------------------------------------------------------------*/
|
|
#include "clock.h"
|
|
#include "xc_drv_clock.h"
|
|
|
|
/*------------------------------------------------------------------------------------
|
|
Macros
|
|
-------------------------------------------------------------------------------------*/
|
|
|
|
/*------------------------------------------------------------------------------------
|
|
Global Variables
|
|
-------------------------------------------------------------------------------------*/
|
|
|
|
/*------------------------------------------------------------------------------------
|
|
Func Prototype
|
|
-------------------------------------------------------------------------------------*/
|
|
|
|
/*------------------------------------------------------------------------------------
|
|
Functions
|
|
-------------------------------------------------------------------------------------*/
|
|
/**
|
|
****************************************************************************************
|
|
* @brief
|
|
*
|
|
* @param[in]
|
|
* @param[in]
|
|
****************************************************************************************
|
|
*/
|
|
void clock_init(void)
|
|
{
|
|
CLOCK_InitCfg_t clock_cfg;
|
|
|
|
clock_cfg.hfclk_src = CLOCK_HFCLK_SRC_XTAL;
|
|
clock_cfg.hfclk_in = CLOCK_HFCLK_IN_64M;
|
|
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_RC;
|
|
|
|
if(clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_XTAL) {
|
|
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32768;
|
|
} else if(clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_RC) {
|
|
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32K;
|
|
}
|
|
|
|
xc_clock_init_cfg(&clock_cfg);
|
|
|
|
SysTick_Config(xc_clock_hfclk_in_get( ) / 100);
|
|
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
|
}
|