1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

OP-291 PIOS/Servo: Refer to channels by TIM_Channel_x to be consistent with PWM

system

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2571 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-01-24 07:51:54 +00:00 committed by peabody124
parent d5ccb59b5a
commit 2881370eab
2 changed files with 15 additions and 10 deletions

View File

@ -485,37 +485,37 @@ const struct pios_servo_channel pios_servo_channels[] = {
{
.timer = TIM4,
.port = GPIOB,
.channel = 4,
.channel = TIM_Channel_4,
.pin = GPIO_Pin_9,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 3,
.channel = TIM_Channel_3,
.pin = GPIO_Pin_8,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 2,
.channel = TIM_Channel_2,
.pin = GPIO_Pin_7,
},
{
.timer = TIM1,
.port = GPIOA,
.channel = 1,
.channel = TIM_Channel_1,
.pin = GPIO_Pin_8,
},
{ /* needs to remap to alternative function */
.timer = TIM3,
.port = GPIOB,
.channel = 1,
.channel = TIM_Channel_1,
.pin = GPIO_Pin_4,
},
{
.timer = TIM2,
.port = GPIOA,
.channel = 3,
.channel = TIM_Channel_3,
.pin = GPIO_Pin_2,
},
};

View File

@ -34,6 +34,7 @@
/* Private Function Prototypes */
uint16_t servo_positions[8];
/**
* Initialise Servos
*/
@ -176,16 +177,20 @@ void PIOS_Servo_Set(uint8_t Servo, uint16_t Position)
/* Update the position */
switch(pios_servo_cfg.channels[Servo].channel) {
case 1:
case TIM_Channel_1:
servo_positions[Servo] = Position;
TIM_SetCompare1(pios_servo_cfg.channels[Servo].timer, Position);
break;
case 2:
case TIM_Channel_2:
servo_positions[Servo] = Position;
TIM_SetCompare2(pios_servo_cfg.channels[Servo].timer, Position);
break;
case 3:
case TIM_Channel_3:
servo_positions[Servo] = Position;
TIM_SetCompare3(pios_servo_cfg.channels[Servo].timer, Position);
break;
case 4:
case TIM_Channel_4:
servo_positions[Servo] = Position;
TIM_SetCompare4(pios_servo_cfg.channels[Servo].timer, Position);
break;
}