V1.0
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/*!
|
||||
* \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 "xc6xxx_hal_clock.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief clock_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void clock_init(void) {
|
||||
CLOCK_CtrlBlock_Typedef clock_cb;
|
||||
|
||||
clock_cb.hfclk_src = CLOCK_HFCLK_SRC_XTAL;
|
||||
clock_cb.hfclk_in = CLOCK_HFCLK_IN_32M;
|
||||
|
||||
clock_cb.lfclk_src = CLOCK_LFCLK_SRC_RC;
|
||||
|
||||
if (clock_cb.lfclk_src == CLOCK_LFCLK_SRC_XTAL) {
|
||||
clock_cb.lfclk_in = CLOCK_XTAL_LFCLK_IN_32K;
|
||||
} else if (clock_cb.lfclk_src == CLOCK_LFCLK_SRC_RC) {
|
||||
clock_cb.lfclk_in = CLOCK_RC_LFCLK_IN_32K;
|
||||
}
|
||||
// Clock Initialization
|
||||
CLOCK_Init(clock_cb);
|
||||
// Systick Configuration
|
||||
SysTick_Config(CLOCK_HighFreq_Get() / 100);
|
||||
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
||||
}
|
||||
Reference in New Issue
Block a user