Firmware changes to match rewired control board.
This is a bit more difficult than just reassigning pins as the usage of the timers has changed to the point of using 16 bit timers where 32 bit timers would have been ideal. This makes the use of the prescaler necessary, and we need to cope with a different prescaler value being used on different timers.
This commit is contained in:
19
timer.h
19
timer.h
@@ -4,12 +4,17 @@
|
||||
#include "types.h"
|
||||
|
||||
#define TIMER_PCLK 14745600
|
||||
#define TIMER_PRESCALE 0
|
||||
#define TIMER_PRESCALE 9215
|
||||
#define TIMER0_PRESCALE 0
|
||||
|
||||
#define TIMER_SECOND (TIMER_PCLK/(TIMER_PRESCALE+1))
|
||||
#define TIMER_MS (TIMER_SECOND/1000)
|
||||
#define TIMER_US (TIMER_SECOND/1000000)
|
||||
|
||||
#define TIMER0_SECOND (TIMER_PCLK/(TIMER0_PRESCALE+1))
|
||||
#define TIMER0_MS (TIMER0_SECOND/1000)
|
||||
#define TIMER0_US (TIMER0_SECOND/1000000)
|
||||
|
||||
#define PWM_MAX 14745
|
||||
#if 0
|
||||
#define PWM_PERIOD 58980
|
||||
@@ -21,8 +26,8 @@
|
||||
|
||||
#define TIMER_CH(x) (timer_map[x])
|
||||
|
||||
extern volatile unsigned int timer1_width[];
|
||||
extern volatile unsigned int timer1_cppm[];
|
||||
extern volatile unsigned int timer0_width[];
|
||||
extern volatile unsigned int timer0_cppm[];
|
||||
extern unsigned int timer_map[];
|
||||
|
||||
void init_timer(void);
|
||||
@@ -34,12 +39,12 @@ void timer_set_pwm_invalid(int channel);
|
||||
bool timer_valid(int channel);
|
||||
bool timer_allvalid(void);
|
||||
|
||||
#define timer_delay_us(x) timer_delay_clocks((x)*TIMER_US)
|
||||
#define timer_delay_ms(x) timer_delay_clocks((x)*TIMER_MS)
|
||||
#define timer_delay_us(x) timer_delay_clocks((x)*TIMER0_US)
|
||||
#define timer_delay_ms(x) timer_delay_clocks((x)*TIMER0_MS)
|
||||
|
||||
#ifdef TIMER_CPPM
|
||||
#define timer_input(ch) (timer1_cppm[TIMER_CH(ch)])
|
||||
#define timer_input(ch) (timer0_cppm[TIMER_CH(ch)])
|
||||
#else
|
||||
#define timer_input(ch) (timer1_width[TIMER_CH(ch)])
|
||||
#define timer_input(ch) (timer0_width[TIMER_CH(ch)])
|
||||
#endif
|
||||
#endif /* __TIMER_H */
|
||||
|
||||
Reference in New Issue
Block a user