Rev 2117 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2117 | Rev 2189 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _TIMER2_H |
1 | #ifndef _TIMER2_H |
2 | #define _TIMER2_H |
2 | #define _TIMER2_H |
Line 3... | Line 3... | ||
3 | 3 | ||
- | 4 | #include <inttypes.h> |
|
- | 5 | #include <math.h> |
|
- | 6 | #include "configuration.h" |
|
- | 7 | ||
- | 8 | extern volatile uint16_t pwmChannels[MAX_PWMCHANNELS]; |
|
- | 9 | ||
- | 10 | #define SERVO_RESOLUTION FINE |
|
- | 11 | ||
- | 12 | #if (SERVO_RESOLUTION == COARSE) |
|
- | 13 | #define F_TIMER2 (F_CPU/32) |
|
- | 14 | #define CS2 ((1<<CS21)|(1<<CS20)) |
|
- | 15 | #else |
|
- | 16 | #define F_TIMER2(F_CPU/8) |
|
- | 17 | #define CS2 (1<<CS21) |
|
- | 18 | #endif |
|
- | 19 | ||
- | 20 | //#define ABSOLUTE_MIN ((float)F_TIMER2*0.00075 + 0.5) |
|
- | 21 | //#define ABSOLUTE_MAX ((float)F_TIMER2*0.00225 + 0.5) |
|
- | 22 | ||
- | 23 | #define PULSELENGTH_800 ((float)F_TIMER2*0.0008) |
|
- | 24 | #define PULSELENGTH_1000 ((float)F_TIMER2*0.0010) |
|
- | 25 | #define PULSELENGTH_1500 ((float)F_TIMER2*0.0015) |
|
- | 26 | #define PULSELENGTH_2000 ((float)F_TIMER2*0.0020) |
|
- | 27 | #define PULSELENGTH_2200 ((float)F_TIMER2*0.0022) |
|
- | 28 | ||
- | 29 | #define PWM_CONTROL_SCALE_FACTOR (PULSELENGTH_1000/(float)CONTROL_RANGE) |
|
- | 30 | #define PWM_BYTE_SCALE_FACTOR (PULSELENGTH_1000/256.0) |
|
- | 31 | ||
- | 32 | // Prevent damage even if grossly misconfigured: |
|
- | 33 | // Multiply this by angle in int16-degrees and again by 100 to get servo deflection to same angle |
|
Line 4... | Line 34... | ||
4 | #include <inttypes.h> |
34 | // (assuming 90 degrees over 1 ms, which is the norm): |
5 | 35 | ||
6 | void timer2_init(void); |
36 | void timer2_init(void); |
7 | void calculateServoValues(void); |
- |