1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-291 PiOS/Servo: Converting output to use driver system

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2499 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-01-21 03:40:21 +00:00 committed by peabody124
parent 3d2f78ae9a
commit 2d9f7f32d1
10 changed files with 363 additions and 144 deletions

View File

@ -44,7 +44,7 @@
//#define PIOS_INCLUDE_SPEKTRUM
//#define PIOS_INCLUDE_PPM
//#define PIOS_INCLUDE_PWM
//#define PIOS_INCLUDE_SERVO
#define PIOS_INCLUDE_SERVO
#define PIOS_INCLUDE_SPI
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_USART

View File

@ -65,7 +65,13 @@ void PIOS_Board_Init(void) {
/* Initialize the PiOS library */
PIOS_COM_Init();
//PIOS_Servo_Init();
/* Remap AFIO pin */
GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
PIOS_Servo_Init();
PIOS_ADC_Init();
PIOS_GPIO_Init();
@ -536,6 +542,76 @@ struct pios_com_dev pios_com_devs[] = {
const uint8_t pios_com_num_devices = NELEMENTS(pios_com_devs);
/*
* Servo outputs
*/
#include <pios_servo_priv.h>
const struct pios_servo_channel pios_servo_channels[] = {
{
.timer = TIM4,
.port = GPIOB,
.channel = 4,
.pin = GPIO_Pin_9,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 3,
.pin = GPIO_Pin_8,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 2,
.pin = GPIO_Pin_7,
},
{
.timer = TIM1,
.port = GPIOA,
.channel = 1,
.pin = GPIO_Pin_8,
},
{ /* needs to remap to alternative function */
.timer = TIM3,
.port = GPIOB,
.channel = 1,
.pin = GPIO_Pin_4,
},
{
.timer = TIM2,
.port = GPIOA,
.channel = 3,
.pin = GPIO_Pin_2,
},
};
const struct pios_servo_cfg pios_servo_cfg = {
.tim_base_init = {
.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
.TIM_ClockDivision = TIM_CKD_DIV1,
.TIM_CounterMode = TIM_CounterMode_Up,
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
.TIM_RepetitionCounter = 0x0000,
},
.tim_oc_init = {
.TIM_OCMode = TIM_OCMode_PWM1,
.TIM_OutputState = TIM_OutputState_Enable,
.TIM_OutputNState = TIM_OutputNState_Disable,
.TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
.TIM_OCPolarity = TIM_OCPolarity_High,
.TIM_OCNPolarity = TIM_OCPolarity_High,
.TIM_OCIdleState = TIM_OCIdleState_Reset,
.TIM_OCNIdleState = TIM_OCNIdleState_Reset,
},
.gpio_init = {
.GPIO_Mode = GPIO_Mode_AF_PP,
.GPIO_Speed = GPIO_Speed_2MHz,
},
.channels = pios_servo_channels,
.num_channels = NELEMENTS(pios_servo_channels),
};
/*
* I2C Adapters
*/

View File

@ -187,7 +187,32 @@ void updateAttitude()
attitudeActual.Pitch = (UPDATE_FRAC * attitudeActual.Pitch + (1-UPDATE_FRAC) * accel_pitch) * 180 / M_PI;
attitudeActual.Yaw = attitudeActual.Yaw * 180 / M_PI;
AttitudeActualSet(&attitudeActual);
}
void updateStabilization()
{
AttitudeActualData attitudeActual;
AttitudeActualGet(&attitudeActual);
AttitudeDesiredData attitudeDesired;
AttitudeDesiredGet(&attitudeDesired);
AttitudeRawData attitudeRaw;
AttitudeRawGet(&attitudeRaw);
ActuatorDesiredData actuatorDesired;
ActuatorDesiredGet(&actuatorDesired);
}
void updateActuator()
{
ActuatorDesiredData actuatorDesired;
ActuatorDesiredGet(&actuatorDesired);
ActuatorCommandData actuatorCommand;
ActuatorCommandGet(&actuatorCommand);
ActuatorCommandSet(&actuatorCommand);
}
/**
* @}

View File

@ -112,7 +112,7 @@ static void systemTask(void *parameters)
ObjectPersistenceConnectCallback(&objectUpdatedCb);
// Main system loop
while (1) {
while (1) {
// Update the system statistics
updateStats();

View File

@ -605,6 +605,88 @@ void PIOS_USART_spektrum_irq_handler(void)
}
#endif
/**
* Pios servo configuration structures
*/
#include <pios_servo_priv.h>
const struct pios_servo_channel pios_servo_channels[] = {
{
.timer = TIM4,
.port = GPIOB,
.channel = 1,
.pin = GPIO_Pin_6,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 2,
.pin = GPIO_Pin_7,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 3,
.pin = GPIO_Pin_8,
},
{
.timer = TIM4,
.port = GPIOB,
.channel = 4,
.pin = GPIO_Pin_9,
},
{
.timer = TIM8,
.port = GPIOC,
.channel = 1,
.pin = GPIO_Pin_6,
},
{
.timer = TIM8,
.port = GPIOC,
.channel = 2,
.pin = GPIO_Pin_7,
},
{
.timer = TIM8,
.port = GPIOC,
.channel = 3,
.pin = GPIO_Pin_8,
},
{
.timer = TIM8,
.port = GPIOC,
.channel = 4,
.pin = GPIO_Pin_9,
},
};
const struct pios_servo_cfg pios_servo_cfg = {
.tim_base_init = {
.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
.TIM_ClockDivision = TIM_CKD_DIV1,
.TIM_CounterMode = TIM_CounterMode_Up,
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
.TIM_RepetitionCounter = 0x0000,
},
.tim_oc_init = {
.TIM_OCMode = TIM_OCMode_PWM1,
.TIM_OutputState = TIM_OutputState_Enable,
.TIM_OutputNState = TIM_OutputNState_Disable,
.TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
.TIM_OCPolarity = TIM_OCPolarity_High,
.TIM_OCNPolarity = TIM_OCPolarity_High,
.TIM_OCIdleState = TIM_OCIdleState_Reset,
.TIM_OCNIdleState = TIM_OCNIdleState_Reset,
},
.gpio_init = {
.GPIO_Mode = GPIO_Mode_AF_PP,
.GPIO_Speed = GPIO_Speed_2MHz,
},
.channels = pios_servo_channels,
.num_channels = NELEMENTS(pios_servo_channels),
};
/*
* COM devices
*/

View File

@ -217,7 +217,7 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
//-------------------------
// Receiver PWM inputs
//-------------------------
#define PIOS_PWM_CH1_GPIO_PORT GPIOA
/* #define PIOS_PWM_CH1_GPIO_PORT GPIOA
#define PIOS_PWM_CH1_PIN GPIO_Pin_9
#define PIOS_PWM_CH1_TIM_PORT TIM1
#define PIOS_PWM_CH1_CH TIM_Channel_2
@ -272,25 +272,13 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
#define PIOS_PWM_SUPV_HZ 25
#define PIOS_PWM_SUPV_IRQ_CHANNEL TIM6_IRQn
#define PIOS_PWM_SUPV_IRQ_FUNC void TIM6_IRQHandler(void)
*/
//-------------------------
// Servo outputs
//-------------------------
#define PIOS_SERVO_GPIO_PORT_1TO4 GPIOB
#define PIOS_SERVO_GPIO_PIN_1 GPIO_Pin_6
#define PIOS_SERVO_GPIO_PIN_2 GPIO_Pin_7
#define PIOS_SERVO_GPIO_PIN_3 GPIO_Pin_8
#define PIOS_SERVO_GPIO_PIN_4 GPIO_Pin_9
#define PIOS_SERVO_GPIO_PORT_5TO8 GPIOC
#define PIOS_SERVO_GPIO_PIN_5 GPIO_Pin_6
#define PIOS_SERVO_GPIO_PIN_6 GPIO_Pin_7
#define PIOS_SERVO_GPIO_PIN_7 GPIO_Pin_8
#define PIOS_SERVO_GPIO_PIN_8 GPIO_Pin_9
#define PIOS_SERVO_NUM_OUTPUTS 8
#define PIOS_SERVO_NUM_TIMERS PIOS_SERVO_NUM_OUTPUTS
#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_SERVOS_INITIAL_POSITION 2000 /* dont want to start motors, have no pulse till settings loaded */
//-------------------------
// GPIO

View File

@ -289,18 +289,6 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
//-------------------------
// Servo outputs
//-------------------------
#define PIOS_SERVO_GPIO_PORT_1TO4 GPIOB
#define PIOS_SERVO_GPIO_PIN_1 GPIO_Pin_6
#define PIOS_SERVO_GPIO_PIN_2 GPIO_Pin_7
#define PIOS_SERVO_GPIO_PIN_3 GPIO_Pin_8
#define PIOS_SERVO_GPIO_PIN_4 GPIO_Pin_9
#define PIOS_SERVO_GPIO_PORT_5TO8 GPIOC
#define PIOS_SERVO_GPIO_PIN_5 GPIO_Pin_6
#define PIOS_SERVO_GPIO_PIN_6 GPIO_Pin_7
#define PIOS_SERVO_GPIO_PIN_7 GPIO_Pin_8
#define PIOS_SERVO_GPIO_PIN_8 GPIO_Pin_9
#define PIOS_SERVO_NUM_OUTPUTS 8
#define PIOS_SERVO_NUM_TIMERS PIOS_SERVO_NUM_OUTPUTS
#define PIOS_SERVO_UPDATE_HZ 50
#define PIOS_SERVOS_INITIAL_POSITION 0 /* dont want to start motors, have no pulse till settings loaded */

View File

@ -30,12 +30,10 @@
/* Project Includes */
#include "pios.h"
#include "pios_servo_priv.h"
/* Private Function Prototypes */
/* Local Variables */
static volatile uint16_t ServoPosition[PIOS_SERVO_NUM_TIMERS];
/**
* Initialise Servos
*/
@ -43,72 +41,82 @@ void PIOS_Servo_Init(void)
{
#ifndef PIOS_ENABLE_DEBUG_PINS
#if defined(PIOS_INCLUDE_SERVO)
/* Initialise GPIOs as alternate function push/pull */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Pin = PIOS_SERVO_GPIO_PIN_3 | PIOS_SERVO_GPIO_PIN_4;
#ifndef PIOS_COM_AUX
GPIO_InitStructure.GPIO_Pin |= PIOS_SERVO_GPIO_PIN_1 | PIOS_SERVO_GPIO_PIN_2;
#endif
GPIO_Init(PIOS_SERVO_GPIO_PORT_1TO4, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIOS_SERVO_GPIO_PIN_5 | PIOS_SERVO_GPIO_PIN_6 | PIOS_SERVO_GPIO_PIN_7 | PIOS_SERVO_GPIO_PIN_8;
GPIO_Init(PIOS_SERVO_GPIO_PORT_5TO8, &GPIO_InitStructure);
for (uint8_t i = 0; i < pios_servo_cfg.num_channels; i++) {
GPIO_InitTypeDef GPIO_InitStructure = pios_servo_cfg.gpio_init;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = pios_servo_cfg.tim_base_init;
TIM_OCInitTypeDef TIM_OCInitStructure = pios_servo_cfg.tim_oc_init;
/* Initialise RCC Clocks (TIM4 and TIM8) */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
struct pios_servo_channel channel = pios_servo_cfg.channels[i];
/* Enable appropriate clock to timer module */
switch((int32_t) channel.timer) {
case (int32_t)TIM1:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
break;
case (int32_t)TIM2:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
break;
case (int32_t)TIM3:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
break;
case (int32_t)TIM4:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
break;
case (int32_t)TIM5:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);
break;
case (int32_t)TIM6:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
break;
case (int32_t)TIM7:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7, ENABLE);
break;
case (int32_t)TIM8:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
break;
}
/* Initialise Timers TIM4 and TIM8 */
/* With a resolution of 1uS, period of 20mS (50Hz) */
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1);
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
/* Enable GPIO */
GPIO_InitStructure.GPIO_Pin = channel.pin;
GPIO_Init(channel.port, &GPIO_InitStructure);
/* Enable time base */
TIM_TimeBaseInit(channel.timer, &TIM_TimeBaseStructure);
channel.timer->PSC = (PIOS_MASTER_CLOCK / 1000000) - 1;
/* Set up for output compare function */
switch(channel.channel) {
case 1:
TIM_OC1Init(channel.timer, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(channel.timer, TIM_OCPreload_Enable);
break;
case 2:
TIM_OC2Init(channel.timer, &TIM_OCInitStructure);
TIM_OC2PreloadConfig(channel.timer, TIM_OCPreload_Enable);
break;
case 3:
TIM_OC3Init(channel.timer, &TIM_OCInitStructure);
TIM_OC3PreloadConfig(channel.timer, TIM_OCPreload_Enable);
break;
case 4:
TIM_OC4Init(channel.timer, &TIM_OCInitStructure);
TIM_OC4PreloadConfig(channel.timer, TIM_OCPreload_Enable);
break;
}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
TIM_ARRPreloadConfig(channel.timer, ENABLE);
TIM_CtrlPWMOutputs(channel.timer, ENABLE);
TIM_Cmd(channel.timer, ENABLE);
}
/* Setup each timer separately */
TIM_OCInitTypeDef TIM_OCInitStructure;
/* TIM4 */
TIM_OCStructInit(&TIM_OCInitStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION;
TIM_OC1Init(TIM4, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OC2Init(TIM4, &TIM_OCInitStructure);
TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OC3Init(TIM4, &TIM_OCInitStructure);
TIM_OC3PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OC4Init(TIM4, &TIM_OCInitStructure);
TIM_OC4PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM4, ENABLE);
TIM_CtrlPWMOutputs(TIM4, ENABLE);
TIM_Cmd(TIM4, ENABLE);
/* TIM8 */
TIM_OCStructInit(&TIM_OCInitStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION;
TIM_OC1Init(TIM8, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM8, TIM_OCPreload_Enable);
TIM_OC2Init(TIM8, &TIM_OCInitStructure);
TIM_OC2PreloadConfig(TIM8, TIM_OCPreload_Enable);
TIM_OC3Init(TIM8, &TIM_OCInitStructure);
TIM_OC3PreloadConfig(TIM8, TIM_OCPreload_Enable);
TIM_OC4Init(TIM8, &TIM_OCInitStructure);
TIM_OC4PreloadConfig(TIM8, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM8, ENABLE);
TIM_CtrlPWMOutputs(TIM8, ENABLE);
TIM_Cmd(TIM8, ENABLE);
#endif // PIOS_INCLUDE_SERVO
#endif // PIOS_ENABLE_DEBUG_PINS
}
@ -122,29 +130,31 @@ void PIOS_Servo_SetHz(uint16_t onetofour, uint16_t fivetoeight)
{
#ifndef PIOS_ENABLE_DEBUG_PINS
#if defined(PIOS_INCLUDE_SERVO)
/* (Re)-Initialise Timers TIM4 and TIM8 */
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = pios_servo_cfg.tim_base_init;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
#if 0
/* Clipping */
if (onetofour > 500) {
onetofour = 500;
}
if (fivetoeight > 500) {
fivetoeight = 500;
}
#endif
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1;
TIM_TimeBaseStructure.TIM_Period = ((1000000 / onetofour) - 1);
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1;
TIM_TimeBaseStructure.TIM_Period = ((1000000 / fivetoeight) - 1);
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
for (uint8_t i = 0; i < pios_servo_cfg.num_channels; i++) {
struct pios_servo_channel channel = pios_servo_cfg.channels[i];
/* Enable time base */
switch((int32_t)channel.timer) {
case (int32_t)TIM1:
case (int32_t)TIM2:
case (int32_t)TIM3:
case (int32_t)TIM4:
TIM_TimeBaseStructure.TIM_Period = ((1000000 / onetofour) - 1);
break;
case (int32_t)TIM5:
case (int32_t)TIM6:
case (int32_t)TIM7:
case (int32_t)TIM8:
TIM_TimeBaseStructure.TIM_Period = ((1000000 / fivetoeight) - 1);
break;
}
TIM_TimeBaseInit(channel.timer, &TIM_TimeBaseStructure);
}
#endif // PIOS_INCLUDE_SERVO
#endif // PIOS_ENABLE_DEBUG_PINS
}
@ -159,36 +169,23 @@ void PIOS_Servo_Set(uint8_t Servo, uint16_t Position)
#ifndef PIOS_ENABLE_DEBUG_PINS
#if defined(PIOS_INCLUDE_SERVO)
/* Make sure servo exists */
if (Servo < PIOS_SERVO_NUM_OUTPUTS && Servo >= 0) {
if (Servo < pios_servo_cfg.num_channels && Servo >= 0) {
/* Update the position */
ServoPosition[Servo] = Position;
switch (Servo) {
case 0:
TIM_SetCompare1(TIM4, Position);
break;
case 1:
TIM_SetCompare2(TIM4, Position);
break;
case 2:
TIM_SetCompare3(TIM4, Position);
break;
case 3:
TIM_SetCompare4(TIM4, Position);
break;
case 4:
TIM_SetCompare1(TIM8, Position);
break;
case 5:
TIM_SetCompare2(TIM8, Position);
break;
case 6:
TIM_SetCompare3(TIM8, Position);
break;
case 7:
TIM_SetCompare4(TIM8, Position);
break;
}
switch(pios_servo_cfg.channels[Servo].channel) {
case 1:
TIM_SetCompare1(pios_servo_cfg.channels[Servo].timer, Position);
break;
case 2:
TIM_SetCompare2(pios_servo_cfg.channels[Servo].timer, Position);
break;
case 3:
TIM_SetCompare3(pios_servo_cfg.channels[Servo].timer, Position);
break;
case 4:
TIM_SetCompare4(pios_servo_cfg.channels[Servo].timer, Position);
break;
}
}
#endif // PIOS_INCLUDE_SERVO
#endif // PIOS_ENABLE_DEBUG_PINS

View File

@ -0,0 +1,61 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_SERVO Servo Functions
* @brief PIOS interface to read and write from servo PWM ports
* @{
*
* @file pios_servo_priv.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Servo private structures.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_SERVO_PRIV_H
#define PIOS_SERVO_PRIV_H
#include <pios.h>
#include <pios_stm32.h>
// GPIO_TypeDef *gpio;
struct pios_servo_channel {
TIM_TypeDef * timer;
GPIO_TypeDef * port;
uint8_t channel;
uint16_t pin;
};
struct pios_servo_cfg {
TIM_TimeBaseInitTypeDef tim_base_init;
TIM_OCInitTypeDef tim_oc_init;
GPIO_InitTypeDef gpio_init;
const struct pios_servo_channel *const channels;
uint8_t num_channels;
};
extern const struct pios_servo_cfg pios_servo_cfg;
#endif /* PIOS_SERVO_PRIV_H */
/**
* @}
* @}
*/

View File

@ -2951,6 +2951,7 @@
65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_HD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_HD.S; sourceTree = SOURCE_ROOT; };
65E8F0F111EFF25C00BBF654 /* startup_stm32f10x_MD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_MD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_MD.S; sourceTree = SOURCE_ROOT; };
65EA2E171273C55200636061 /* ratedesired.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ratedesired.xml; sourceTree = "<group>"; };
65FBE14412E7C98100176B5A /* pios_servo_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_servo_priv.h; sourceTree = "<group>"; };
65FC66AA123F30F100B04F74 /* ahrs_timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ahrs_timer.c; path = ../../AHRS/ahrs_timer.c; sourceTree = SOURCE_ROOT; };
65FC66AB123F312A00B04F74 /* ahrs_timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs_timer.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -7509,6 +7510,7 @@
65E8F04911EFF25C00BBF654 /* pios_pwm.h */,
65E8F04A11EFF25C00BBF654 /* pios_sdcard.h */,
65E8F04B11EFF25C00BBF654 /* pios_servo.h */,
65FBE14412E7C98100176B5A /* pios_servo_priv.h */,
65E8F04C11EFF25C00BBF654 /* pios_spektrum.h */,
65E8F04D11EFF25C00BBF654 /* pios_spi.h */,
65E8F04E11EFF25C00BBF654 /* pios_spi_priv.h */,