[ch32][risc-v][bsp] update drv_common for wch risc-v bsp
This commit is contained in:
parent
7d8f485321
commit
1104b80a4d
|
@ -1,28 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2023-06-14 muaxiaohei first version
|
* 2023-06-14 muaxiaohei first version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include "drv_common.h"
|
#include "drv_common.h"
|
||||||
|
|
||||||
void rt_hw_us_delay(rt_uint32_t us)
|
#define DBG_TAG "drv.common"
|
||||||
{
|
#define DBG_LVL DBG_INFO
|
||||||
uint64_t total_delay_ticks, us_ticks, start, now, delta, reload;
|
#include <rtdbg.h>
|
||||||
|
|
||||||
start = SysTick->CNT;
|
void rt_hw_us_delay(rt_uint32_t us)
|
||||||
reload = SysTick->CMP;
|
{
|
||||||
us_ticks = SystemCoreClock / 8000000UL;
|
rt_uint64_t total_delay_ticks, us_ticks, start, now, delta, reload;
|
||||||
total_delay_ticks = (uint32_t)us * us_ticks;
|
|
||||||
RT_ASSERT(total_delay_ticks < reload);
|
start = SysTick->CNT;
|
||||||
|
reload = SysTick->CMP;
|
||||||
do{
|
us_ticks = SystemCoreClock / 8000000UL;
|
||||||
now = SysTick->CNT;
|
total_delay_ticks = us * us_ticks;
|
||||||
delta = start > now ? start - now : reload + start - now;
|
if (total_delay_ticks >= reload)
|
||||||
}while(delta < total_delay_ticks);
|
{
|
||||||
}
|
LOW_E("rt_hw_us_delay: the us parameter exceeds the maximum limit!");
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
now = SysTick->CNT;
|
||||||
|
delta = start > now ? start - now : reload + start - now;
|
||||||
|
} while(delta < total_delay_ticks);
|
||||||
|
}
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2023-06-14 muaxiaohei first version
|
* 2023-06-14 muaxiaohei first version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __DRV_COMMON_H__
|
#ifndef __DRV_COMMON_H__
|
||||||
#define __DRV_COMMON_H__
|
#define __DRV_COMMON_H__
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rt_hw_us_delay(rt_uint32_t us);
|
void rt_hw_us_delay(rt_uint32_t us);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue