mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-1683 - Fix compilation for CC (not yet supported)
This commit is contained in:
parent
d0629926f0
commit
411416d2a1
@ -39,6 +39,16 @@
|
||||
|
||||
static const struct pios_servo_cfg *servo_cfg;
|
||||
|
||||
// determine if the related timer will work in synchronous (or OneShot/OneShot125) One Pulse mode.
|
||||
//static uint8_t pios_servo_bank_mode[PIOS_SERVO_BANKS] = { 0 };
|
||||
|
||||
// timer associated to each bank
|
||||
//static TIM_TypeDef *pios_servo_bank_timer[PIOS_SERVO_BANKS] = { 0 };
|
||||
|
||||
// index of bank used for each pin
|
||||
static uint8_t *pios_servo_pin_bank;
|
||||
|
||||
|
||||
/**
|
||||
* Initialise Servos
|
||||
*/
|
||||
@ -52,10 +62,41 @@ int32_t PIOS_Servo_Init(const struct pios_servo_cfg *cfg)
|
||||
|
||||
/* Store away the requested configuration */
|
||||
servo_cfg = cfg;
|
||||
pios_servo_pin_bank = pios_malloc(sizeof(uint8_t) * cfg->num_channels);
|
||||
|
||||
uint8_t bank = 0;
|
||||
/* Configure the channels to be in output compare mode */
|
||||
for (uint8_t i = 0; i < cfg->num_channels; i++) {
|
||||
const struct pios_tim_channel *chan = &cfg->channels[i];
|
||||
const struct pios_tim_channel *chan = &servo_cfg->channels[i];
|
||||
bool new = true;
|
||||
/* See if any previous channels use that same timer */
|
||||
for (uint8_t j = 0; (j < i) && new; j++) {
|
||||
new &= chan->timer != servo_cfg->channels[j].timer;
|
||||
}
|
||||
|
||||
if (new) {
|
||||
PIOS_Assert(bank < PIOS_SERVO_BANKS);
|
||||
for (uint8_t j = i; j < servo_cfg->num_channels; j++) {
|
||||
if (servo_cfg->channels[j].timer == chan->timer) {
|
||||
pios_servo_pin_bank[j] = bank;
|
||||
}
|
||||
}
|
||||
//pios_servo_bank_timer[i] = chan->timer;
|
||||
|
||||
PIOS_Assert(bank < PIOS_SERVO_BANKS);
|
||||
|
||||
for (uint8_t j = i; j < servo_cfg->num_channels; j++) {
|
||||
if (servo_cfg->channels[j].timer == chan->timer) {
|
||||
pios_servo_pin_bank[j] = bank;
|
||||
}
|
||||
}
|
||||
/*
|
||||
TIM_ARRPreloadConfig(chan->timer, ENABLE);
|
||||
TIM_CtrlPWMOutputs(chan->timer, ENABLE);
|
||||
TIM_Cmd(chan->timer, DISABLE);
|
||||
*/
|
||||
bank++;
|
||||
}
|
||||
|
||||
/* Set up for output compare function */
|
||||
switch (chan->timer_chan) {
|
||||
@ -150,4 +191,28 @@ void PIOS_Servo_Set(uint8_t servo, uint16_t position)
|
||||
}
|
||||
}
|
||||
|
||||
void PIOS_Servo_Update(){
|
||||
/*
|
||||
for (uint8_t i = 0; (i < PIOS_SERVO_BANKS); i++) {
|
||||
const TIM_TypeDef *timer = pios_servo_bank_timer[i];
|
||||
if (timer) {
|
||||
TIM_Cmd((TIM_TypeDef *)timer, ENABLE);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void PIOS_Servo_SetBankMode(__attribute__((unused)) uint8_t bank, __attribute__((unused)) uint8_t mode){
|
||||
|
||||
}
|
||||
|
||||
uint8_t PIOS_Servo_GetPinBank(uint8_t pin)
|
||||
{
|
||||
if (pin < servo_cfg->num_channels) {
|
||||
return pios_servo_pin_bank[pin];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_SERVO */
|
||||
|
@ -251,6 +251,7 @@ extern uint32_t pios_com_hkosd_id;
|
||||
// -------------------------
|
||||
#define PIOS_SERVO_UPDATE_HZ 50
|
||||
#define PIOS_SERVOS_INITIAL_POSITION 0 /* dont want to start motors, have no pulse till settings loaded */
|
||||
#define PIOS_SERVO_BANKS 6
|
||||
|
||||
// --------------------------
|
||||
// Timer controller settings
|
||||
|
@ -2,7 +2,10 @@
|
||||
<object name="ActuatorSettings" singleinstance="true" settings="true" category="Control">
|
||||
<description>Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType</description>
|
||||
<field name="BankUpdateFreq" units="Hz" type="uint16" elements="6" defaultvalue="50"/>
|
||||
<field name="BankMode" type="enum" units="" elements="6" options="PWM,OneShot,OneShot125" defaultvalue="PWM"/>
|
||||
<field name="BankMode" type="enum" units="" elements="6" options="PWM,OneShot,OneShot125" defaultvalue="PWM"
|
||||
limits="%0401NE:OneShot:OneShot125,\
|
||||
%0402NE:OneShot:OneShot125;"
|
||||
/>
|
||||
<field name="ChannelMax" units="us" type="int16" elements="12" defaultvalue="1000"/>
|
||||
<field name="ChannelNeutral" units="us" type="int16" elements="12" defaultvalue="1000"/>
|
||||
<field name="ChannelMin" units="us" type="int16" elements="12" defaultvalue="1000"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user