forked from greiman/SdFat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SysCall.h
83 lines (82 loc) · 2.28 KB
/
SysCall.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* FatLib Library
* Copyright (C) 2013 by William Greiman
*
* This file is part of the FatLib Library
*
* This Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the FatLib Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef SysCall_h
#define SysCall_h
/**
* \file
* \brief SysCall class
*/
#if defined(ARDUINO)
#include <Arduino.h>
#include <SPI.h>
#elif defined(PLATFORM_ID) // Only defined if a Particle device
#include "application.h"
#else // defined(ARDUINO)
#error "Unknown system"
#endif // defined(ARDUINO)
//-----------------------------------------------------------------------------
#ifdef ESP8266
// undefine F macro if ESP8266.
#undef F
#endif // ESP8266
//-----------------------------------------------------------------------------
#ifndef F
/** Define macro for strings stored in flash. */
#define F(str) (str)
#endif // F
//-----------------------------------------------------------------------------
/** \return the time in milliseconds. */
inline uint16_t curTimeMS() {
return millis();
}
//-----------------------------------------------------------------------------
/**
* \class SysCall
* \brief SysCall - Class to wrap system calls.
*/
class SysCall {
public:
/** Halt execution of this thread. */
static void halt() {
while (1) {
yield();
}
}
/** Yield to other threads. */
static void yield();
};
#if defined(ESP8266)
inline void SysCall::yield() {
// Avoid ESP8266 bug
delay(0);
}
#elif defined(ARDUINO)
inline void SysCall::yield() {
// Use the external Arduino yield() function.
::yield();
}
#elif defined(PLATFORM_ID) // Only defined if a Particle device
inline void SysCall::yield() {
Particle.process();
}
#else // ESP8266
inline void SysCall::yield() {}
#endif // ESP8266
#endif // SysCall_h