1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Fix pios debug pin functions and defines (thanks to Mathieu for the patch)

This commit is contained in:
Oleg Semyonov 2013-04-26 17:59:52 +03:00
parent fa8c2f239c
commit 45f456580f
12 changed files with 33 additions and 27 deletions

View File

@ -41,7 +41,7 @@
// //
#define DEBUG_PORT PIOS_COM_GPS #define DEBUG_PORT PIOS_COM_GPS
//#define ENABLE_DEBUG_MSG //#define ENABLE_DEBUG_MSG
//#define USE_DEBUG_PINS //#define PIOS_ENABLE_DEBUG_PINS
//#define DUMP_CONFIG // Enable this do read and dump the OSD config //#define DUMP_CONFIG // Enable this do read and dump the OSD config
// //
@ -78,7 +78,7 @@
#define OSDMSG_GPS_STAT_FIX 0x2B #define OSDMSG_GPS_STAT_FIX 0x2B
#define OSDMSG_GPS_STAT_HB_FLAG 0x10 #define OSDMSG_GPS_STAT_HB_FLAG 0x10
#ifdef USE_DEBUG_PINS #ifdef PIOS_ENABLE_DEBUG_PINS
#define DEBUG_PIN_RUNNING 0 #define DEBUG_PIN_RUNNING 0
#define DEBUG_PIN_I2C 1 #define DEBUG_PIN_I2C 1
#define DebugPinHigh(x) PIOS_DEBUG_PinHigh(x) #define DebugPinHigh(x) PIOS_DEBUG_PinHigh(x)

View File

@ -65,6 +65,7 @@
/* PIOS debug interface */ /* PIOS debug interface */
/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */
/* #define DEBUG_LEVEL 0 */ /* #define DEBUG_LEVEL 0 */
/* #define PIOS_ENABLE_DEBUG_PINS */
#include <pios_debug.h> #include <pios_debug.h>
/* PIOS common functions */ /* PIOS common functions */

View File

@ -7,7 +7,7 @@
* @{ * @{
* *
* @file pios_debug.c * @file pios_debug.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
* @brief Debugging Functions * @brief Debugging Functions
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* *
@ -60,13 +60,13 @@ void PIOS_DEBUG_Init(const struct pios_tim_channel * channels, uint8_t num_chann
GPIO_StructInit(&GPIO_InitStructure); GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = chan->init->GPIO_Pin; GPIO_InitStructure.GPIO_Pin = chan->pin.init.GPIO_Pin;
/* Initialize the GPIO */ /* Initialize the GPIO */
GPIO_Init(chan->init->port, &GPIO_InitStructure); GPIO_Init(chan->pin.gpio, &GPIO_InitStructure);
/* Set the pin low */ /* Set the pin low */
GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET);
} }
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }
@ -84,7 +84,7 @@ void PIOS_DEBUG_PinHigh(uint8_t pin)
const struct pios_tim_channel * chan = &debug_channels[pin]; const struct pios_tim_channel * chan = &debug_channels[pin];
GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_Set); GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_SET);
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }
@ -102,7 +102,7 @@ void PIOS_DEBUG_PinLow(uint8_t pin)
const struct pios_tim_channel * chan = &debug_channels[pin]; const struct pios_tim_channel * chan = &debug_channels[pin];
GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET);
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }
@ -124,8 +124,8 @@ void PIOS_DEBUG_PinValue8Bit(uint8_t value)
* This is sketchy since it assumes a particular ordering * This is sketchy since it assumes a particular ordering
* and bitwise layout of the channels provided to the debug code. * and bitwise layout of the channels provided to the debug code.
*/ */
debug_channels[0].init.port->BSRR = bsrr_l; debug_channels[0].pin.gpio->BSRR = bsrr_l;
debug_channels[4].init.port->BSRR = bsrr_h; debug_channels[4].pin.gpio->BSRR = bsrr_h;
PIOS_IRQ_Enable(); PIOS_IRQ_Enable();
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
@ -143,7 +143,7 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value)
* and bitwise layout of the channels provided to the debug code. * and bitwise layout of the channels provided to the debug code.
*/ */
uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6); uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6);
debug_channels[0].init.port->BSRR = bsrr_l; debug_channels[0].pin.gpio->BSRR = bsrr_l;
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }

View File

@ -7,7 +7,7 @@
* @{ * @{
* *
* @file pios_debug.c * @file pios_debug.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
* @brief Debugging Functions * @brief Debugging Functions
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* *
@ -60,13 +60,13 @@ void PIOS_DEBUG_Init(const struct pios_tim_channel * channels, uint8_t num_chann
GPIO_StructInit(&GPIO_InitStructure); GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = chan->init->GPIO_Pin; GPIO_InitStructure.GPIO_Pin = chan->pin.init.GPIO_Pin;
/* Initialize the GPIO */ /* Initialize the GPIO */
GPIO_Init(chan->init->port, &GPIO_InitStructure); GPIO_Init(chan->pin.gpio, &GPIO_InitStructure);
/* Set the pin low */ /* Set the pin low */
GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET);
} }
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }
@ -84,7 +84,7 @@ void PIOS_DEBUG_PinHigh(uint8_t pin)
const struct pios_tim_channel * chan = &debug_channels[pin]; const struct pios_tim_channel * chan = &debug_channels[pin];
GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_Set); GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_SET);
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }
@ -102,7 +102,7 @@ void PIOS_DEBUG_PinLow(uint8_t pin)
const struct pios_tim_channel * chan = &debug_channels[pin]; const struct pios_tim_channel * chan = &debug_channels[pin];
GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET);
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }
@ -124,8 +124,8 @@ void PIOS_DEBUG_PinValue8Bit(uint8_t value)
* This is sketchy since it assumes a particular ordering * This is sketchy since it assumes a particular ordering
* and bitwise layout of the channels provided to the debug code. * and bitwise layout of the channels provided to the debug code.
*/ */
debug_channels[0].init.port->BSRR = bsrr_l; debug_channels[0].pin.gpio->BSRR = bsrr_l;
debug_channels[4].init.port->BSRR = bsrr_h; debug_channels[4].pin.gpio->BSRR = bsrr_h;
PIOS_IRQ_Enable(); PIOS_IRQ_Enable();
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
@ -143,7 +143,7 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value)
* and bitwise layout of the channels provided to the debug code. * and bitwise layout of the channels provided to the debug code.
*/ */
uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6); uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6);
debug_channels[0].init.port->BSRR = bsrr_l; debug_channels[0].pin.gpio->BSRR = bsrr_l;
#endif // PIOS_ENABLE_DEBUG_PINS #endif // PIOS_ENABLE_DEBUG_PINS
} }

View File

@ -38,6 +38,7 @@
/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */
/* #define DEBUG_LEVEL 0 */ /* #define DEBUG_LEVEL 0 */
/* #define PIOS_ENABLE_DEBUG_PINS */
/* PIOS FreeRTOS support */ /* PIOS FreeRTOS support */
#define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_FREERTOS

View File

@ -773,7 +773,7 @@ void PIOS_Board_Init(void) {
/* Remap AFIO pin for PB4 (Servo 5 Out)*/ /* Remap AFIO pin for PB4 (Servo 5 Out)*/
GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE);
#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS #ifndef PIOS_ENABLE_DEBUG_PINS
switch (hwsettings_rcvrport) { switch (hwsettings_rcvrport) {
case HWSETTINGS_CC_RCVRPORT_DISABLED: case HWSETTINGS_CC_RCVRPORT_DISABLED:
case HWSETTINGS_CC_RCVRPORT_PWM: case HWSETTINGS_CC_RCVRPORT_PWM:
@ -787,8 +787,8 @@ void PIOS_Board_Init(void) {
break; break;
} }
#else #else
PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels)); PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins));
#endif /* PIOS_DEBUG_ENABLE_DEBUG_PINS */ #endif /* PIOS_ENABLE_DEBUG_PINS */
switch(bdinfo->board_rev) { switch(bdinfo->board_rev) {
case BOARD_REVISION_CC: case BOARD_REVISION_CC:

View File

@ -38,6 +38,7 @@
/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */
/* #define DEBUG_LEVEL 0 */ /* #define DEBUG_LEVEL 0 */
/* #define PIOS_ENABLE_DEBUG_PINS */
/* PIOS FreeRTOS support */ /* PIOS FreeRTOS support */
#define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_FREERTOS

View File

@ -38,6 +38,7 @@
/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */
/* #define DEBUG_LEVEL 0 */ /* #define DEBUG_LEVEL 0 */
/* #define PIOS_ENABLE_DEBUG_PINS */
/* PIOS FreeRTOS support */ /* PIOS FreeRTOS support */
#define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_FREERTOS

View File

@ -38,6 +38,7 @@
/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */
/* #define DEBUG_LEVEL 0 */ /* #define DEBUG_LEVEL 0 */
/* #define PIOS_ENABLE_DEBUG_PINS */
/* PIOS FreeRTOS support */ /* PIOS FreeRTOS support */
#define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_FREERTOS

View File

@ -777,11 +777,11 @@ void PIOS_Board_Init(void) {
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id; pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
#endif /* PIOS_INCLUDE_GCSRCVR */ #endif /* PIOS_INCLUDE_GCSRCVR */
#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS #ifndef PIOS_ENABLE_DEBUG_PINS
// pios_servo_cfg points to the correct configuration based on input port settings // pios_servo_cfg points to the correct configuration based on input port settings
PIOS_Servo_Init(pios_servo_cfg); PIOS_Servo_Init(pios_servo_cfg);
#else #else
PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels)); PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins));
#endif #endif
if (PIOS_I2C_Init(&pios_i2c_mag_pressure_adapter_id, &pios_i2c_mag_pressure_adapter_cfg)) { if (PIOS_I2C_Init(&pios_i2c_mag_pressure_adapter_id, &pios_i2c_mag_pressure_adapter_cfg)) {

View File

@ -38,6 +38,7 @@
/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */
/* #define DEBUG_LEVEL 0 */ /* #define DEBUG_LEVEL 0 */
/* #define PIOS_ENABLE_DEBUG_PINS */
/* PIOS FreeRTOS support */ /* PIOS FreeRTOS support */
#define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_FREERTOS

View File

@ -826,7 +826,7 @@ void PIOS_Board_Init(void) {
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id; pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
#endif /* PIOS_INCLUDE_GCSRCVR */ #endif /* PIOS_INCLUDE_GCSRCVR */
#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS #ifndef PIOS_ENABLE_DEBUG_PINS
switch (hwsettings_rcvrport) { switch (hwsettings_rcvrport) {
case HWSETTINGS_RV_RCVRPORT_DISABLED: case HWSETTINGS_RV_RCVRPORT_DISABLED:
case HWSETTINGS_RV_RCVRPORT_PWM: case HWSETTINGS_RV_RCVRPORT_PWM:
@ -842,7 +842,7 @@ void PIOS_Board_Init(void) {
break; break;
} }
#else #else
PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels)); PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins));
#endif #endif
if (PIOS_I2C_Init(&pios_i2c_mag_adapter_id, &pios_i2c_mag_adapter_cfg)) { if (PIOS_I2C_Init(&pios_i2c_mag_adapter_id, &pios_i2c_mag_adapter_cfg)) {