1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Servo: use peripheral clock frequency when calculating FRC1 tick count (#1789)

This commit is contained in:
Ivan Grokhotkov 2016-03-24 01:48:23 +03:00
parent 3d3c928e2e
commit 633e48f3ae

View File

@ -126,6 +126,8 @@ private:
#if !defined (SERVO_EXCLUDE_TIMER1) #if !defined (SERVO_EXCLUDE_TIMER1)
#define TIMER1_TICKS_PER_US (APB_CLK_FREQ / 1000000L)
struct ServoTimer1 struct ServoTimer1
{ {
public: public:
@ -137,11 +139,11 @@ public:
uint32_t usToTicks(uint32_t us) const uint32_t usToTicks(uint32_t us) const
{ {
return (clockCyclesPerMicrosecond() / 16 * us); // converts microseconds to tick return (TIMER1_TICKS_PER_US / 16 * us); // converts microseconds to tick
} }
uint32_t ticksToUs(uint32_t ticks) const uint32_t ticksToUs(uint32_t ticks) const
{ {
return (ticks / clockCyclesPerMicrosecond() * 16); // converts from ticks back to microseconds return (ticks / TIMER1_TICKS_PER_US * 16); // converts from ticks back to microseconds
} }
void InitInterrupt(timercallback handler) void InitInterrupt(timercallback handler)