仓库迁移
This commit is contained in:
45
source/soft/mymisc.c
Normal file
45
source/soft/mymisc.c
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "rtthread.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdint.h"
|
||||
#include "stdio.h"
|
||||
|
||||
|
||||
typedef struct{
|
||||
void (*later_fun)(void *t);
|
||||
void *t;
|
||||
rt_timer_t timer;
|
||||
}later_def;
|
||||
|
||||
|
||||
static void later_fun_exe(void *t)
|
||||
{
|
||||
later_def *l=t;
|
||||
rt_timer_delete(l->timer);
|
||||
if(l->later_fun){
|
||||
l->later_fun(l->t);
|
||||
}
|
||||
free(l);
|
||||
}
|
||||
|
||||
// 延迟一段时间调用函数
|
||||
void later_execute(void (*fun)(void *t),void *t,int ms)
|
||||
{
|
||||
static uint16_t count;
|
||||
char s1[16]={0};
|
||||
sprintf(s1,"later_t#%d",count);
|
||||
later_def *l=calloc(1,sizeof(later_def));
|
||||
l->later_fun=fun;
|
||||
l->t=t;
|
||||
l->timer=rt_timer_create(s1,later_fun_exe,l,
|
||||
rt_tick_from_millisecond(ms),
|
||||
RT_TIMER_FLAG_ONE_SHOT|RT_TIMER_FLAG_SOFT_TIMER);
|
||||
rt_timer_start(l->timer);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user