From ce5f814b63418b1ed312906210d5141819b3c64c Mon Sep 17 00:00:00 2001 From: FredericG Date: Tue, 2 Mar 2010 11:23:03 +0000 Subject: [PATCH] Introduction of PIOS_DEBUG git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@222 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PiOS/STM32F10x/pios_debug.c | 85 ++++++++++++++++++++++++++++++ flight/PiOS/inc/pios_debug.h | 33 ++++++++++++ flight/PiOS/pios.h | 1 + 3 files changed, 119 insertions(+) create mode 100644 flight/PiOS/STM32F10x/pios_debug.c create mode 100644 flight/PiOS/inc/pios_debug.h diff --git a/flight/PiOS/STM32F10x/pios_debug.c b/flight/PiOS/STM32F10x/pios_debug.c new file mode 100644 index 000000000..3324c4a46 --- /dev/null +++ b/flight/PiOS/STM32F10x/pios_debug.c @@ -0,0 +1,85 @@ +/** + ****************************************************************************** + * + * @file pios_debug.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief RC Servo routines + * @see The GNU Public License (GPL) Version 3 + * @defgroup PIOS_SERVO RC Servo Functions + * @{ + * + *****************************************************************************/ +/* + * 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 + */ + + +/* Project Includes */ +#include "pios.h" + + +/* Private Function Prototypes */ + +/** +* Initialise Debug-features +*/ +void PIOS_DEBUG_Init(void) +{ + // Initialise Servo pins as standard output pins + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_StructInit(&GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Pin = SERVO1_PIN | SERVO2_PIN | SERVO3_PIN | SERVO4_PIN; + GPIO_Init(SERVO1TO4_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SERVO5_PIN | SERVO6_PIN | SERVO7_PIN | SERVO8_PIN; + GPIO_Init(SERVO5TO8_PORT, &GPIO_InitStructure); +} + +/** +* Set debug-pin high +* \param pin 0 for S1 output +*/ +void PIOS_DEBUG_PinHigh(uint8_t pin) +{ + if (pin < 4) + { + SERVO1TO4_PORT->BSRR = (SERVO1_PIN<BSRR = (SERVO5_PIN<<(pin-4)); + } +} + +/** +* Set debug-pin low +* \param pin 0 for S1 output +*/ +void PIOS_DEBUG_PinLow(uint8_t pin) +{ + if (pin < 4) + { + SERVO1TO4_PORT->BRR = (SERVO1_PIN<BRR = (SERVO5_PIN<<(pin-4)); + } +} + + diff --git a/flight/PiOS/inc/pios_debug.h b/flight/PiOS/inc/pios_debug.h new file mode 100644 index 000000000..0b96d9f20 --- /dev/null +++ b/flight/PiOS/inc/pios_debug.h @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * + * @file pios_i2c.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Debug helper functions header. + * @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_DEBUG_H +#define PIOS_DEBUG_H + +void PIOS_DEBUG_Init(void); +void PIOS_DEBUG_PinHigh(uint8_t pin); +void PIOS_DEBUG_PinLow(uint8_t pin); + +#endif /* PIOS_DEBUG_H */ diff --git a/flight/PiOS/pios.h b/flight/PiOS/pios.h index 448059903..bb0342ea8 100644 --- a/flight/PiOS/pios.h +++ b/flight/PiOS/pios.h @@ -69,6 +69,7 @@ #include #include #include +#include /* PIOS Hardware Includes (Common) */ #include