mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
2d27c54d48
The main purpose of this new COM implementation is that it is much simpler, and requires less code space. This takes a bit of the pressure off of the CC bootloader which was right at the limit of available code space in the bootloader partition. This is not intended to ever be used by the application. This driver also formalizes the assumptions in the bootloader's usage of the COM layer. All messages are assumed to arrive in atomic chunks from the HID layer.
111 lines
3.1 KiB
C
111 lines
3.1 KiB
C
/**
|
|
******************************************************************************
|
|
*
|
|
* @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>
|
|
|
|
// ***********************************************************************************
|
|
|
|
#if defined(PIOS_INCLUDE_COM_MSG)
|
|
|
|
#include <pios_com_msg_priv.h>
|
|
|
|
#endif /* PIOS_INCLUDE_COM_MSG */
|
|
|
|
// ***********************************************************************************
|
|
|
|
#if defined(PIOS_INCLUDE_USB)
|
|
#include "pios_usb_priv.h"
|
|
|
|
static const struct pios_usb_cfg pios_usb_main_cfg = {
|
|
.irq = {
|
|
.init = {
|
|
.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn,
|
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
|
.NVIC_IRQChannelSubPriority = 0,
|
|
.NVIC_IRQChannelCmd = ENABLE,
|
|
},
|
|
},
|
|
};
|
|
|
|
#endif /* PIOS_INCLUDE_USB */
|
|
|
|
#if defined(PIOS_INCLUDE_USB_HID)
|
|
#include <pios_usb_hid_priv.h>
|
|
|
|
const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
|
|
.data_if = 0,
|
|
.data_rx_ep = 1,
|
|
.data_tx_ep = 1,
|
|
};
|
|
|
|
#endif /* PIOS_INCLUDE_USB_HID */
|
|
|
|
uint32_t pios_com_telem_usb_id;
|
|
|
|
/**
|
|
* PIOS_Board_Init()
|
|
* initializes all the core subsystems on this specific hardware
|
|
* called from System/openpilot.c
|
|
*/
|
|
static bool board_init_complete = false;
|
|
void PIOS_Board_Init(void) {
|
|
if (board_init_complete) {
|
|
return;
|
|
}
|
|
|
|
/* Enable Prefetch Buffer */
|
|
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
|
|
|
/* Flash 2 wait state */
|
|
FLASH_SetLatency(FLASH_Latency_2);
|
|
|
|
/* Delay system */
|
|
PIOS_DELAY_Init();
|
|
|
|
/* Initialize the PiOS library */
|
|
PIOS_GPIO_Init();
|
|
|
|
#if defined(PIOS_INCLUDE_USB)
|
|
uint32_t pios_usb_id;
|
|
if (PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg)) {
|
|
PIOS_Assert(0);
|
|
}
|
|
#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)) {
|
|
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 */
|
|
|
|
#endif /* PIOS_INCLUDE_USB */
|
|
|
|
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);//TODO Tirar
|
|
|
|
board_init_complete = true;
|
|
}
|