Subversion Repositories FlightCtrl

Rev

Rev 2117 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1612 dongfang 1
#ifndef _TIMER2_H
2
#define _TIMER2_H
3
 
4
#include <inttypes.h>
2189 - 5
#include <math.h>
6
#include "configuration.h"
1612 dongfang 7
 
2189 - 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 
34
// (assuming 90 degrees over 1 ms, which is the norm):
35
 
1612 dongfang 36
void timer2_init(void);
2189 - 37
//void calculateServoValues(void);
1612 dongfang 38
#endif //_TIMER2_H