mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 07:45:29 +03:00
Initial IO remapping capability
This commit is contained in:
parent
5f47fc311b
commit
46a6e560f1
28 changed files with 506 additions and 382 deletions
|
@ -17,14 +17,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "io/motors.h"
|
||||
#include "io/servos.h"
|
||||
#include "drivers/timer.h"
|
||||
|
||||
typedef enum {
|
||||
PWM_TYPE_CONVENTIONAL = 0,
|
||||
PWM_TYPE_STANDARD = 0,
|
||||
PWM_TYPE_ONESHOT125,
|
||||
PWM_TYPE_ONESHOT42,
|
||||
PWM_TYPE_MULTISHOT,
|
||||
PWM_TYPE_BRUSHED
|
||||
} motorPwmProtocolTypes_e;
|
||||
|
||||
#define PWM_TIMER_MHZ 1
|
||||
|
||||
#if defined(STM32F40_41xxx) // must be multiples of timer clock
|
||||
#define ONESHOT125_TIMER_MHZ 12
|
||||
#define ONESHOT42_TIMER_MHZ 21
|
||||
|
@ -38,9 +44,20 @@ typedef enum {
|
|||
#endif
|
||||
|
||||
struct timerHardware_s;
|
||||
void pwmBrushedMotorConfig(const struct timerHardware_s *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate);
|
||||
void pwmBrushlessMotorConfig(const struct timerHardware_s *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse);
|
||||
void pwmFastPwmMotorConfig(const struct timerHardware_s *timerHardware, uint8_t motorIndex, uint16_t motorPwmRate, uint16_t idlePulse, uint8_t fastPwmProtocolType);
|
||||
typedef void(*pwmWriteFuncPtr)(uint8_t index, uint16_t value); // function pointer used to write motors
|
||||
|
||||
typedef struct {
|
||||
volatile timCCR_t *ccr;
|
||||
TIM_TypeDef *tim;
|
||||
uint16_t period;
|
||||
pwmWriteFuncPtr pwmWritePtr;
|
||||
bool enabled;
|
||||
IO_t io;
|
||||
} pwmOutputPort_t;
|
||||
|
||||
void motorInit(motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount);
|
||||
void servoInit(servoConfig_t *servoConfig);
|
||||
|
||||
void pwmServoConfig(const struct timerHardware_s *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse);
|
||||
|
||||
void pwmWriteMotor(uint8_t index, uint16_t value);
|
||||
|
@ -49,5 +66,7 @@ void pwmCompleteOneshotMotorUpdate(uint8_t motorCount);
|
|||
|
||||
void pwmWriteServo(uint8_t index, uint16_t value);
|
||||
|
||||
pwmOutputPort_t *pwmGetMotors();
|
||||
void pwmDisableMotors(void);
|
||||
void pwmEnableMotors(void);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue