hpw422移植新的sdk
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* \file xc_drv_systick.c
|
||||
*
|
||||
* \brief Target xinchip systick driver 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 "xc_drv_systick.h"
|
||||
#include "xc_drv_clock.h"
|
||||
#if XC_CHECK(XC_SYSTICK_ENABLED)
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
void SysTick_Handler(void) { systick_callback(); }
|
||||
|
||||
void delay_us(uint32_t nus)
|
||||
{
|
||||
if (nus == 0)
|
||||
return;
|
||||
|
||||
uint32_t unit = xc_systick_unit_get();
|
||||
|
||||
uint32_t temp;
|
||||
|
||||
SysTick->CTRL = 0x00; // 关闭计数器
|
||||
SysTick->LOAD = unit * nus - unit + 1;
|
||||
|
||||
SysTick->VAL = 0;
|
||||
SysTick->CTRL = 0x05;
|
||||
|
||||
do {
|
||||
temp = SysTick->CTRL; // 读取当前倒计数值
|
||||
} while ((temp & 0x01) && (!(temp & (1 << 16))));
|
||||
}
|
||||
|
||||
void delay_ms(uint32_t nms)
|
||||
{
|
||||
if (nms == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
delay_us(1000);
|
||||
} while (--nms);
|
||||
}
|
||||
|
||||
__WEAK void systick_callback(void) {}
|
||||
#endif // XC_CHECK(XC_SYSTICK_ENABLED)
|
||||
Reference in New Issue
Block a user