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.
millis.h@1:d1b960698e70, 2015-03-26 (annotated)
- Committer:
- eduardoG26
- Date:
- Thu Mar 26 14:21:36 2015 +0000
- Revision:
- 1:d1b960698e70
- Parent:
- 0:571ea8a1bbae
20150326
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 | 1:d1b960698e70 | 25 | // millis() as in Arduino... |
eduardoG26 | 0:571ea8a1bbae | 26 | |
eduardoG26 | 0:571ea8a1bbae | 27 | #ifndef MILLIS_H_ |
eduardoG26 | 0:571ea8a1bbae | 28 | #define MILLIS_H_ |
eduardoG26 | 0:571ea8a1bbae | 29 | |
eduardoG26 | 0:571ea8a1bbae | 30 | #include "mbed.h" |
eduardoG26 | 1:d1b960698e70 | 31 | #include "project.h" |
eduardoG26 | 0:571ea8a1bbae | 32 | |
eduardoG26 | 0:571ea8a1bbae | 33 | // Get millis value similar to arduino |
eduardoG26 | 0:571ea8a1bbae | 34 | uint32_t millis (); |
eduardoG26 | 0:571ea8a1bbae | 35 | |
eduardoG26 | 1:d1b960698e70 | 36 | // Must be called to start milliseconds timer! |
eduardoG26 | 0:571ea8a1bbae | 37 | void StartMillis (); |
eduardoG26 | 0:571ea8a1bbae | 38 | |
eduardoG26 | 0:571ea8a1bbae | 39 | #endif // See #ifndef MILLIS_H_ |
eduardoG26 | 0:571ea8a1bbae | 40 | // End of file |