初始化提交

This commit is contained in:
王立帮
2024-07-20 22:09:06 +08:00
commit c247dd07a6
6876 changed files with 2743096 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
#include "compatibility.h"
static struct timeval start, end;
//static long mtime, seconds, useconds;
/**********************************************************************/
/**
* This function is added in order to simulate arduino delay() function
* @param milisec
*/
void __msleep(int milisec)
{
struct timespec req = {0};
req.tv_sec = 0;
req.tv_nsec = milisec * 1000000L;
nanosleep(&req, (struct timespec*) NULL);
//usleep(milisec*1000);
}
void __usleep(int milisec)
{
struct timespec req = {0};
req.tv_sec = 0;
req.tv_nsec = milisec * 1000L;
nanosleep(&req, (struct timespec*) NULL);
//usleep(milisec);
}
/**
* This function is added in order to simulate arduino millis() function
*/
void __start_timer()
{
gettimeofday(&start, NULL);
}
long __millis()
{
static long mtime, seconds, useconds;
gettimeofday(&end, NULL);
seconds = end.tv_sec - start.tv_sec;
useconds = end.tv_usec - start.tv_usec;
mtime = ((seconds) * 1000 + useconds / 1000.0) + 0.5;
return mtime;
}