Arduino functions millis, micros and eventually some more to come
Dependents: DigitalCamera_OV5642_WIZwiki-W7500 BMC F746NG_TestAll Prelude_OV5642_dev
Arduino basic compatibility millis(), micros(), evtl. more to come.
micros() and millis() are uint32_t and have a correct overflow at 2^32-1. micros() has a granularity/resolution of 50. This can be changed by a define. 1 microsecond is not realistic because every count needs an irq. A resolution of 50 microseconds means 20KHz irq. That should not take away more than 1 percent overall processing time.
Arduino.h@3:abbc3308dfa1, 2015-03-30 (annotated)
- Committer:
- eduardoG26
- Date:
- Mon Mar 30 13:50:18 2015 +0000
- Revision:
- 3:abbc3308dfa1
- Parent:
- 2:215810c8e89e
TICKER_PERIOD_US changed to 50
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eduardoG26 | 1:d1b960698e70 | 1 | /* |
eduardoG26 | 1:d1b960698e70 | 2 | The MIT License (MIT) |
eduardoG26 | 1:d1b960698e70 | 3 | |
eduardoG26 | 1:d1b960698e70 | 4 | Copyright (c) 2014 calima engineering |
eduardoG26 | 1:d1b960698e70 | 5 | |
eduardoG26 | 1:d1b960698e70 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
eduardoG26 | 1:d1b960698e70 | 7 | of this software and associated documentation files (the "Software"), to deal |
eduardoG26 | 1:d1b960698e70 | 8 | in the Software without restriction, including without limitation the rights |
eduardoG26 | 1:d1b960698e70 | 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
eduardoG26 | 1:d1b960698e70 | 10 | copies of the Software, and to permit persons to whom the Software is |
eduardoG26 | 1:d1b960698e70 | 11 | furnished to do so, subject to the following conditions: |
eduardoG26 | 1:d1b960698e70 | 12 | |
eduardoG26 | 1:d1b960698e70 | 13 | The above copyright notice and this permission notice shall be included in |
eduardoG26 | 1:d1b960698e70 | 14 | all copies or substantial portions of the Software. |
eduardoG26 | 1:d1b960698e70 | 15 | |
eduardoG26 | 1:d1b960698e70 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
eduardoG26 | 1:d1b960698e70 | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
eduardoG26 | 1:d1b960698e70 | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
eduardoG26 | 1:d1b960698e70 | 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
eduardoG26 | 1:d1b960698e70 | 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
eduardoG26 | 1:d1b960698e70 | 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
eduardoG26 | 1:d1b960698e70 | 22 | THE SOFTWARE. |
eduardoG26 | 1:d1b960698e70 | 23 | */ |
eduardoG26 | 1:d1b960698e70 | 24 | |
eduardoG26 | 2:215810c8e89e | 25 | #ifndef ARDUINO_H_ |
eduardoG26 | 2:215810c8e89e | 26 | #define ARDUINO_H_ |
eduardoG26 | 0:571ea8a1bbae | 27 | |
eduardoG26 | 0:571ea8a1bbae | 28 | #include "mbed.h" |
eduardoG26 | 0:571ea8a1bbae | 29 | |
eduardoG26 | 0:571ea8a1bbae | 30 | // Get millis value similar to arduino |
eduardoG26 | 0:571ea8a1bbae | 31 | uint32_t millis (); |
eduardoG26 | 0:571ea8a1bbae | 32 | |
eduardoG26 | 2:215810c8e89e | 33 | // Get micros value similar to arduino |
eduardoG26 | 2:215810c8e89e | 34 | uint32_t micros (); |
eduardoG26 | 2:215810c8e89e | 35 | |
eduardoG26 | 2:215810c8e89e | 36 | // Must be called to start timer! |
eduardoG26 | 2:215810c8e89e | 37 | void StartArduinoTimer (); |
eduardoG26 | 0:571ea8a1bbae | 38 | |
eduardoG26 | 2:215810c8e89e | 39 | /** Macro for delay() |
eduardoG26 | 2:215810c8e89e | 40 | * |
eduardoG26 | 2:215810c8e89e | 41 | * @param void |
eduardoG26 | 2:215810c8e89e | 42 | */ |
eduardoG26 | 2:215810c8e89e | 43 | #define delay(x) (wait_ms(x)) |
eduardoG26 | 2:215810c8e89e | 44 | /** Macro for delayMicroseconds() |
eduardoG26 | 2:215810c8e89e | 45 | * |
eduardoG26 | 2:215810c8e89e | 46 | * @param void |
eduardoG26 | 2:215810c8e89e | 47 | */ |
eduardoG26 | 2:215810c8e89e | 48 | #define delayMicroseconds(x) (wait_us(x)) |
eduardoG26 | 2:215810c8e89e | 49 | |
eduardoG26 | 2:215810c8e89e | 50 | #endif // See #ifndef ARDUINO_H_ |
eduardoG26 | 0:571ea8a1bbae | 51 | // End of file |