forked from sim-/kk
-
Notifications
You must be signed in to change notification settings - Fork 17
/
motors.h
56 lines (47 loc) · 1.32 KB
/
motors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef MOTORS_H
#define MOTORS_H
#include "config.h"
/*** BEGIN DEFINES ***/
//#define SERVO_REVERSE
/*
* ESC PPM output rate -
* Do not set lower than 122 Hz without a slower/higher t0/t1 clkdiv
* as the period needs to fit in the 16-bit timer.
*/
//#define ESC_RATE 300 // in Hz
//#define ESC_RATE 400 // in Hz (at SINGLE_COPTER Only)
#define ESC_RATE 450 // in Hz
//#define ESC_RATE 495 // in Hz
// NOTE: Set to 50 for analog servos, 250 for digital servos.
#define SERVO_RATE 50 // in Hz
/*** END DEFINES ***/
/*** BEGIN HELPER MACROS ***/
#define PWM_LOW_PULSE_US ((1000000 / ESC_RATE) - 2000)
#ifdef SERVO_REVERSE
#undef SERVO_REVERSE
#define SERVO_REVERSE -
#else
#define SERVO_REVERSE
#endif
/*** END HELPER MACROS ***/
/*** BEGIN VARIABLES ***/
extern int16_t MotorOut1;
extern int16_t MotorOut2;
extern int16_t MotorOut3;
extern int16_t MotorOut4;
extern int16_t MotorOut5;
extern int16_t MotorOut6;
extern int16_t MotorStartTCNT1;
#if defined(SINGLE_COPTER) || defined(DUAL_COPTER) || defined(TWIN_COPTER) || defined(TRI_COPTER)
extern uint8_t servo_skip;
extern uint16_t servo_skip_divider;
#endif
/*** END VARIABLES ***/
/*** BEGIN PROTOTYPES ***/
void motorsSetup(void);
void motorLoop(void);
void motorsIdentify(void);
void motorsThrottleCalibration(void);
void output_motor_ppm(void);
/*** END PROTOTYPES ***/
#endif