Simplifying microseconds <-> clock cycles conversions. (Rob Tillaart)
This should fix problems with overflows in pulseIn(). It may make millis() slightly less precise for clock speeds that aren't multiple of 1 million, but we don't really support those anyway. http://code.google.com/p/arduino/issues/detail?id=675
This commit is contained in:
parent
5184064486
commit
3ece2827a4
|
@ -73,8 +73,8 @@ extern "C"{
|
||||||
#define noInterrupts() cli()
|
#define noInterrupts() cli()
|
||||||
|
|
||||||
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
||||||
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
|
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
|
||||||
#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
|
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
|
||||||
|
|
||||||
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
||||||
#define highByte(w) ((uint8_t) ((w) >> 8))
|
#define highByte(w) ((uint8_t) ((w) >> 8))
|
||||||
|
|
Loading…
Reference in New Issue