This commit is contained in:
moyuhai
2026-06-09 16:39:17 +08:00
commit 41a602f89c
3057 changed files with 771495 additions and 0 deletions
@@ -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;
}
@@ -0,0 +1,62 @@
/*!
* \file clock.h
*
* \brief The head file of clock.c
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
*
* _ __ _ ________ _
* | |/ /(_)___ / ____/ /_ (_)___
* | // / __ \/ / / __ \/ / __ \
* / |/ / / / / /___/ / / / / /_/ /
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
* /_/
* (C) 2022-2025 XinChip
*
* \endcode
*
* \author ( XinChip ) Alex-J
*
* \author ( XinChip )
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CLOCK_H__
#define __CLOCK_H__
#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
/*------------------------------------------------------------------------------------
Macros
-------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
TypeDef
-------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
Global Variables
-------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------
Exported Functions
-------------------------------------------------------------------------------------*/
void clock_init(void);
#ifdef __cplusplus
}
#endif
#endif /* __CLOCK_H__ */