mirror of
				https://github.com/esp8266/Arduino.git
				synced 2025-11-03 14:33:37 +03:00 
			
		
		
		
	Servo: use peripheral clock frequency when calculating FRC1 tick count (#1789)
This commit is contained in:
		@@ -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)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user