mirror of
https://github.com/digistump/DigistumpArduino.git
synced 2025-09-18 01:42:26 -07:00
switch to setup for Arduino Boards Manager
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
|
||||
#include "compatibility.h"
|
||||
/**********************************************************************/
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
void __usleep(int milisec)
|
||||
{
|
||||
struct timespec req = {0};
|
||||
req.tv_sec = 0;
|
||||
req.tv_nsec = milisec * 1000L;
|
||||
nanosleep(&req, (struct timespec *)NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is added in order to simulate arduino millis() function
|
||||
*/
|
||||
void __start_timer()
|
||||
{
|
||||
gettimeofday(&start, NULL);
|
||||
}
|
||||
|
||||
long __millis()
|
||||
{
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user