2011-01-13 16:57:30 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file pios_board.c
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief Defines board specific static initializers for hardware for the PipBee board.
|
|
|
|
* @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>
|
|
|
|
|
2012-01-23 00:22:59 +01:00
|
|
|
#if defined(PIOS_INCLUDE_LED)
|
|
|
|
|
|
|
|
#include <pios_led_priv.h>
|
|
|
|
static const struct pios_led pios_leds[] = {
|
|
|
|
[PIOS_LED_USB] = {
|
|
|
|
.pin = {
|
|
|
|
.gpio = GPIOA,
|
|
|
|
.init = {
|
|
|
|
.GPIO_Pin = GPIO_Pin_3,
|
|
|
|
.GPIO_Mode = GPIO_Mode_Out_PP,
|
|
|
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[PIOS_LED_LINK] = {
|
|
|
|
.pin = {
|
|
|
|
.gpio = GPIOB,
|
|
|
|
.init = {
|
|
|
|
.GPIO_Pin = GPIO_Pin_5,
|
|
|
|
.GPIO_Mode = GPIO_Mode_Out_PP,
|
|
|
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[PIOS_LED_RX] = {
|
|
|
|
.pin = {
|
|
|
|
.gpio = GPIOB,
|
|
|
|
.init = {
|
|
|
|
.GPIO_Pin = GPIO_Pin_6,
|
|
|
|
.GPIO_Mode = GPIO_Mode_Out_PP,
|
|
|
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[PIOS_LED_TX] = {
|
|
|
|
.pin = {
|
|
|
|
.gpio = GPIOB,
|
|
|
|
.init = {
|
|
|
|
.GPIO_Pin = GPIO_Pin_7,
|
|
|
|
.GPIO_Mode = GPIO_Mode_Out_PP,
|
|
|
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pios_led_cfg pios_led_cfg = {
|
|
|
|
.leds = pios_leds,
|
|
|
|
.num_leds = NELEMENTS(pios_leds),
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PIOS_INCLUDE_LED */
|
2011-02-14 02:17:42 +01:00
|
|
|
|
2012-01-13 01:53:52 +01:00
|
|
|
#if defined(PIOS_INCLUDE_COM_MSG)
|
2011-02-14 02:17:42 +01:00
|
|
|
|
2012-01-13 01:53:52 +01:00
|
|
|
#include <pios_com_msg_priv.h>
|
2011-02-14 02:17:42 +01:00
|
|
|
|
2012-01-13 01:53:52 +01:00
|
|
|
#endif /* PIOS_INCLUDE_COM_MSG */
|
2011-02-14 02:17:42 +01:00
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
#if defined(PIOS_INCLUDE_USB)
|
|
|
|
#include "pios_usb_priv.h"
|
2011-07-26 06:27:03 +02:00
|
|
|
|
2011-09-08 03:39:56 +02:00
|
|
|
static const struct pios_usb_cfg pios_usb_main_cfg = {
|
2011-07-26 06:27:03 +02:00
|
|
|
.irq = {
|
|
|
|
.init = {
|
|
|
|
.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn,
|
|
|
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
|
|
|
.NVIC_IRQChannelSubPriority = 0,
|
|
|
|
.NVIC_IRQChannelCmd = ENABLE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-14 20:17:06 +01:00
|
|
|
#include "pios_usb_board_data_priv.h"
|
|
|
|
#include "pios_usb_desc_hid_only_priv.h"
|
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
#endif /* PIOS_INCLUDE_USB */
|
|
|
|
|
|
|
|
#if defined(PIOS_INCLUDE_USB_HID)
|
|
|
|
#include <pios_usb_hid_priv.h>
|
2011-02-14 02:17:42 +01:00
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
|
2011-09-08 03:39:56 +02:00
|
|
|
.data_if = 0,
|
|
|
|
.data_rx_ep = 1,
|
|
|
|
.data_tx_ep = 1,
|
|
|
|
};
|
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
#endif /* PIOS_INCLUDE_USB_HID */
|
2011-09-08 03:39:56 +02:00
|
|
|
|
2011-09-14 23:04:15 +02:00
|
|
|
uint32_t pios_com_telem_usb_id;
|
2011-02-14 02:17:42 +01:00
|
|
|
|
2011-01-13 16:57:30 +01:00
|
|
|
/**
|
|
|
|
* PIOS_Board_Init()
|
|
|
|
* initializes all the core subsystems on this specific hardware
|
|
|
|
* called from System/openpilot.c
|
|
|
|
*/
|
2011-07-26 06:27:03 +02:00
|
|
|
static bool board_init_complete = false;
|
2011-01-13 16:57:30 +01:00
|
|
|
void PIOS_Board_Init(void) {
|
2011-07-26 06:27:03 +02:00
|
|
|
if (board_init_complete) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-13 16:57:30 +01:00
|
|
|
/* Enable Prefetch Buffer */
|
|
|
|
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
|
|
|
|
|
|
|
/* Flash 2 wait state */
|
|
|
|
FLASH_SetLatency(FLASH_Latency_2);
|
|
|
|
|
|
|
|
/* Delay system */
|
2011-04-29 21:48:13 +02:00
|
|
|
PIOS_DELAY_Init();
|
|
|
|
|
2011-01-13 16:57:30 +01:00
|
|
|
/* Initialize the PiOS library */
|
|
|
|
PIOS_GPIO_Init();
|
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
#if defined(PIOS_INCLUDE_USB)
|
2012-01-14 20:17:06 +01:00
|
|
|
/* Initialize board specific USB data */
|
|
|
|
PIOS_USB_BOARD_DATA_Init();
|
|
|
|
|
|
|
|
/* Activate the HID-only USB configuration */
|
|
|
|
PIOS_USB_DESC_HID_ONLY_Init();
|
|
|
|
|
2011-09-08 03:39:56 +02:00
|
|
|
uint32_t pios_usb_id;
|
|
|
|
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
|
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
2012-01-13 01:53:52 +01:00
|
|
|
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
|
|
|
|
uint32_t pios_usb_hid_id;
|
|
|
|
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
|
2011-09-08 03:39:56 +02:00
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
2012-01-13 01:53:52 +01:00
|
|
|
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
|
2011-07-26 06:27:03 +02:00
|
|
|
PIOS_Assert(0);
|
2011-02-14 02:17:42 +01:00
|
|
|
}
|
2012-01-13 01:53:52 +01:00
|
|
|
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
|
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
#endif /* PIOS_INCLUDE_USB */
|
2011-01-13 16:57:30 +01:00
|
|
|
|
2011-02-14 02:17:42 +01:00
|
|
|
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);//TODO Tirar
|
2011-07-26 06:27:03 +02:00
|
|
|
|
|
|
|
board_init_complete = true;
|
2011-02-14 02:17:42 +01:00
|
|
|
}
|