Minor cleanup
This commit is contained in:
parent
9028db79c8
commit
06ad65a2f6
|
@ -42,7 +42,7 @@ static pwmOutputPort_t servos[MAX_SUPPORTED_SERVOS];
|
||||||
|
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
static pwmOutputPort_t beeperPwm;
|
static pwmOutputPort_t beeperPwm;
|
||||||
static uint16_t freqBeep=0;
|
static uint16_t freqBeep = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool pwmMotorsEnabled = false;
|
bool pwmMotorsEnabled = false;
|
||||||
|
@ -456,7 +456,7 @@ void servoDevInit(const servoDevConfig_t *servoConfig)
|
||||||
/* flag failure and disable ability to arm */
|
/* flag failure and disable ability to arm */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pwmOutConfig(&servos[servoIndex], timer, PWM_TIMER_HZ, PWM_TIMER_HZ / servoConfig->servoPwmRate, servoConfig->servoCenterPulse, 0);
|
pwmOutConfig(&servos[servoIndex], timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / servoConfig->servoPwmRate, servoConfig->servoCenterPulse, 0);
|
||||||
servos[servoIndex].enabled = true;
|
servos[servoIndex].enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ void pwmWriteBeeper(bool onoffBeep)
|
||||||
if(!beeperPwm.io)
|
if(!beeperPwm.io)
|
||||||
return;
|
return;
|
||||||
if(onoffBeep == true) {
|
if(onoffBeep == true) {
|
||||||
*beeperPwm.ccr = (PWM_TIMER_HZ / freqBeep) / 2;
|
*beeperPwm.ccr = (PWM_TIMER_1MHZ / freqBeep) / 2;
|
||||||
beeperPwm.enabled = true;
|
beeperPwm.enabled = true;
|
||||||
} else {
|
} else {
|
||||||
*beeperPwm.ccr = 0;
|
*beeperPwm.ccr = 0;
|
||||||
|
@ -495,7 +495,7 @@ void beeperPwmInit(IO_t io, uint16_t frequency)
|
||||||
IOConfigGPIO(beeperPwm.io, IOCFG_AF_PP);
|
IOConfigGPIO(beeperPwm.io, IOCFG_AF_PP);
|
||||||
#endif
|
#endif
|
||||||
freqBeep = frequency;
|
freqBeep = frequency;
|
||||||
pwmOutConfig(&beeperPwm, timer, PWM_TIMER_HZ, PWM_TIMER_HZ / freqBeep, (PWM_TIMER_HZ / freqBeep) / 2, 0);
|
pwmOutConfig(&beeperPwm, timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / freqBeep, (PWM_TIMER_1MHZ / freqBeep) / 2, 0);
|
||||||
}
|
}
|
||||||
*beeperPwm.ccr = 0;
|
*beeperPwm.ccr = 0;
|
||||||
beeperPwm.enabled = false;
|
beeperPwm.enabled = false;
|
||||||
|
|
|
@ -77,7 +77,7 @@ typedef enum {
|
||||||
PWM_TYPE_MAX
|
PWM_TYPE_MAX
|
||||||
} motorPwmProtocolTypes_e;
|
} motorPwmProtocolTypes_e;
|
||||||
|
|
||||||
#define PWM_TIMER_HZ MHZ_TO_HZ(1)
|
#define PWM_TIMER_1MHZ MHZ_TO_HZ(1)
|
||||||
|
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
#define MAX_DMA_TIMERS 8
|
#define MAX_DMA_TIMERS 8
|
||||||
|
|
|
@ -391,7 +391,7 @@ void pwmRxInit(const pwmConfig_t *pwmConfig)
|
||||||
IOConfigGPIO(io, IOCFG_AF_PP);
|
IOConfigGPIO(io, IOCFG_AF_PP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timerConfigure(timer, (uint16_t)PWM_TIMER_PERIOD, PWM_TIMER_HZ);
|
timerConfigure(timer, (uint16_t)PWM_TIMER_PERIOD, PWM_TIMER_1MHZ);
|
||||||
timerChCCHandlerInit(&port->edgeCb, pwmEdgeCallback);
|
timerChCCHandlerInit(&port->edgeCb, pwmEdgeCallback);
|
||||||
timerChOvrHandlerInit(&port->overflowCb, pwmOverflowCallback);
|
timerChOvrHandlerInit(&port->overflowCb, pwmOverflowCallback);
|
||||||
timerChConfigCallbacks(timer, &port->edgeCb, &port->overflowCb);
|
timerChConfigCallbacks(timer, &port->edgeCb, &port->overflowCb);
|
||||||
|
@ -448,7 +448,7 @@ void ppmRxInit(const ppmConfig_t *ppmConfig)
|
||||||
IOConfigGPIO(io, IOCFG_AF_PP);
|
IOConfigGPIO(io, IOCFG_AF_PP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timerConfigure(timer, (uint16_t)PPM_TIMER_PERIOD, PWM_TIMER_HZ);
|
timerConfigure(timer, (uint16_t)PPM_TIMER_PERIOD, PWM_TIMER_1MHZ);
|
||||||
timerChCCHandlerInit(&port->edgeCb, ppmEdgeCallback);
|
timerChCCHandlerInit(&port->edgeCb, ppmEdgeCallback);
|
||||||
timerChOvrHandlerInit(&port->overflowCb, ppmOverflowCallback);
|
timerChOvrHandlerInit(&port->overflowCb, ppmOverflowCallback);
|
||||||
timerChConfigCallbacks(timer, &port->edgeCb, &port->overflowCb);
|
timerChConfigCallbacks(timer, &port->edgeCb, &port->overflowCb);
|
||||||
|
|
|
@ -134,7 +134,7 @@ typedef enum {
|
||||||
#define HARDWARE_TIMER_DEFINITION_COUNT 14
|
#define HARDWARE_TIMER_DEFINITION_COUNT 14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MHZ_TO_HZ(x) (x * 1000000)
|
#define MHZ_TO_HZ(x) ((x) * 1000000)
|
||||||
|
|
||||||
extern const timerHardware_t timerHardware[];
|
extern const timerHardware_t timerHardware[];
|
||||||
extern const timerDef_t timerDefinitions[];
|
extern const timerDef_t timerDefinitions[];
|
||||||
|
|
Loading…
Reference in New Issue