//Config
const uint8_t NUM_OF_ACTUATORS = 5;
#define DSHOT_PWM
const PWMPinConfig PWM_CONFIG[MAX_CHANNELS]
{
{PWM1_Pin, PWM1_GPIO_Port, &htim1, TIM_CHANNEL_1, true, DMAMotorBuffer1, TIM_DMA_ID_CC1, TIM_DMA_CC1},
{PWM2_Pin, PWM2_GPIO_Port, &htim1, TIM_CHANNEL_2, true, DMAMotorBuffer2, TIM_DMA_ID_CC2, TIM_DMA_CC2},
{PWM3_Pin, PWM3_GPIO_Port, &htim1, TIM_CHANNEL_3, true, DMAMotorBuffer3, TIM_DMA_ID_CC3, TIM_DMA_CC3},
{PWM4_Pin, PWM4_GPIO_Port, &htim1, TIM_CHANNEL_4, true, DMAMotorBuffer4, TIM_DMA_ID_CC4, TIM_DMA_CC4},
{PWM6_Pin, PWM6_GPIO_Port, &htim3, TIM_CHANNEL_1, false, {0}, 0, 0},
{PWM10_Pin, PWM10_GPIO_Port, &htim3, TIM_CHANNEL_2, false, {0}, 0, 0},
{PWM11_Pin, PWM11_GPIO_Port, &htim3, TIM_CHANNEL_3, false, {0}, 0, 0},
{PWM12_Pin, PWM12_GPIO_Port, &htim3, TIM_CHANNEL_4, false, {0}, 0, 0}
}; //something like this
=====================================================
static uint8_t motorOutputs[NUM_OF_ACTUATORS] = {0};
//Input
typedef struct losActuatorsIndividual_t{
uint8_t channelactuator_id;
uint8_t percentage;
}; output;
};
void losActuatorSet(losActuatorsIndividual_t val)
{
//call the appropriate driver and pass along the struct info
motorOutputs[val.actuator_id] = output;
}
uint8_t getActuator(uint8_t channel)
{
return motorOutputs[channel];
} |