-
Notifications
You must be signed in to change notification settings - Fork 365
Expand file tree
/
Copy pathdrv_pwm.h
More file actions
executable file
·64 lines (57 loc) · 2.04 KB
/
Copy pathdrv_pwm.h
File metadata and controls
executable file
·64 lines (57 loc) · 2.04 KB
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
57
58
59
60
61
62
63
64
/*
* This file is part of baseflight
* Licensed under GPL V3 or modified DCL - see https://github.com/multiwii/baseflight/blob/master/README.md
*/
#pragma once
#define MAX_MOTORS 12
#define MAX_SERVOS 8
#define MAX_PWM_INPUTS 8
#define MAX_PPM_INPUTS 16
#define PULSE_1MS (1000) // 1ms pulse width
#define PULSE_MIN (750) // minimum PWM pulse width which is considered valid
#define PULSE_MAX (2250) // maximum PWM pulse width which is considered valid
typedef struct drv_pwm_config_t {
bool enableInput;
bool usePPM;
bool useUART;
bool useSoftSerial;
bool useServos;
bool extraServos; // configure additional 4 channels in PPM mode as servos, not motors
bool airplane; // fixed wing hardware config, lots of servos etc
uint8_t pwmFilter; // PWM ICFilter value for jittering input
uint8_t adcChannel; // steal one RC input for current sensor
uint16_t motorPwmRate;
uint16_t servoPwmRate;
uint16_t idlePulse; // PWM value to use when initializing the driver. set this to either PULSE_1MS (regular pwm),
// some higher value (used by 3d mode), or 0, for brushed pwm drivers.
uint16_t servoCenterPulse;
uint16_t failsafeThreshold;
bool syncPWM;
bool fastPWM;
// OUT parameters, filled by driver
uint8_t numServos;
} drv_pwm_config_t;
// This indexes into the read-only hardware definition structure in drv_pwm.c, as well as into pwmPorts[] structure with dynamic data.
enum {
PWM1 = 0,
PWM2,
PWM3,
PWM4,
PWM5,
PWM6,
PWM7,
PWM8,
PWM9,
PWM10,
PWM11,
PWM12,
PWM13,
PWM14,
MAX_PORTS
};
void pwmICConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t polarity);
bool pwmInit(drv_pwm_config_t *init); // returns whether driver is asking to calibrate throttle or not
void pwmWriteMotor(uint8_t index, uint16_t value);
void pwmWriteServo(uint8_t index, uint16_t value);
uint16_t pwmRead(uint8_t channel);
// void pwmWrite(uint8_t channel, uint16_t value);