Fixed timer output needing to be properly enabled (when using PPM pins etc).
This commit is contained in:
parent
b4c777e2a0
commit
01f942554c
|
@ -64,9 +64,7 @@ static void pwmOutConfig(pwmOutputPort_t *port, const timerHardware_t *timerHard
|
||||||
configTimeBase(timerHardware->tim, period, mhz);
|
configTimeBase(timerHardware->tim, period, mhz);
|
||||||
pwmOCConfig(timerHardware->tim, timerHardware->channel, value, timerHardware->output);
|
pwmOCConfig(timerHardware->tim, timerHardware->channel, value, timerHardware->output);
|
||||||
|
|
||||||
if (timerHardware->output & TIMER_OUTPUT_ENABLED) {
|
TIM_CtrlPWMOutputs(timerHardware->tim, ENABLE);
|
||||||
TIM_CtrlPWMOutputs(timerHardware->tim, ENABLE);
|
|
||||||
}
|
|
||||||
TIM_Cmd(timerHardware->tim, ENABLE);
|
TIM_Cmd(timerHardware->tim, ENABLE);
|
||||||
|
|
||||||
port->ccr = timerChCCR(timerHardware);
|
port->ccr = timerChCCR(timerHardware);
|
||||||
|
|
|
@ -63,11 +63,7 @@ static void pwmOutConfig(pwmOutputPort_t *port, const timerHardware_t *timerHard
|
||||||
configTimeBase(timerHardware->tim, period, mhz);
|
configTimeBase(timerHardware->tim, period, mhz);
|
||||||
pwmOCConfig(timerHardware->tim, timerHardware->channel, value, timerHardware->output);
|
pwmOCConfig(timerHardware->tim, timerHardware->channel, value, timerHardware->output);
|
||||||
|
|
||||||
if (timerHardware->output & TIMER_OUTPUT_ENABLED) {
|
HAL_TIM_PWM_Start(Handle, timerHardware->channel);
|
||||||
HAL_TIM_PWM_Start(Handle, timerHardware->channel);
|
|
||||||
} else {
|
|
||||||
HAL_TIM_PWM_Stop(Handle, timerHardware->channel);
|
|
||||||
}
|
|
||||||
HAL_TIM_Base_Start(Handle);
|
HAL_TIM_Base_Start(Handle);
|
||||||
|
|
||||||
switch (timerHardware->channel) {
|
switch (timerHardware->channel) {
|
||||||
|
@ -221,7 +217,7 @@ void motorInit(const motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t mot
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const timerHardware_t *timerHardware = timerGetByTag(tag, TIMER_OUTPUT_ENABLED);
|
const timerHardware_t *timerHardware = timerGetByTag(tag, TIM_USE_ANY);
|
||||||
|
|
||||||
if (timerHardware == NULL) {
|
if (timerHardware == NULL) {
|
||||||
/* flag failure and disable ability to arm */
|
/* flag failure and disable ability to arm */
|
||||||
|
@ -280,7 +276,7 @@ void servoInit(const servoConfig_t *servoConfig)
|
||||||
IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_INDEX(servoIndex));
|
IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_INDEX(servoIndex));
|
||||||
//IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP);
|
//IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP);
|
||||||
|
|
||||||
const timerHardware_t *timer = timerGetByTag(tag, TIMER_OUTPUT_ENABLED);
|
const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_ANY);
|
||||||
IOConfigGPIOAF(servos[servoIndex].io, IOCFG_AF_PP, timer->alternateFunction);
|
IOConfigGPIOAF(servos[servoIndex].io, IOCFG_AF_PP, timer->alternateFunction);
|
||||||
|
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ static void escSerialICConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t polari
|
||||||
|
|
||||||
void setTxSignalEsc(escSerial_t *escSerial, uint8_t state)
|
void setTxSignalEsc(escSerial_t *escSerial, uint8_t state)
|
||||||
{
|
{
|
||||||
if((escSerial->mode == PROTOCOL_KISSALL))
|
if(escSerial->mode == PROTOCOL_KISSALL)
|
||||||
{
|
{
|
||||||
for (volatile uint8_t i = 0; i < escSerial->outputCount; i++) {
|
for (volatile uint8_t i = 0; i < escSerial->outputCount; i++) {
|
||||||
uint8_t state_temp = state;
|
uint8_t state_temp = state;
|
||||||
|
|
|
@ -108,8 +108,9 @@ typedef struct timerHardware_s {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TIMER_OUTPUT_NONE = 0x00,
|
TIMER_OUTPUT_NONE = 0x00,
|
||||||
TIMER_INPUT_ENABLED = 0x00,
|
TIMER_INPUT_ENABLED = 0x01, /* TODO: remove this */
|
||||||
TIMER_OUTPUT_ENABLED = 0x01,
|
TIMER_OUTPUT_ENABLED = 0x01, /* TODO: remove this */
|
||||||
|
TIMER_OUTPUT_STANDARD = 0x01,
|
||||||
TIMER_OUTPUT_INVERTED = 0x02,
|
TIMER_OUTPUT_INVERTED = 0x02,
|
||||||
TIMER_OUTPUT_N_CHANNEL = 0x04
|
TIMER_OUTPUT_N_CHANNEL = 0x04
|
||||||
} timerFlag_e;
|
} timerFlag_e;
|
||||||
|
|
|
@ -37,11 +37,11 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
|
const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
|
||||||
DEF_TIM(TIM3, CH2, PC7, TIM_USE_PPM, TIMER_INPUT_ENABLED, 0 ), // PPM IN
|
DEF_TIM(TIM3, CH2, PC7, TIM_USE_PPM, TIMER_OUTPUT_STANDARD, 0 ), // PPM IN
|
||||||
DEF_TIM(TIM5, CH1, PA0, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S1_OUT - DMA1_ST2
|
DEF_TIM(TIM5, CH1, PA0, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // S1_OUT - DMA1_ST2
|
||||||
DEF_TIM(TIM5, CH2, PA1, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S2_OUT - DMA1_ST4
|
DEF_TIM(TIM5, CH2, PA1, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // S2_OUT - DMA1_ST4
|
||||||
DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S3_OUT - DMA1_ST1
|
DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // S3_OUT - DMA1_ST1
|
||||||
DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 1 ), // S4_OUT - DMA1_ST6
|
DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 1 ), // S4_OUT - DMA1_ST6
|
||||||
DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR | TIM_USE_LED, TIMER_OUTPUT_ENABLED, 0 ), // S5_OUT - DMA1_ST7
|
DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR | TIM_USE_LED, TIMER_OUTPUT_STANDARD, 0 ), // S5_OUT - DMA1_ST7
|
||||||
DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S6_OUT - DMA1_ST2
|
DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // S6_OUT - DMA1_ST2
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue