提交SMOD ATSC IMX APP版本 V122
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
/*************************************************************************
|
||||
系统延时相关函数
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
#include "stm32f4xx.h"
|
||||
#include "type.h"
|
||||
#include "os_task.h"
|
||||
#include "FreeRTOS.h"
|
||||
*/
|
||||
#include "../inc/type.h"
|
||||
#include "../inc/delay.h"
|
||||
#include "../inc/isys_com.h"
|
||||
|
||||
#include <unistd.h>
|
||||
extern volatile uint32 sys_ready;
|
||||
//extern SYS_TASK sys_task;
|
||||
|
||||
void delay_ms(uint32 nms)
|
||||
{
|
||||
|
||||
usleep(nms*1000);
|
||||
}
|
||||
|
||||
void delay_us(uint32 nus)
|
||||
{
|
||||
uint32 index = 0;
|
||||
//系统钟168M, 循环一次4条指令, 42*4 = 168 约为1us
|
||||
//系统钟396M, 循环一次4条指令, 99*4 = 396 约为1us
|
||||
//for(index = (42 * nus); index != 0; index--)
|
||||
for(index = (99 * nus); index != 0; index--)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
//usleep(nus);
|
||||
}
|
||||
|
||||
void idelay_us(uint32 nus)
|
||||
{
|
||||
usleep(nus);
|
||||
}
|
||||
|
||||
/*
|
||||
void delay_us(uint32 nus)
|
||||
{
|
||||
uint32 index = 0;
|
||||
//系统钟168M, 循环一次4条指令, 42*4 = 168 约为1us
|
||||
for(index = (42 * nus); index != 0; index--)
|
||||
{
|
||||
;
|
||||
}
|
||||
}*/
|
||||
|
||||
uint32 check_delay_over(uint32 *ptick,uint32 cycle)
|
||||
{
|
||||
|
||||
unsigned long tick_bak = get_sys_tick();
|
||||
//printf("cur_tick =%d\n",tick_bak);
|
||||
if((*ptick)+cycle>tick_bak)//延时还没到。
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*ptick=get_sys_tick();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
void delay_ticks(uint32 ticks)
|
||||
{
|
||||
if(!ticks)
|
||||
return;
|
||||
|
||||
/*if(sys_ready)
|
||||
{
|
||||
vTaskDelay(ticks);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 index = 0;
|
||||
|
||||
for(index = (41000 * OS_PER_TICK_MS*ticks); index != 0; index--)
|
||||
{
|
||||
;
|
||||
}
|
||||
}*/
|
||||
|
||||
delay_ms(ticks*10);
|
||||
}
|
||||
|
||||
void task_delay(uint32 nms)
|
||||
{
|
||||
uint32 task_id;
|
||||
|
||||
/*if(!sys_ready)
|
||||
{
|
||||
delay_ms(nms);
|
||||
}
|
||||
get_current_task_id(&task_id);
|
||||
if(task_id>=MAX_TASK)
|
||||
return;
|
||||
|
||||
sys_task.pause[task_id] = (nms+999)/1000; //转换为秒
|
||||
vTaskDelay((nms +(OS_PER_TICK_MS-1)) / OS_PER_TICK_MS); //转化为tick值 处理结果,向上对齐 最小时间为10ms
|
||||
sys_task.pause[task_id] = 0;
|
||||
*/
|
||||
usleep(nms*1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user