1 Star 0 Fork 1

WilliamArthur / csi_pangu

forked from yocop / csi_pangu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lib.c 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
shuke 提交于 2020-05-14 14:07 . init version
/*
* Copyright (C) 2017-2019 Alibaba Group Holding Limited
*/
/******************************************************************************
* @file lib.c
* @brief source file for the lib
* @version V1.0
* @date 02. June 2017
* @vendor csky
* @chip pangu
******************************************************************************/
#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>
#include "csi_core.h"
#include "soc.h"
#include <sys_freq.h>
extern uint32_t csi_coret_get_load(void);
extern uint32_t csi_coret_get_value(void);
extern int32_t drv_get_cpu_id(void);
static void _500udelay(void)
{
uint32_t load = csi_coret_get_load();
uint32_t start = csi_coret_get_value();
uint32_t cur;
uint32_t cnt = (drv_get_cur_cpu_freq() / 1000 / 2);
while (1) {
cur = csi_coret_get_value();
if (start > cur) {
if (start - cur >= cnt) {
return;
}
} else {
if (load - cur + start > cnt) {
return;
}
}
}
}
void mdelay(uint32_t ms)
{
while (ms--) {
_500udelay();
_500udelay();
}
}
static void _10udelay(void)
{
uint32_t load = csi_coret_get_load();
uint32_t start = csi_coret_get_value();
uint32_t cnt = (drv_get_sys_freq() / 1000 / 100);
while (1) {
uint32_t cur = csi_coret_get_value();
if (start > cur) {
if (start - cur >= cnt) {
return;
}
} else {
if (load - cur + start > cnt) {
return;
}
}
}
}
void udelay(uint32_t us)
{
us = (us / 10);
if (us == 0) {
return;
}
while (us--) {
_10udelay();
}
}
1
https://gitee.com/st-lucifer/csi_pangu.git
git@gitee.com:st-lucifer/csi_pangu.git
st-lucifer
csi_pangu
csi_pangu
master

搜索帮助