|
17 | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | 18 | */ |
19 | 19 |
|
20 | | -#ifndef _WIRING_ |
21 | | -#define _WIRING_ |
| 20 | +#ifndef _WIRING_H_ |
| 21 | +#define _WIRING_H_ |
22 | 22 |
|
23 | | -#ifdef __cplusplus |
24 | | -extern "C" { |
25 | | -#endif |
| 23 | +#include <stdint.h> |
| 24 | +#include <stdlib.h> |
| 25 | +#include <stdbool.h> |
| 26 | +#include <string.h> |
| 27 | +#include <math.h> |
26 | 28 |
|
27 | | -/** |
28 | | - * |
29 | | - */ |
30 | | -extern void initVariant( void ) ; |
31 | | -extern void init( void ) ; |
| 29 | +#include "binary.h" |
| 30 | +#include "itoa.h" |
32 | 31 |
|
33 | | -/** |
34 | | - * \brief Returns the number of milliseconds since the Arduino board began running the current program. |
35 | | - * |
36 | | - * This number will overflow (go back to zero), after approximately 50 days. |
37 | | - * |
38 | | - * \return Number of milliseconds since the program started (uint32_t) |
39 | | - */ |
40 | | -extern uint32_t millis( void ) ; |
| 32 | +#ifdef __cplusplus |
| 33 | +extern "C"{ |
| 34 | +#endif // __cplusplus |
| 35 | +#include <board.h> |
| 36 | +#ifdef __cplusplus |
| 37 | +} |
| 38 | +#endif |
41 | 39 |
|
42 | | -/** |
43 | | - * \brief Returns the number of microseconds since the Arduino board began running the current program. |
44 | | - * |
45 | | - * This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards |
46 | | - * (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is |
47 | | - * always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution |
48 | | - * of eight microseconds. |
49 | | - * |
50 | | - * \note There are 1,000 microseconds in a millisecond and 1,000,000 microseconds in a second. |
51 | | - */ |
52 | | -extern uint32_t micros( void ) ; |
| 40 | +#include "wiring_analog.h" |
| 41 | +#include "wiring_constants.h" |
| 42 | +#include "wiring_digital.h" |
| 43 | +#include "wiring_pulse.h" |
| 44 | +#include "wiring_shift.h" |
| 45 | +#include "wiring_time.h" |
| 46 | +#include "WInterrupts.h" |
53 | 47 |
|
54 | | -/** |
55 | | - * \brief Pauses the program for the amount of time (in miliseconds) specified as parameter. |
56 | | - * (There are 1000 milliseconds in a second.) |
57 | | - * |
58 | | - * \param dwMs the number of milliseconds to pause (uint32_t) |
59 | | - */ |
60 | | -extern void delay( uint32_t dwMs ) ; |
| 48 | +#ifdef __cplusplus |
| 49 | +#include "HardwareSerial.h" |
| 50 | +#include "Tone.h" |
| 51 | +#include "WCharacter.h" |
| 52 | +#include "WMath.h" |
| 53 | +#include "WString.h" |
| 54 | +#endif // __cplusplus |
61 | 55 |
|
62 | | -/** |
63 | | - * \brief Pauses the program for the amount of time (in microseconds) specified as parameter. |
64 | | - * |
65 | | - * \param dwUs the number of microseconds to pause (uint32_t) |
66 | | - */ |
67 | | -static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused)); |
68 | | -static inline void delayMicroseconds(uint32_t usec){ |
69 | | - uint32_t start = GetCurrentMicro(); |
| 56 | +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) |
| 57 | +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) |
| 58 | +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) |
70 | 59 |
|
71 | | - while((start+usec) > GetCurrentMicro()); |
72 | | -} |
73 | 60 |
|
74 | | -#ifdef __cplusplus |
75 | | -} |
76 | | -#endif |
77 | 61 |
|
78 | | -#endif /* _WIRING_ */ |
| 62 | +#endif /* _WIRING_H_ */ |
0 commit comments