1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Introduced ENABLE_DEBUG_PINS option in makefile that will enable the debug-pins and disable the servo outputs

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@233 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
fredericg 2010-03-03 16:16:43 +00:00 committed by fredericg
parent 35f07fe9dc
commit 0310339cb6
3 changed files with 23 additions and 1 deletions

View File

@ -26,6 +26,8 @@
# Set developer code and compile options
# Set to YES for debugging
DEBUG = YES
ENABLE_DEBUG_PINS = NO
# Set to YES when using Code Sourcery toolchain
CODE_SOURCERY = YES
@ -280,6 +282,11 @@ CDEFS = -DSTM32F10X_$(MODEL)
CDEFS += -DUSE_STDPERIPH_DRIVER
CDEFS += -DUSE_$(BOARD)
ifeq ($(ENABLE_DEBUG_PINS),YES)
CDEFS += -DPIOS_ENABLE_DEBUG_PINS
endif
# Place project-specific -D and/or -U options for
# Assembler with preprocessor here.
#ADEFS = -DUSE_IRQ_ASM_WRAPPER

View File

@ -37,6 +37,7 @@
*/
void PIOS_DEBUG_Init(void)
{
#ifdef PIOS_ENABLE_DEBUG_PINS
/* Initialise Servo pins as standard output pins */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
@ -46,6 +47,7 @@ void PIOS_DEBUG_Init(void)
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);
#endif // PIOS_ENABLE_DEBUG_PINS
}
/**
@ -53,12 +55,14 @@ void PIOS_DEBUG_Init(void)
* \param pin 0 for S1 output
*/
void PIOS_DEBUG_PinHigh(uint8_t Pin)
{
{
#ifdef PIOS_ENABLE_DEBUG_PINS
if(Pin < 4) {
PIOS_SERVO_GPIO_PORT_1TO4->BSRR = (PIOS_SERVO_GPIO_PIN_1 << Pin);
} else if (Pin <= 7) {
PIOS_SERVO_GPIO_PORT_5TO8->BSRR = (PIOS_SERVO_GPIO_PIN_5 << (Pin - 4));
}
#endif // PIOS_ENABLE_DEBUG_PINS
}
/**
@ -67,11 +71,13 @@ void PIOS_DEBUG_PinHigh(uint8_t Pin)
*/
void PIOS_DEBUG_PinLow(uint8_t Pin)
{
#ifdef PIOS_ENABLE_DEBUG_PINS
if(Pin < 4) {
PIOS_SERVO_GPIO_PORT_1TO4->BRR = (PIOS_SERVO_GPIO_PIN_1 << Pin);
} else if(Pin <= 7) {
PIOS_SERVO_GPIO_PORT_5TO8->BRR = (PIOS_SERVO_GPIO_PIN_5 << (Pin - 4));
}
#endif // PIOS_ENABLE_DEBUG_PINS
}

View File

@ -31,6 +31,9 @@
#if !defined(PIOS_DONT_USE_SERVO)
#ifdef PIOS_ENABLE_DEBUG_PINS
#warning "*** PIOS_ENABLE_DEBUG_PINS defined => Servo outputs will not function ***"
#endif
/* Private Function Prototypes */
@ -44,6 +47,7 @@ static volatile uint16_t ServoPosition[PIOS_SERVO_NUM_TIMERS];
*/
void PIOS_Servo_Init(void)
{
#ifndef PIOS_ENABLE_DEBUG_PINS
/* Initialise GPIOs as alternate function push/pull */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
@ -107,6 +111,7 @@ void PIOS_Servo_Init(void)
TIM_ARRPreloadConfig(TIM8, ENABLE);
TIM_CtrlPWMOutputs(TIM8, ENABLE);
TIM_Cmd(TIM8, ENABLE);
#endif // PIOS_ENABLE_DEBUG_PINS
}
/**
@ -116,6 +121,7 @@ void PIOS_Servo_Init(void)
*/
void PIOS_Servo_SetHz(uint16_t onetofour, uint16_t fivetoeight)
{
#ifndef PIOS_ENABLE_DEBUG_PINS
/* (Re)-Initialise Timers TIM4 and TIM8 */
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
@ -139,6 +145,7 @@ void PIOS_Servo_SetHz(uint16_t onetofour, uint16_t fivetoeight)
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1;
TIM_TimeBaseStructure.TIM_Period = ((1000000 / fivetoeight) - 1);
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
#endif // PIOS_ENABLE_DEBUG_PINS
}
/**
@ -148,6 +155,7 @@ void PIOS_Servo_SetHz(uint16_t onetofour, uint16_t fivetoeight)
*/
void PIOS_Servo_Set(uint8_t Servo, uint16_t Position)
{
#ifndef PIOS_ENABLE_DEBUG_PINS
/* Make sure servo exists */
if (Servo < PIOS_SERVO_NUM_OUTPUTS && Servo >= 0)
{
@ -190,6 +198,7 @@ void PIOS_Servo_Set(uint8_t Servo, uint16_t Position)
break;
}
}
#endif // PIOS_ENABLE_DEBUG_PINS
}
#endif