2011-01-27 23:33:13 +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
|
|
|
|
*/
|
|
|
|
|
2013-04-16 22:03:08 +02:00
|
|
|
#include <pios.h>
|
|
|
|
#include <pios_board_info.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pull in the board-specific static HW definitions.
|
2012-01-23 01:41:41 +01:00
|
|
|
* Including .c files is a bit ugly but this allows all of
|
|
|
|
* the HW definitions to be const and static to limit their
|
2013-04-16 22:03:08 +02:00
|
|
|
* scope.
|
2012-01-23 01:41:41 +01:00
|
|
|
*
|
|
|
|
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
|
|
|
|
*/
|
2013-04-16 22:03:08 +02:00
|
|
|
#include "../board_hw_defs.c"
|
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:39 +01:00
|
|
|
|
2011-01-27 23:33:13 +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;
|
2013-05-18 14:17:26 +02:00
|
|
|
void PIOS_Board_Init(void)
|
|
|
|
{
|
|
|
|
if (board_init_complete) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable Prefetch Buffer */
|
|
|
|
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
2011-07-26 06:27:03 +02:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
/* Flash 2 wait state */
|
|
|
|
FLASH_SetLatency(FLASH_Latency_2);
|
2011-01-27 23:33:13 +01:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
/* Delay system */
|
|
|
|
PIOS_DELAY_Init();
|
2011-01-27 23:33:13 +01:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
/* Initialize the PiOS library */
|
|
|
|
PIOS_GPIO_Init();
|
2011-04-29 21:48:13 +02:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
const struct pios_board_info *bdinfo = &pios_board_info_blob;
|
2011-01-27 23:33:13 +01:00
|
|
|
|
2012-01-23 00:22:59 +01:00
|
|
|
#if defined(PIOS_INCLUDE_LED)
|
2013-05-18 14:17:26 +02:00
|
|
|
const struct pios_led_cfg *led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
|
|
|
|
PIOS_Assert(led_cfg);
|
|
|
|
PIOS_LED_Init(led_cfg);
|
|
|
|
#endif /* PIOS_INCLUDE_LED */
|
2012-01-23 00:22:59 +01:00
|
|
|
|
2012-01-02 20:03:15 +01:00
|
|
|
#if defined(PIOS_INCLUDE_USB)
|
2013-05-18 14:17:26 +02:00
|
|
|
/* Initialize board specific USB data */
|
|
|
|
PIOS_USB_BOARD_DATA_Init();
|
|
|
|
|
|
|
|
/* Activate the HID-only USB configuration */
|
|
|
|
PIOS_USB_DESC_HID_ONLY_Init();
|
|
|
|
|
|
|
|
uint32_t pios_usb_id;
|
|
|
|
switch (bdinfo->board_rev) {
|
|
|
|
case BOARD_REVISION_CC:
|
|
|
|
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg_cc);
|
|
|
|
break;
|
|
|
|
case BOARD_REVISION_CC3D:
|
|
|
|
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg_cc3d);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
2012-01-13 01:53:52 +01:00
|
|
|
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
|
2013-05-18 14:17:26 +02:00
|
|
|
uint32_t pios_usb_hid_id;
|
|
|
|
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
|
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
|
|
|
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
|
|
|
|
PIOS_Assert(0);
|
|
|
|
}
|
|
|
|
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
|
2012-01-02 20:03:15 +01:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
#endif /* PIOS_INCLUDE_USB */
|
2011-01-27 23:33:13 +01:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); // TODO Tirar
|
2011-07-26 06:27:03 +02:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
board_init_complete = true;
|
2011-02-14 02:17:39 +01:00
|
|
|
}
|
2012-01-25 05:15:43 +01:00
|
|
|
|
|
|
|
void PIOS_ADC_DMA_Handler()
|
2013-05-18 14:17:26 +02:00
|
|
|
{}
|