mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 09:45:33 +03:00
Add extra MSP message to get outputs with timer ids
Timer ids are needed to correctly replicate pwm allocation logic in the configurator
This commit is contained in:
parent
cada1cca14
commit
0d16352fb8
4 changed files with 27 additions and 2 deletions
|
@ -38,8 +38,20 @@
|
||||||
|
|
||||||
timHardwareContext_t * timerCtx[HARDWARE_TIMER_DEFINITION_COUNT];
|
timHardwareContext_t * timerCtx[HARDWARE_TIMER_DEFINITION_COUNT];
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t timer2id(const HAL_Timer_t *tim)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < HARDWARE_TIMER_DEFINITION_COUNT; ++i)
|
||||||
|
{
|
||||||
|
if(timerDefinitions[i].tim == tim)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint8_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(AT32F43x)
|
#if defined(AT32F43x)
|
||||||
uint8_t lookupTimerIndex(const tmr_type *tim)
|
uint8_t lookupTimerIndex(const HAL_Timer_t *tim)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -54,7 +66,7 @@ uint8_t lookupTimerIndex(const tmr_type *tim)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// return index of timer in timer table. Lowest timer has index 0
|
// return index of timer in timer table. Lowest timer has index 0
|
||||||
uint8_t lookupTimerIndex(const TIM_TypeDef *tim)
|
uint8_t lookupTimerIndex(const HAL_Timer_t *tim)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "drivers/rcc_types.h"
|
#include "drivers/rcc_types.h"
|
||||||
#include "drivers/timer_def.h"
|
#include "drivers/timer_def.h"
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
#define CC_CHANNELS_PER_TIMER 4 // TIM_Channel_1..4
|
#define CC_CHANNELS_PER_TIMER 4 // TIM_Channel_1..4
|
||||||
|
|
||||||
typedef uint16_t captureCompare_t; // 16 bit on both 103 and 303, just register access must be 32bit sometimes (use timCCR_t)
|
typedef uint16_t captureCompare_t; // 16 bit on both 103 and 303, just register access must be 32bit sometimes (use timCCR_t)
|
||||||
|
@ -231,3 +233,5 @@ void timerPWMStopDMA(TCH_t * tch);
|
||||||
bool timerPWMDMAInProgress(TCH_t * tch);
|
bool timerPWMDMAInProgress(TCH_t * tch);
|
||||||
|
|
||||||
volatile timCCR_t *timerCCR(TCH_t * tch);
|
volatile timCCR_t *timerCCR(TCH_t * tch);
|
||||||
|
|
||||||
|
uint8_t timer2id(const HAL_Timer_t *tim);
|
||||||
|
|
|
@ -1516,6 +1516,14 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSP2_INAV_OUTPUT_MAPPING_EXT:
|
||||||
|
for (uint8_t i = 0; i < timerHardwareCount; ++i)
|
||||||
|
if (!(timerHardware[i].usageFlags & (TIM_USE_PPM | TIM_USE_PWM))) {
|
||||||
|
sbufWriteU8(dst, timer2id(timerHardware[i].tim));
|
||||||
|
sbufWriteU8(dst, timerHardware[i].usageFlags);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case MSP2_INAV_MC_BRAKING:
|
case MSP2_INAV_MC_BRAKING:
|
||||||
#ifdef USE_MR_BRAKING_MODE
|
#ifdef USE_MR_BRAKING_MODE
|
||||||
sbufWriteU16(dst, navConfig()->mc.braking_speed_threshold);
|
sbufWriteU16(dst, navConfig()->mc.braking_speed_threshold);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#define MSP2_INAV_OUTPUT_MAPPING 0x200A
|
#define MSP2_INAV_OUTPUT_MAPPING 0x200A
|
||||||
#define MSP2_INAV_MC_BRAKING 0x200B
|
#define MSP2_INAV_MC_BRAKING 0x200B
|
||||||
#define MSP2_INAV_SET_MC_BRAKING 0x200C
|
#define MSP2_INAV_SET_MC_BRAKING 0x200C
|
||||||
|
#define MSP2_INAV_OUTPUT_MAPPING_EXT 0x200D
|
||||||
|
|
||||||
#define MSP2_INAV_MIXER 0x2010
|
#define MSP2_INAV_MIXER 0x2010
|
||||||
#define MSP2_INAV_SET_MIXER 0x2011
|
#define MSP2_INAV_SET_MIXER 0x2011
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue