1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

Moves pios_led functionality to pios_gpio and makes pios_led a thin layer over pios_gpio. Supports configuring multiple sets of GPIOs.

This commit is contained in:
Brian Webb 2013-07-16 21:09:48 -07:00
parent 2a0533e5e3
commit e246ecf536
30 changed files with 364 additions and 485 deletions

View File

@ -0,0 +1,81 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_LED LED Functions
* @brief STM32 Hardware LED handling code
* @{
*
* @file pios_led.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief LED functions, init, toggle, on & off.
* @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
*/
#include "pios.h"
#ifdef PIOS_INCLUDE_LED
#include <pios_gpio_priv.h>
#include <pios_gpio.h>
static uint32_t pios_led_gpios_id;
/**
* Initialises all the LED's
*/
int32_t PIOS_LED_Init(const struct pios_gpio_cfg *cfg)
{
PIOS_Assert(cfg);
return PIOS_GPIO_Init(&pios_led_gpios_id, cfg);
}
/**
* Turn on LED
* \param[in] LED LED id
*/
void PIOS_LED_On(uint32_t led_id)
{
PIOS_GPIO_On(pios_led_gpios_id, led_id);
}
/**
* Turn off LED
* \param[in] LED LED id
*/
void PIOS_LED_Off(uint32_t led_id)
{
PIOS_GPIO_Off(pios_led_gpios_id, led_id);
}
/**
* Toggle LED on/off
* \param[in] LED LED id
*/
void PIOS_LED_Toggle(uint32_t led_id)
{
PIOS_GPIO_Toggle(pios_led_gpios_id, led_id);
}
#endif /* PIOS_INCLUDE_LED */
/**
* @}
* @}
*/

View File

@ -32,11 +32,9 @@
#define PIOS_GPIO_H #define PIOS_GPIO_H
/* Public Functions */ /* Public Functions */
extern void PIOS_GPIO_Init(void); extern void PIOS_GPIO_On(uint32_t gpios_dev_id, uint8_t gpio_id);
extern void PIOS_GPIO_Enable(uint8_t Pin); extern void PIOS_GPIO_Off(uint32_t gpios_dev_id, uint8_t gpio_id);
extern void PIOS_GPIO_On(uint8_t Pin); extern void PIOS_GPIO_Toggle(uint32_t gpios_dev_id, uint8_t gpio_id);
extern void PIOS_GPIO_Off(uint8_t Pin);
extern void PIOS_GPIO_Toggle(uint8_t Pin);
#endif /* PIOS_GPIO_H */ #endif /* PIOS_GPIO_H */

View File

@ -31,21 +31,9 @@
#ifndef PIOS_LED_PRIV_H #ifndef PIOS_LED_PRIV_H
#define PIOS_LED_PRIV_H #define PIOS_LED_PRIV_H
#include <pios.h> #include <pios_gpio_priv.h>
#include <pios_stm32.h>
struct pios_led { extern int32_t PIOS_LED_Init(const struct pios_gpio_cfg *cfg);
struct stm32_gpio pin;
uint32_t remap;
bool active_high;
};
struct pios_led_cfg {
const struct pios_led *leds;
uint8_t num_leds;
};
extern int32_t PIOS_LED_Init(const struct pios_led_cfg *cfg);
#endif /* PIOS_LED_PRIV_H */ #endif /* PIOS_LED_PRIV_H */

View File

@ -81,6 +81,8 @@
#include "semphr.h" #include "semphr.h"
#endif #endif
#include <stdbool.h>
#include <pios_architecture.h> #include <pios_architecture.h>
#ifdef PIOS_INCLUDE_TASK_MONITOR #ifdef PIOS_INCLUDE_TASK_MONITOR

View File

@ -2,12 +2,12 @@
****************************************************************************** ******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer * @addtogroup PIOS PIOS Core hardware abstraction layer
* @{ * @{
* @defgroup PIOS_GPIO GPIO Functions * @addtogroup PIOS_GPIO GPIO Functions
* @brief GPIO hardware code for STM32 * @brief STM32 Hardware GPIO handling code
* @{ * @{
* *
* @file pios_gpio.c * @file pios_gpio.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013.
* @brief GPIO functions, init, toggle, on & off. * @brief GPIO functions, init, toggle, on & off.
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* *
@ -32,65 +32,125 @@
#ifdef PIOS_INCLUDE_GPIO #ifdef PIOS_INCLUDE_GPIO
/* Private Function Prototypes */ #include <pios_gpio_priv.h>
/* Local Variables */
static GPIO_TypeDef *GPIO_PORT[PIOS_GPIO_NUM] = PIOS_GPIO_PORTS;
static const uint32_t GPIO_PIN[PIOS_GPIO_NUM] = PIOS_GPIO_PINS;
static const uint32_t GPIO_CLK[PIOS_GPIO_NUM] = PIOS_GPIO_CLKS;
/** /**
* Initialises all the GPIO's * Initialises all the GPIO's
*/ */
void PIOS_GPIO_Init(void) int32_t PIOS_GPIO_Init(uint32_t *gpios_dev_id, const struct pios_gpio_cfg *cfg)
{ {
/* Do nothing */ PIOS_Assert(cfg);
*gpios_dev_id = (uint32_t)cfg;
for (uint8_t i = 0; i < cfg->num_gpios; i++) {
const struct pios_gpio *gpio = &(cfg->gpios[i]);
/* Enable the peripheral clock for the GPIO */
switch ((uint32_t)gpio->pin.gpio) {
case (uint32_t)GPIOA:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
break;
case (uint32_t)GPIOB:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
break;
case (uint32_t)GPIOC:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
break;
default:
PIOS_Assert(0);
break;
}
if (gpio->remap) {
GPIO_PinRemapConfig(gpio->remap, ENABLE);
}
GPIO_Init(gpio->pin.gpio, &gpio->pin.init);
PIOS_GPIO_Off(*gpios_dev_id, i);
}
return 0;
} }
/** /**
* Enable a GPIO Pin * Turn on GPIO
* \param[in] Pin Pin Number * \param[in] GPIO GPIO id
*/ */
void PIOS_GPIO_Enable(uint8_t Pin) void PIOS_GPIO_On(uint32_t gpios_dev_id, uint8_t gpio_id)
{ {
// RCC_APB2PeriphClockCmd(GPIO_CLK[Pin], ENABLE); const struct pios_gpio_cfg *gpio_cfg = (const struct pios_gpio_cfg *)gpios_dev_id;
GPIO_InitTypeDef GPIO_InitStructure; PIOS_Assert(gpio_cfg);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; if (gpio_id >= gpio_cfg->num_gpios) {
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; /* GPIO index out of range */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Pin]; return;
GPIO_Init(GPIO_PORT[Pin], &GPIO_InitStructure); }
/* GPIO's Off */ const struct pios_gpio *gpio = &(gpio_cfg->gpios[gpio_id]);
GPIO_PORT[Pin]->BSRR = GPIO_PIN[Pin];
if (gpio->active_low) {
GPIO_ResetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
} else {
GPIO_SetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
}
} }
/** /**
* Turn on Pin * Turn off GPIO
* \param[in] Pin Pin Number * \param[in] GPIO GPIO id
*/ */
void PIOS_GPIO_On(uint8_t Pin) void PIOS_GPIO_Off(uint32_t gpios_dev_id, uint8_t gpio_id)
{ {
GPIO_PORT[Pin]->BRR = GPIO_PIN[Pin]; const struct pios_gpio_cfg *gpio_cfg = (const struct pios_gpio_cfg *)gpios_dev_id;
PIOS_Assert(gpio_cfg);
if (gpio_id >= gpio_cfg->num_gpios) {
/* GPIO index out of range */
return;
}
const struct pios_gpio *gpio = &(gpio_cfg->gpios[gpio_id]);
if (gpio->active_low) {
GPIO_SetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
} else {
GPIO_ResetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
}
} }
/** /**
* Turn off Pin * Toggle GPIO on/off
* \param[in] Pin Pin Number * \param[in] GPIO GPIO id
*/ */
void PIOS_GPIO_Off(uint8_t Pin) void PIOS_GPIO_Toggle(uint32_t gpios_dev_id, uint8_t gpio_id)
{ {
GPIO_PORT[Pin]->BSRR = GPIO_PIN[Pin]; const struct pios_gpio_cfg *gpio_cfg = (const struct pios_gpio_cfg *)gpios_dev_id;
}
/** PIOS_Assert(gpio_cfg);
* Toggle Pin on/off
* \param[in] Pin Pin Number if (gpio_id >= gpio_cfg->num_gpios) {
*/ /* GPIO index out of range */
void PIOS_GPIO_Toggle(uint8_t Pin) return;
{ }
GPIO_PORT[Pin]->ODR ^= GPIO_PIN[Pin];
const struct pios_gpio *gpio = &(gpio_cfg->gpios[gpio_id]);
if (GPIO_ReadOutputDataBit(gpio->pin.gpio, gpio->pin.init.GPIO_Pin) == Bit_SET) {
if (gpio->active_low) {
PIOS_GPIO_On(gpios_dev_id, gpio_id);
} else {
PIOS_GPIO_Off(gpios_dev_id, gpio_id);
}
} else {
if (gpio->active_low) {
PIOS_GPIO_Off(gpios_dev_id, gpio_id);
} else {
PIOS_GPIO_On(gpios_dev_id, gpio_id);
}
}
} }
#endif /* PIOS_INCLUDE_GPIO */ #endif /* PIOS_INCLUDE_GPIO */

View File

@ -1,159 +0,0 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_LED LED Functions
* @brief STM32 Hardware LED handling code
* @{
*
* @file pios_led.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief LED functions, init, toggle, on & off.
* @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
*/
#include "pios.h"
#ifdef PIOS_INCLUDE_LED
#include <pios_led_priv.h>
static const struct pios_led_cfg *led_cfg;
/**
* Initialises all the LED's
*/
int32_t PIOS_LED_Init(const struct pios_led_cfg *cfg)
{
PIOS_Assert(cfg);
/* Store away the config in a global used by API functions */
led_cfg = cfg;
for (uint8_t i = 0; i < cfg->num_leds; i++) {
const struct pios_led *led = &(cfg->leds[i]);
/* Enable the peripheral clock for the GPIO */
switch ((uint32_t)led->pin.gpio) {
case (uint32_t)GPIOA:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
break;
case (uint32_t)GPIOB:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
break;
case (uint32_t)GPIOC:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
break;
default:
PIOS_Assert(0);
break;
}
if (led->remap) {
GPIO_PinRemapConfig(led->remap, ENABLE);
}
GPIO_Init(led->pin.gpio, &led->pin.init);
PIOS_LED_Off(i);
}
return 0;
}
/**
* Turn on LED
* \param[in] LED LED id
*/
void PIOS_LED_On(uint32_t led_id)
{
PIOS_Assert(led_cfg);
if (led_id >= led_cfg->num_leds) {
/* LED index out of range */
return;
}
const struct pios_led *led = &(led_cfg->leds[led_id]);
if (led->active_high) {
GPIO_SetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
} else {
GPIO_ResetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
}
}
/**
* Turn off LED
* \param[in] LED LED id
*/
void PIOS_LED_Off(uint32_t led_id)
{
PIOS_Assert(led_cfg);
if (led_id >= led_cfg->num_leds) {
/* LED index out of range */
return;
}
const struct pios_led *led = &(led_cfg->leds[led_id]);
if (led->active_high) {
GPIO_ResetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
} else {
GPIO_SetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
}
}
/**
* Toggle LED on/off
* \param[in] LED LED id
*/
void PIOS_LED_Toggle(uint32_t led_id)
{
PIOS_Assert(led_cfg);
if (led_id >= led_cfg->num_leds) {
/* LED index out of range */
return;
}
const struct pios_led *led = &(led_cfg->leds[led_id]);
if (GPIO_ReadOutputDataBit(led->pin.gpio, led->pin.init.GPIO_Pin) == Bit_SET) {
if (led->active_high) {
PIOS_LED_Off(led_id);
} else {
PIOS_LED_On(led_id);
}
} else {
if (led->active_high) {
PIOS_LED_On(led_id);
} else {
PIOS_LED_Off(led_id);
}
}
}
#endif /* PIOS_INCLUDE_LED */
/**
* @}
* @}
*/

View File

@ -2,8 +2,8 @@
****************************************************************************** ******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer * @addtogroup PIOS PIOS Core hardware abstraction layer
* @{ * @{
* @defgroup PIOS_GPIO GPIO Functions * @addtogroup PIOS_GPIO GPIO Functions
* @brief GPIO hardware code for STM32F4xx * @brief STM32 Hardware GPIO handling code
* @{ * @{
* *
* @file pios_gpio.c * @file pios_gpio.c
@ -32,64 +32,143 @@
#ifdef PIOS_INCLUDE_GPIO #ifdef PIOS_INCLUDE_GPIO
/* Private Function Prototypes */ #include <pios_gpio_priv.h>
/* Local Variables */
static GPIO_TypeDef *GPIO_PORT[PIOS_GPIO_NUM] = PIOS_GPIO_PORTS;
static const uint32_t GPIO_PIN[PIOS_GPIO_NUM] = PIOS_GPIO_PINS;
/** /**
* Initialises all the GPIO's * Initialises all the GPIO's
*/ */
void PIOS_GPIO_Init(void) int32_t PIOS_GPIO_Init(uint32_t *gpios_dev_id, const struct pios_gpio_cfg *cfg)
{ {
/* Do nothing */ PIOS_Assert(cfg);
*gpios_dev_id = (uint32_t)cfg;
for (uint8_t i = 0; i < cfg->num_gpios; i++) {
const struct pios_gpio *gpio = &(cfg->gpios[i]);
/* Enable the peripheral clock for the GPIO */
switch ((uint32_t)gpio->pin.gpio) {
case (uint32_t)GPIOA:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
break;
case (uint32_t)GPIOB:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
break;
case (uint32_t)GPIOC:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
break;
case (uint32_t)GPIOD:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
break;
case (uint32_t)GPIOE:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
break;
case (uint32_t)GPIOF:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
break;
case (uint32_t)GPIOG:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
break;
case (uint32_t)GPIOH:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);
break;
case (uint32_t)GPIOI:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI, ENABLE);
break;
default:
PIOS_Assert(0);
break;
}
if (gpio->remap) {
GPIO_PinAFConfig(gpio->pin.gpio, gpio->pin.init.GPIO_Pin, gpio->remap);
}
GPIO_Init(gpio->pin.gpio, &gpio->pin.init);
PIOS_GPIO_Off(*gpios_dev_id, i);
}
return 0;
} }
/** /**
* Enable a GPIO Pin * Turn on GPIO
* \param[in] Pin Pin Number * \param[in] GPIO GPIO id
*/ */
void PIOS_GPIO_Enable(uint8_t Pin) void PIOS_GPIO_On(uint32_t gpios_dev_id, uint8_t gpio_id)
{ {
GPIO_InitTypeDef GPIO_InitStructure; const struct pios_gpio_cfg *gpio_cfg = (const struct pios_gpio_cfg *)gpios_dev_id;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; PIOS_Assert(gpio_cfg);
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Pin];
GPIO_Init(GPIO_PORT[Pin], &GPIO_InitStructure);
/* GPIO's Off */ if (gpio_id >= gpio_cfg->num_gpios) {
PIOS_GPIO_Off(Pin); /* GPIO index out of range */
return;
}
const struct pios_gpio *gpio = &(gpio_cfg->gpios[gpio_id]);
if (gpio->active_low) {
GPIO_ResetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
} else {
GPIO_SetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
}
} }
/** /**
* Turn on Pin * Turn off GPIO
* \param[in] Pin Pin Number * \param[in] GPIO GPIO id
*/ */
void PIOS_GPIO_On(uint8_t Pin) void PIOS_GPIO_Off(uint32_t gpios_dev_id, uint8_t gpio_id)
{ {
GPIO_ResetBits(GPIO_PORT[Pin], GPIO_PIN[Pin]); const struct pios_gpio_cfg *gpio_cfg = (const struct pios_gpio_cfg *)gpios_dev_id;
PIOS_Assert(gpio_cfg);
if (gpio_id >= gpio_cfg->num_gpios) {
/* GPIO index out of range */
return;
}
const struct pios_gpio *gpio = &(gpio_cfg->gpios[gpio_id]);
if (gpio->active_low) {
GPIO_SetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
} else {
GPIO_ResetBits(gpio->pin.gpio, gpio->pin.init.GPIO_Pin);
}
} }
/** /**
* Turn off Pin * Toggle GPIO on/off
* \param[in] Pin Pin Number * \param[in] GPIO GPIO id
*/ */
void PIOS_GPIO_Off(uint8_t Pin) void PIOS_GPIO_Toggle(uint32_t gpios_dev_id, uint8_t gpio_id)
{ {
GPIO_SetBits(GPIO_PORT[Pin], GPIO_PIN[Pin]); const struct pios_gpio_cfg *gpio_cfg = (const struct pios_gpio_cfg *)gpios_dev_id;
}
/** PIOS_Assert(gpio_cfg);
* Toggle Pin on/off
* \param[in] Pin Pin Number if (gpio_id >= gpio_cfg->num_gpios) {
*/ /* GPIO index out of range */
void PIOS_GPIO_Toggle(uint8_t Pin) return;
{ }
GPIO_ToggleBits(GPIO_PORT[Pin], GPIO_PIN[Pin]);
const struct pios_gpio *gpio = &(gpio_cfg->gpios[gpio_id]);
if (GPIO_ReadOutputDataBit(gpio->pin.gpio, gpio->pin.init.GPIO_Pin) == Bit_SET) {
if (gpio->active_low) {
PIOS_GPIO_On(gpios_dev_id, gpio_id);
} else {
PIOS_GPIO_Off(gpios_dev_id, gpio_id);
}
} else {
if (gpio->active_low) {
PIOS_GPIO_Off(gpios_dev_id, gpio_id);
} else {
PIOS_GPIO_On(gpios_dev_id, gpio_id);
}
}
} }
#endif /* PIOS_INCLUDE_GPIO */ #endif /* PIOS_INCLUDE_GPIO */

View File

@ -1,177 +0,0 @@
/**
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_LED LED Functions
* @brief STM32 Hardware LED handling code
* @{
*
* @file pios_led.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief LED functions, init, toggle, on & off.
* @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
*/
#include "pios.h"
#ifdef PIOS_INCLUDE_LED
#include <pios_led_priv.h>
static const struct pios_led_cfg *led_cfg;
/**
* Initialises all the LED's
*/
int32_t PIOS_LED_Init(const struct pios_led_cfg *cfg)
{
PIOS_Assert(cfg);
/* Store away the config in a global used by API functions */
led_cfg = cfg;
for (uint8_t i = 0; i < cfg->num_leds; i++) {
const struct pios_led *led = &(cfg->leds[i]);
/* Enable the peripheral clock for the GPIO */
switch ((uint32_t)led->pin.gpio) {
case (uint32_t)GPIOA:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
break;
case (uint32_t)GPIOB:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
break;
case (uint32_t)GPIOC:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
break;
case (uint32_t)GPIOD:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
break;
case (uint32_t)GPIOE:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
break;
case (uint32_t)GPIOF:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
break;
case (uint32_t)GPIOG:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
break;
case (uint32_t)GPIOH:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);
break;
case (uint32_t)GPIOI:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI, ENABLE);
break;
default:
PIOS_Assert(0);
break;
}
if (led->remap) {
GPIO_PinAFConfig(led->pin.gpio, led->pin.init.GPIO_Pin, led->remap);
}
GPIO_Init(led->pin.gpio, &led->pin.init);
PIOS_LED_Off(i);
}
return 0;
}
/**
* Turn on LED
* \param[in] LED LED id
*/
void PIOS_LED_On(uint32_t led_id)
{
PIOS_Assert(led_cfg);
if (led_id >= led_cfg->num_leds) {
/* LED index out of range */
return;
}
const struct pios_led *led = &(led_cfg->leds[led_id]);
if (led->active_high) {
GPIO_SetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
} else {
GPIO_ResetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
}
}
/**
* Turn off LED
* \param[in] LED LED id
*/
void PIOS_LED_Off(uint32_t led_id)
{
PIOS_Assert(led_cfg);
if (led_id >= led_cfg->num_leds) {
/* LED index out of range */
return;
}
const struct pios_led *led = &(led_cfg->leds[led_id]);
if (led->active_high) {
GPIO_ResetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
} else {
GPIO_SetBits(led->pin.gpio, led->pin.init.GPIO_Pin);
}
}
/**
* Toggle LED on/off
* \param[in] LED LED id
*/
void PIOS_LED_Toggle(uint32_t led_id)
{
PIOS_Assert(led_cfg);
if (led_id >= led_cfg->num_leds) {
/* LED index out of range */
return;
}
const struct pios_led *led = &(led_cfg->leds[led_id]);
if (GPIO_ReadOutputDataBit(led->pin.gpio, led->pin.init.GPIO_Pin) == Bit_SET) {
if (led->active_high) {
PIOS_LED_Off(led_id);
} else {
PIOS_LED_On(led_id);
}
} else {
if (led->active_high) {
PIOS_LED_On(led_id);
} else {
PIOS_LED_Off(led_id);
}
}
}
#endif /* PIOS_INCLUDE_LED */
/**
* @}
* @}
*/

View File

@ -31,7 +31,7 @@
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
#include <pios_led_priv.h> #include <pios_led_priv.h>
static const struct pios_led pios_leds_cc[] = { static const struct pios_gpio pios_leds_cc[] = {
[PIOS_LED_HEARTBEAT] = { [PIOS_LED_HEARTBEAT] = {
.pin = { .pin = {
.gpio = GPIOA, .gpio = GPIOA,
@ -41,15 +41,16 @@ static const struct pios_led pios_leds_cc[] = {
.GPIO_Speed = GPIO_Speed_50MHz, .GPIO_Speed = GPIO_Speed_50MHz,
}, },
}, },
.active_low = true
}, },
}; };
static const struct pios_led_cfg pios_led_cfg_cc = { static const struct pios_gpio_cfg pios_led_cfg_cc = {
.leds = pios_leds_cc, .gpios = pios_leds_cc,
.num_leds = NELEMENTS(pios_leds_cc), .num_gpios = NELEMENTS(pios_leds_cc),
}; };
static const struct pios_led pios_leds_cc3d[] = { static const struct pios_gpio pios_leds_cc3d[] = {
[PIOS_LED_HEARTBEAT] = { [PIOS_LED_HEARTBEAT] = {
.pin = { .pin = {
.gpio = GPIOB, .gpio = GPIOB,
@ -60,15 +61,16 @@ static const struct pios_led pios_leds_cc3d[] = {
}, },
}, },
.remap = GPIO_Remap_SWJ_JTAGDisable, .remap = GPIO_Remap_SWJ_JTAGDisable,
.active_low = true
}, },
}; };
static const struct pios_led_cfg pios_led_cfg_cc3d = { static const struct pios_gpio_cfg pios_led_cfg_cc3d = {
.leds = pios_leds_cc3d, .gpios = pios_leds_cc3d,
.num_leds = NELEMENTS(pios_leds_cc3d), .num_gpios = NELEMENTS(pios_leds_cc3d),
}; };
const struct pios_led_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(uint32_t board_revision) const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(uint32_t board_revision)
{ {
switch (board_revision) { switch (board_revision) {
case BOARD_REVISION_CC: return &pios_led_cfg_cc; case BOARD_REVISION_CC: return &pios_led_cfg_cc;

View File

@ -59,13 +59,10 @@ void PIOS_Board_Init(void)
/* Delay system */ /* Delay system */
PIOS_DELAY_Init(); PIOS_DELAY_Init();
/* Initialize the PiOS library */
PIOS_GPIO_Init();
const struct pios_board_info *bdinfo = &pios_board_info_blob; const struct pios_board_info *bdinfo = &pios_board_info_blob;
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
const struct pios_led_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); const struct pios_gpio_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
PIOS_Assert(led_cfg); PIOS_Assert(led_cfg);
PIOS_LED_Init(led_cfg); PIOS_LED_Init(led_cfg);
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */

View File

@ -145,7 +145,7 @@ void PIOS_Board_Init(void)
const struct pios_board_info *bdinfo = &pios_board_info_blob; const struct pios_board_info *bdinfo = &pios_board_info_blob;
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
const struct pios_led_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); const struct pios_gpio_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
PIOS_Assert(led_cfg); PIOS_Assert(led_cfg);
PIOS_LED_Init(led_cfg); PIOS_LED_Init(led_cfg);
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */
@ -865,8 +865,6 @@ void PIOS_Board_Init(void)
PIOS_Assert(0); PIOS_Assert(0);
} }
PIOS_GPIO_Init();
/* Make sure we have at least one telemetry link configured or else fail initialization */ /* Make sure we have at least one telemetry link configured or else fail initialization */
PIOS_Assert(pios_com_telem_rf_id || pios_com_telem_usb_id); PIOS_Assert(pios_com_telem_rf_id || pios_com_telem_usb_id);
} }

View File

@ -27,7 +27,7 @@
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
#include <pios_led_priv.h> #include <pios_led_priv.h>
static const struct pios_led pios_leds[] = { static const struct pios_gpio pios_leds[] = {
[PIOS_LED_USB] = { [PIOS_LED_USB] = {
.pin = { .pin = {
.gpio = GPIOA, .gpio = GPIOA,
@ -37,6 +37,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_Speed = GPIO_Speed_50MHz, .GPIO_Speed = GPIO_Speed_50MHz,
}, },
}, },
.active_low = true
}, },
[PIOS_LED_LINK] = { [PIOS_LED_LINK] = {
.pin = { .pin = {
@ -47,6 +48,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_Speed = GPIO_Speed_50MHz, .GPIO_Speed = GPIO_Speed_50MHz,
}, },
}, },
.active_low = true
}, },
[PIOS_LED_RX] = { [PIOS_LED_RX] = {
.pin = { .pin = {
@ -57,6 +59,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_Speed = GPIO_Speed_50MHz, .GPIO_Speed = GPIO_Speed_50MHz,
}, },
}, },
.active_low = true
}, },
[PIOS_LED_TX] = { [PIOS_LED_TX] = {
.pin = { .pin = {
@ -67,6 +70,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_Speed = GPIO_Speed_50MHz, .GPIO_Speed = GPIO_Speed_50MHz,
}, },
}, },
.active_low = true
}, },
#ifdef PIOS_RFM22B_DEBUG_ON_TELEM #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
[PIOS_LED_D1] = { [PIOS_LED_D1] = {
@ -112,12 +116,12 @@ static const struct pios_led pios_leds[] = {
#endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */ #endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */
}; };
static const struct pios_led_cfg pios_led_cfg = { static const struct pios_gpio_cfg pios_led_cfg = {
.leds = pios_leds, .gpios = pios_leds,
.num_leds = NELEMENTS(pios_leds), .num_gpios = NELEMENTS(pios_leds),
}; };
const struct pios_led_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision) const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision)
{ {
return &pios_led_cfg; return &pios_led_cfg;
} }

View File

@ -59,9 +59,6 @@ void PIOS_Board_Init(void)
/* Delay system */ /* Delay system */
PIOS_DELAY_Init(); PIOS_DELAY_Init();
/* Initialize the PiOS library */
PIOS_GPIO_Init();
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
PIOS_LED_Init(&pios_led_cfg); PIOS_LED_Init(&pios_led_cfg);
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */

View File

@ -485,7 +485,6 @@ void PIOS_Board_Init(void)
#ifdef PIOS_INCLUDE_ADC #ifdef PIOS_INCLUDE_ADC
PIOS_ADC_Init(); PIOS_ADC_Init();
#endif #endif
PIOS_GPIO_Init();
} }
static void PIOS_Board_PPM_callback(const int16_t *channels) static void PIOS_Board_PPM_callback(const int16_t *channels)

View File

@ -30,7 +30,7 @@
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
#include <pios_led_priv.h> #include <pios_led_priv.h>
static const struct pios_led pios_leds[] = { static const struct pios_gpio pios_leds[] = {
[PIOS_LED_HEARTBEAT] = { [PIOS_LED_HEARTBEAT] = {
.pin = { .pin = {
.gpio = GPIOB, .gpio = GPIOB,
@ -42,6 +42,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
[PIOS_LED_ALARM] = { [PIOS_LED_ALARM] = {
.pin = { .pin = {
@ -54,15 +55,16 @@ static const struct pios_led pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
}; };
static const struct pios_led_cfg pios_led_cfg = { static const struct pios_gpio_cfg pios_led_cfg = {
.leds = pios_leds, .gpios = pios_leds,
.num_leds = NELEMENTS(pios_leds), .num_gpios = NELEMENTS(pios_leds),
}; };
const struct pios_led_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision) const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision)
{ {
return &pios_led_cfg; return &pios_led_cfg;
} }

View File

@ -35,6 +35,7 @@
#define PIOS_INCLUDE_USB_HID #define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP #define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_COM_MSG #define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER

View File

@ -61,7 +61,7 @@
#define PIOS_INCLUDE_ADC #define PIOS_INCLUDE_ADC
#define PIOS_INCLUDE_I2C #define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SPI
/* #define PIOS_INCLUDE_GPIO */ #define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_EXTI
#define PIOS_INCLUDE_WDG #define PIOS_INCLUDE_WDG

View File

@ -28,7 +28,7 @@
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
#include <pios_led_priv.h> #include <pios_led_priv.h>
static const struct pios_led pios_leds[] = { static const struct pios_gpio pios_leds[] = {
[PIOS_LED_HEARTBEAT] = { [PIOS_LED_HEARTBEAT] = {
.pin = { .pin = {
.gpio = GPIOB, .gpio = GPIOB,
@ -40,6 +40,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
[PIOS_LED_ALARM] = { [PIOS_LED_ALARM] = {
.pin = { .pin = {
@ -52,6 +53,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
#ifdef PIOS_RFM22B_DEBUG_ON_TELEM #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
[PIOS_LED_D1] = { [PIOS_LED_D1] = {
@ -105,12 +107,12 @@ static const struct pios_led pios_leds[] = {
#endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */ #endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */
}; };
static const struct pios_led_cfg pios_led_cfg = { static const struct pios_gpio_cfg pios_led_cfg = {
.leds = pios_leds, .gpios = pios_leds,
.num_leds = NELEMENTS(pios_leds), .num_gpios = NELEMENTS(pios_leds),
}; };
static const struct pios_led pios_leds_v2[] = { static const struct pios_gpio pios_leds_v2[] = {
[PIOS_LED_HEARTBEAT] = { [PIOS_LED_HEARTBEAT] = {
.pin = { .pin = {
.gpio = GPIOB, .gpio = GPIOB,
@ -122,6 +124,7 @@ static const struct pios_led pios_leds_v2[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
[PIOS_LED_ALARM] = { [PIOS_LED_ALARM] = {
.pin = { .pin = {
@ -134,6 +137,7 @@ static const struct pios_led pios_leds_v2[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
#ifdef PIOS_RFM22B_DEBUG_ON_TELEM #ifdef PIOS_RFM22B_DEBUG_ON_TELEM
[PIOS_LED_D1] = { [PIOS_LED_D1] = {
@ -187,12 +191,12 @@ static const struct pios_led pios_leds_v2[] = {
#endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */ #endif /* ifdef PIOS_RFM22B_DEBUG_ON_TELEM */
}; };
static const struct pios_led_cfg pios_led_v2_cfg = { static const struct pios_gpio_cfg pios_led_v2_cfg = {
.leds = pios_leds_v2, .gpios = pios_leds_v2,
.num_leds = NELEMENTS(pios_leds_v2), .num_gpios = NELEMENTS(pios_leds_v2),
}; };
const struct pios_led_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(uint32_t board_revision) const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(uint32_t board_revision)
{ {
switch (board_revision) { switch (board_revision) {
case 2: case 2:

View File

@ -35,6 +35,7 @@
#define PIOS_INCLUDE_USB_HID #define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP #define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_COM_MSG #define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER

View File

@ -51,7 +51,7 @@ void PIOS_Board_Init()
const struct pios_board_info *bdinfo = &pios_board_info_blob; const struct pios_board_info *bdinfo = &pios_board_info_blob;
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
const struct pios_led_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); const struct pios_gpio_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
PIOS_Assert(led_cfg); PIOS_Assert(led_cfg);
PIOS_LED_Init(led_cfg); PIOS_LED_Init(led_cfg);
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */

View File

@ -61,7 +61,7 @@
#define PIOS_INCLUDE_ADC #define PIOS_INCLUDE_ADC
#define PIOS_INCLUDE_I2C #define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SPI
/* #define PIOS_INCLUDE_GPIO */ #define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_EXTI
#define PIOS_INCLUDE_WDG #define PIOS_INCLUDE_WDG

View File

@ -346,7 +346,7 @@ void PIOS_Board_Init(void)
const struct pios_board_info *bdinfo = &pios_board_info_blob; const struct pios_board_info *bdinfo = &pios_board_info_blob;
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
const struct pios_led_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); const struct pios_gpio_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
PIOS_Assert(led_cfg); PIOS_Assert(led_cfg);
PIOS_LED_Init(led_cfg); PIOS_LED_Init(led_cfg);
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */

View File

@ -28,7 +28,7 @@
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
#include <pios_led_priv.h> #include <pios_led_priv.h>
static const struct pios_led pios_leds[] = { static const struct pios_gpio pios_leds[] = {
[PIOS_LED_HEARTBEAT] = { [PIOS_LED_HEARTBEAT] = {
.pin = { .pin = {
.gpio = GPIOE, .gpio = GPIOE,
@ -40,6 +40,7 @@ static const struct pios_led pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
[PIOS_LED_ALARM] = { [PIOS_LED_ALARM] = {
.pin = { .pin = {
@ -52,15 +53,16 @@ static const struct pios_led pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_UP .GPIO_PuPd = GPIO_PuPd_UP
}, },
}, },
.active_low = true
}, },
}; };
static const struct pios_led_cfg pios_led_cfg = { static const struct pios_gpio_cfg pios_led_cfg = {
.leds = pios_leds, .gpios = pios_leds,
.num_leds = NELEMENTS(pios_leds), .num_gpios = NELEMENTS(pios_leds),
}; };
const struct pios_led_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision) const struct pios_gpio_cfg *PIOS_BOARD_HW_DEFS_GetLedCfg(__attribute__((unused)) uint32_t board_revision)
{ {
return &pios_led_cfg; return &pios_led_cfg;
} }

View File

@ -35,6 +35,7 @@
#define PIOS_INCLUDE_USB_HID #define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP #define PIOS_INCLUDE_IAP
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_COM_MSG #define PIOS_INCLUDE_COM_MSG
#define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER

View File

@ -61,7 +61,7 @@
#define PIOS_INCLUDE_ADC #define PIOS_INCLUDE_ADC
#define PIOS_INCLUDE_I2C #define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SPI
/* #define PIOS_INCLUDE_GPIO */ #define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_EXTI
#define PIOS_INCLUDE_WDG #define PIOS_INCLUDE_WDG

View File

@ -39,6 +39,7 @@ HWDEFSINC = ../../boards/$(BOARD_NAME)
# Use file-extension c for "c-only"-files # Use file-extension c for "c-only"-files
SRC += $(OPSYSTEM)/main.c SRC += $(OPSYSTEM)/main.c
SRC += $(OPSYSTEM)/pios_board.c SRC += $(OPSYSTEM)/pios_board.c
SRC += $(PIOSCOMMON)/pios_led.c
## PIOS Hardware ## PIOS Hardware
ifeq ($(MCU),cortex-m3) ifeq ($(MCU),cortex-m3)
include $(PIOS)/stm32f10x/library.mk include $(PIOS)/stm32f10x/library.mk

View File

@ -35,6 +35,7 @@
#define PIOS_INCLUDE_SYS #define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT

View File

@ -41,13 +41,8 @@ void PIOS_Board_Init(void)
/* LEDs */ /* LEDs */
#if defined(PIOS_INCLUDE_LED) #if defined(PIOS_INCLUDE_LED)
const struct pios_led_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); const struct pios_gpio_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
PIOS_Assert(led_cfg); PIOS_Assert(led_cfg);
PIOS_LED_Init(led_cfg); PIOS_LED_Init(led_cfg);
#endif /* PIOS_INCLUDE_LED */ #endif /* PIOS_INCLUDE_LED */
/* Initialize the PiOS library */
#if defined(PIOS_INCLUDE_GPIO)
PIOS_GPIO_Init();
#endif /* PIOS_INCLUDE_GPIO */
} }

View File

@ -86,6 +86,7 @@ SRC += $(PIOSCOMMON)/pios_rfm22b.c
SRC += $(PIOSCOMMON)/pios_rfm22b_com.c SRC += $(PIOSCOMMON)/pios_rfm22b_com.c
SRC += $(PIOSCOMMON)/pios_sbus.c SRC += $(PIOSCOMMON)/pios_sbus.c
SRC += $(PIOSCOMMON)/pios_sdcard.c SRC += $(PIOSCOMMON)/pios_sdcard.c
SRC += $(PIOSCOMMON)/pios_led.c
## PIOS USB related files ## PIOS USB related files
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c

View File

@ -55,6 +55,7 @@ SRC += $(PIOSCOMMON)/pios_com_msg.c
SRC += $(PIOSCOMMON)/pios_iap.c SRC += $(PIOSCOMMON)/pios_iap.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
SRC += $(PIOSCOMMON)/pios_usb_util.c SRC += $(PIOSCOMMON)/pios_usb_util.c
SRC += $(PIOSCOMMON)/pios_led.c
## Misc library functions ## Misc library functions
SRC += $(FLIGHTLIB)/op_dfu.c SRC += $(FLIGHTLIB)/op_dfu.c