mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Some cleanup on PipXtreme codebase.
This commit is contained in:
parent
f0dfba6fc0
commit
cf34baec69
@ -102,6 +102,32 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
|
||||
#define PIOS_ADXL_ENABLE PIOS_SPI_RC_PinSet(PIOS_SPI_ACCEL,0)
|
||||
#define PIOS_ADXL_DISABLE PIOS_SPI_RC_PinSet(PIOS_SPI_ACCEL,1)
|
||||
|
||||
// *****************************************************************
|
||||
// PIOS_LED
|
||||
|
||||
#define PIOS_LED_USB 0
|
||||
#define PIOS_LED_LINK 1
|
||||
#define PIOS_LED_RX 2
|
||||
#define PIOS_LED_TX 3
|
||||
|
||||
#define PIOS_LED_HEARTBEAT PIOS_LED_USB
|
||||
#define PIOS_LED_ALARM PIOS_LED_TX
|
||||
|
||||
#define USB_LED_ON PIOS_LED_On(PIOS_LED_USB)
|
||||
#define USB_LED_OFF PIOS_LED_Off(PIOS_LED_USB)
|
||||
#define USB_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_USB)
|
||||
|
||||
#define LINK_LED_ON PIOS_LED_On(PIOS_LED_LINK)
|
||||
#define LINK_LED_OFF PIOS_LED_Off(PIOS_LED_LINK)
|
||||
#define LINK_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_LINK)
|
||||
|
||||
#define RX_LED_ON PIOS_LED_On(PIOS_LED_RX)
|
||||
#define RX_LED_OFF PIOS_LED_Off(PIOS_LED_RX)
|
||||
#define RX_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_RX)
|
||||
|
||||
#define TX_LED_ON PIOS_LED_On(PIOS_LED_TX)
|
||||
#define TX_LED_OFF PIOS_LED_Off(PIOS_LED_TX)
|
||||
#define TX_LED_TOGGLE PIOS_LED_Toggle(PIOS_LED_TX)
|
||||
|
||||
//------------------------
|
||||
// PIOS_AK8794
|
||||
|
@ -186,8 +186,6 @@ SRC += $(PIOSSTM32F10X)/pios_led.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_delay.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usart.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_irq.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_adc.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_i2c.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_spi.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_ppm.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_debug.c
|
||||
|
@ -34,7 +34,7 @@
|
||||
#define PIOS_CONFIG_H
|
||||
|
||||
/* Enable/Disable PiOS Modules */
|
||||
#define PIOS_INCLUDE_ADC
|
||||
//#define PIOS_INCLUDE_ADC
|
||||
#define PIOS_INCLUDE_DELAY
|
||||
#ifdef MOVE_CONTROLLER
|
||||
#define PIOS_INCLUDE_I2C
|
||||
|
45
flight/PipXtreme/System/inc/pios_usb_board_data.h
Normal file
45
flight/PipXtreme/System/inc/pios_usb_board_data.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_USB_BOARD Board specific USB definitions
|
||||
* @brief Board specific USB definitions
|
||||
* @{
|
||||
*
|
||||
* @file pios_usb_board_data.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Board specific USB definitions
|
||||
* @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
|
||||
*/
|
||||
|
||||
#ifndef PIOS_USB_BOARD_DATA_H
|
||||
#define PIOS_USB_BOARD_DATA_H
|
||||
|
||||
#define PIOS_USB_BOARD_CDC_DATA_LENGTH 64
|
||||
#define PIOS_USB_BOARD_CDC_MGMT_LENGTH 32
|
||||
#define PIOS_USB_BOARD_HID_DATA_LENGTH 64
|
||||
|
||||
#define PIOS_USB_BOARD_EP_NUM 4
|
||||
|
||||
#include "pios_usb_defs.h" /* USB_* macros */
|
||||
|
||||
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_COPTERCONTROL
|
||||
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_COPTERCONTROL, USB_OP_BOARD_MODE_FW)
|
||||
|
||||
#endif /* PIOS_USB_BOARD_DATA_H */
|
@ -35,62 +35,8 @@
|
||||
#include <manualcontrolsettings.h>
|
||||
#include <gcsreceiver.h>
|
||||
|
||||
/*
|
||||
* ADC system
|
||||
*/
|
||||
#include "pios_adc_priv.h"
|
||||
extern void PIOS_ADC_handler(void);
|
||||
void DMA1_Channel1_IRQHandler() __attribute__ ((alias("PIOS_ADC_handler")));
|
||||
// Remap the ADC DMA handler to this one
|
||||
static const struct pios_adc_cfg pios_adc_cfg = {
|
||||
.dma = {
|
||||
.ahb_clk = RCC_AHBPeriph_DMA1,
|
||||
.irq = {
|
||||
.flags = (DMA1_FLAG_TC1 | DMA1_FLAG_TE1 | DMA1_FLAG_HT1 | DMA1_FLAG_GL1),
|
||||
.init = {
|
||||
.NVIC_IRQChannel = DMA1_Channel1_IRQn,
|
||||
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||
.NVIC_IRQChannelSubPriority = 0,
|
||||
.NVIC_IRQChannelCmd = ENABLE,
|
||||
},
|
||||
},
|
||||
.rx = {
|
||||
.channel = DMA1_Channel1,
|
||||
.init = {
|
||||
.DMA_PeripheralBaseAddr = (uint32_t) & ADC1->DR,
|
||||
.DMA_DIR = DMA_DIR_PeripheralSRC,
|
||||
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word,
|
||||
.DMA_MemoryDataSize = DMA_MemoryDataSize_Word,
|
||||
.DMA_Mode = DMA_Mode_Circular,
|
||||
.DMA_Priority = DMA_Priority_High,
|
||||
.DMA_M2M = DMA_M2M_Disable,
|
||||
},
|
||||
}
|
||||
},
|
||||
.half_flag = DMA1_IT_HT1,
|
||||
.full_flag = DMA1_IT_TC1,
|
||||
};
|
||||
|
||||
struct pios_adc_dev pios_adc_devs[] = {
|
||||
{
|
||||
.cfg = &pios_adc_cfg,
|
||||
.callback_function = NULL,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t pios_adc_num_devices = NELEMENTS(pios_adc_devs);
|
||||
|
||||
void PIOS_ADC_handler() {
|
||||
PIOS_ADC_DMA_Handler();
|
||||
}
|
||||
|
||||
#if defined(PIOS_INCLUDE_USART)
|
||||
|
||||
#include "pios_usart_priv.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_TELEMETRY_RF)
|
||||
/*
|
||||
* Telemetry USART
|
||||
*/
|
||||
@ -113,40 +59,21 @@ static const struct pios_usart_cfg pios_usart_telem_main_cfg = {
|
||||
},
|
||||
},
|
||||
.rx = {
|
||||
#ifdef MOVE_CONTROLLER
|
||||
.gpio = GPIOB,
|
||||
#else
|
||||
.gpio = GPIOA,
|
||||
#endif
|
||||
.init = {
|
||||
#ifdef MOVE_CONTROLLER
|
||||
.GPIO_Pin = GPIO_Pin_7,
|
||||
#else
|
||||
.GPIO_Pin = GPIO_Pin_10,
|
||||
#endif
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Mode = GPIO_Mode_IPU,
|
||||
},
|
||||
},
|
||||
.tx = {
|
||||
#ifdef MOVE_CONTROLLER
|
||||
.gpio = GPIOB,
|
||||
#else
|
||||
.gpio = GPIOA,
|
||||
#endif
|
||||
.init = {
|
||||
#ifdef MOVE_CONTROLLER
|
||||
.GPIO_Pin = GPIO_Pin_6,
|
||||
#else
|
||||
.GPIO_Pin = GPIO_Pin_9,
|
||||
#endif
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Mode = GPIO_Mode_AF_PP,
|
||||
},
|
||||
},
|
||||
#ifdef MOVE_CONTROLLER
|
||||
.remap = AFIO_MAPR_USART1_REMAP,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const struct pios_usart_cfg pios_usart_usart2_cfg = {
|
||||
@ -220,11 +147,6 @@ static const struct pios_usart_cfg pios_usart_telem_flexi_cfg = {
|
||||
},
|
||||
},
|
||||
};
|
||||
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
|
||||
|
||||
#endif /* PIOS_INCLUDE_USART */
|
||||
|
||||
#if defined(PIOS_INCLUDE_COM)
|
||||
|
||||
#include "pios_com_priv.h"
|
||||
|
||||
@ -236,8 +158,6 @@ static const struct pios_usart_cfg pios_usart_telem_flexi_cfg = {
|
||||
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 192
|
||||
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192
|
||||
|
||||
#endif /* PIOS_INCLUDE_COM */
|
||||
|
||||
#if defined(PIOS_INCLUDE_RTC)
|
||||
/*
|
||||
* Realtime Clock (RTC)
|
||||
@ -442,129 +362,9 @@ const struct pios_ppm_cfg pios_ppm_cfg = {
|
||||
*/
|
||||
uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE];
|
||||
|
||||
#include <pios_pwm_priv.h>
|
||||
|
||||
static const struct pios_tim_channel pios_tim_rssi_pwm_channel = {
|
||||
#if defined(ANALOG_TRANSMITTER)
|
||||
.timer = TIM3,
|
||||
.timer_chan = TIM_Channel_2,
|
||||
.pin = {
|
||||
.gpio = GPIOB,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_5,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
},
|
||||
},
|
||||
.remap = GPIO_PartialRemap_TIM3,
|
||||
#else
|
||||
.timer = TIM2,
|
||||
.timer_chan = TIM_Channel_2,
|
||||
.pin = {
|
||||
.gpio = GPIOA,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_1,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
},
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
const struct pios_pwm_cfg pios_pwm_cfg = {
|
||||
.tim_ic_init = {
|
||||
.TIM_ICPolarity = TIM_ICPolarity_Rising,
|
||||
.TIM_ICSelection = TIM_ICSelection_DirectTI,
|
||||
.TIM_ICPrescaler = TIM_ICPSC_DIV1,
|
||||
.TIM_ICFilter = 0x0,
|
||||
},
|
||||
.channels = &pios_tim_rssi_pwm_channel,
|
||||
.num_channels = 1,
|
||||
};
|
||||
|
||||
#if defined(PIOS_INCLUDE_I2C)
|
||||
|
||||
|
||||
#include <pios_i2c_priv.h>
|
||||
|
||||
/*
|
||||
* I2C Adapters
|
||||
*/
|
||||
|
||||
void PIOS_I2C_flexi_adapter_ev_irq_handler(void);
|
||||
void PIOS_I2C_flexi_adapter_er_irq_handler(void);
|
||||
void I2C2_EV_IRQHandler() __attribute__ ((alias ("PIOS_I2C_flexi_adapter_ev_irq_handler")));
|
||||
void I2C2_ER_IRQHandler() __attribute__ ((alias ("PIOS_I2C_flexi_adapter_er_irq_handler")));
|
||||
|
||||
static const struct pios_i2c_adapter_cfg pios_i2c_flexi_adapter_cfg = {
|
||||
.regs = I2C2,
|
||||
.init = {
|
||||
.I2C_Mode = I2C_Mode_I2C,
|
||||
.I2C_OwnAddress1 = 0,
|
||||
.I2C_Ack = I2C_Ack_Enable,
|
||||
.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
|
||||
.I2C_DutyCycle = I2C_DutyCycle_2,
|
||||
.I2C_ClockSpeed = 400000, /* bits/s */
|
||||
},
|
||||
.transfer_timeout_ms = 50,
|
||||
.scl = {
|
||||
.gpio = GPIOB,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_10,
|
||||
.GPIO_Speed = GPIO_Speed_10MHz,
|
||||
.GPIO_Mode = GPIO_Mode_AF_OD,
|
||||
},
|
||||
},
|
||||
.sda = {
|
||||
.gpio = GPIOB,
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_11,
|
||||
.GPIO_Speed = GPIO_Speed_10MHz,
|
||||
.GPIO_Mode = GPIO_Mode_AF_OD,
|
||||
},
|
||||
},
|
||||
.event = {
|
||||
.flags = 0, /* FIXME: check this */
|
||||
.init = {
|
||||
.NVIC_IRQChannel = I2C2_EV_IRQn,
|
||||
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||
.NVIC_IRQChannelSubPriority = 0,
|
||||
.NVIC_IRQChannelCmd = ENABLE,
|
||||
},
|
||||
},
|
||||
.error = {
|
||||
.flags = 0, /* FIXME: check this */
|
||||
.init = {
|
||||
.NVIC_IRQChannel = I2C2_ER_IRQn,
|
||||
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||
.NVIC_IRQChannelSubPriority = 0,
|
||||
.NVIC_IRQChannelCmd = ENABLE,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
uint32_t pios_i2c_flexi_adapter_id;
|
||||
void PIOS_I2C_flexi_adapter_ev_irq_handler(void)
|
||||
{
|
||||
/* Call into the generic code to handle the IRQ for this specific device */
|
||||
PIOS_I2C_EV_IRQ_Handler(pios_i2c_flexi_adapter_id);
|
||||
}
|
||||
|
||||
void PIOS_I2C_flexi_adapter_er_irq_handler(void)
|
||||
{
|
||||
/* Call into the generic code to handle the IRQ for this specific device */
|
||||
PIOS_I2C_ER_IRQ_Handler(pios_i2c_flexi_adapter_id);
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_I2C */
|
||||
|
||||
uint32_t rssi_pwm_id;
|
||||
|
||||
uint32_t pios_com_usart1_id;
|
||||
#ifndef MOVE_CONTROLLER
|
||||
uint32_t pios_com_usart2_id;
|
||||
uint32_t pios_com_usart3_id;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PIOS_Board_Init()
|
||||
@ -639,7 +439,6 @@ void PIOS_Board_Init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MOVE_CONTROLLER
|
||||
/* Configure USART2 */
|
||||
{
|
||||
uint32_t pios_usart2_id;
|
||||
@ -674,173 +473,13 @@ void PIOS_Board_Init(void) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
PIOS_COM_SendString(PIOS_COM_DEBUG, "Hello Debug\n\r");
|
||||
//PIOS_COM_SendString(PIOS_COM_TELEM_GCS, "Hello GCS\n\r");
|
||||
//PIOS_COM_SendString(PIOS_COM_TELEM_OUT, "Hello CC\n\r");
|
||||
|
||||
#if defined(PIOS_INCLUDE_I2C)
|
||||
if (PIOS_I2C_Init(&pios_i2c_flexi_adapter_id, &pios_i2c_flexi_adapter_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_AK8974 */
|
||||
|
||||
#if defined(ANALOG_TRANSMITTER)
|
||||
// Initialize switch GPIO pins
|
||||
{
|
||||
GPIO_TypeDef *GPIO_GPIOxs[] = {
|
||||
GPIOA, GPIOB, GPIOB, GPIOB, GPIOB, GPIOB
|
||||
};
|
||||
GPIO_InitTypeDef GPIO_InitStructures[] = {
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_8,
|
||||
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_7,
|
||||
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_14,
|
||||
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_13,
|
||||
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_15,
|
||||
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_9,
|
||||
.GPIO_Mode = GPIO_Mode_Out_OD,
|
||||
},
|
||||
};
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(GPIO_GPIOxs) / sizeof(GPIO_TypeDef); ++i)
|
||||
GPIO_Init(GPIO_GPIOxs[i], GPIO_InitStructures + i);
|
||||
}
|
||||
|
||||
// Initialize the XBee RSSI PWM input.
|
||||
PIOS_PWM_Init(&rssi_pwm_id, &pios_pwm_cfg);
|
||||
|
||||
#elif defined(MAPLE_MINI)
|
||||
|
||||
// Initialize switch GPIO pins
|
||||
{
|
||||
GPIO_TypeDef *GPIO_GPIOxs[] = {
|
||||
GPIOB, GPIOB, GPIOB
|
||||
};
|
||||
GPIO_InitTypeDef GPIO_InitStructures[] = {
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_0,
|
||||
.GPIO_Mode = GPIO_Mode_IPU,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_2,
|
||||
.GPIO_Mode = GPIO_Mode_IPU,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_9,
|
||||
.GPIO_Mode = GPIO_Mode_Out_OD,
|
||||
},
|
||||
};
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(GPIO_GPIOxs) / sizeof(GPIO_TypeDef); ++i)
|
||||
GPIO_Init(GPIO_GPIOxs[i], GPIO_InitStructures + i);
|
||||
}
|
||||
|
||||
// Initialize the XBee RSSI PWM input.
|
||||
PIOS_PWM_Init(&rssi_pwm_id, &pios_pwm_cfg);
|
||||
|
||||
// Turn on the USB port on the Maple Mini */
|
||||
GPIO_ResetBits(GPIOB, GPIO_Pin_9);
|
||||
|
||||
#elif defined(MOVE_CONTROLLER)
|
||||
|
||||
// Initialize switch GPIO pins
|
||||
// PA0 - PS Button
|
||||
// PB8 - Select Button
|
||||
// PB9 - Start Button
|
||||
// PD5 - Square Button
|
||||
// PC13 - Circle Button
|
||||
// PC14 - X Button
|
||||
// PC15 - Triangle Button
|
||||
// PE0 - Move Button
|
||||
{
|
||||
GPIO_TypeDef *GPIO_GPIOxs[] = {
|
||||
GPIOA, GPIOB, GPIOB, GPIOD, GPIOC, GPIOC, GPIOC, GPIOE, GPIOD, GPIOD
|
||||
};
|
||||
GPIO_InitTypeDef GPIO_InitStructures[] = {
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_0,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_8,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_9,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_5,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_13,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_14,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_15,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||
.GPIO_Pin = GPIO_Pin_0,
|
||||
.GPIO_Mode = GPIO_Mode_IPD,
|
||||
},
|
||||
{
|
||||
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||
.GPIO_Pin = GPIO_Pin_0,
|
||||
.GPIO_Mode = GPIO_Mode_Out_PP,
|
||||
},
|
||||
};
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(GPIO_GPIOxs) / sizeof(GPIO_TypeDef); ++i)
|
||||
GPIO_Init(GPIO_GPIOxs[i], GPIO_InitStructures + i);
|
||||
|
||||
// Set the referece voltage for T button potentiometer
|
||||
GPIO_ResetBits(GPIOD, GPIO_Pin_0);
|
||||
}
|
||||
#endif
|
||||
PIOS_COM_SendString(PIOS_COM_TELEM_GCS, "Hello GCS\n\r");
|
||||
PIOS_COM_SendString(PIOS_COM_TELEM_OUT, "Hello CC\n\r");
|
||||
|
||||
/* Remap AFIO pin */
|
||||
GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE);
|
||||
|
||||
PIOS_ADC_Init();
|
||||
PIOS_GPIO_Init();
|
||||
}
|
||||
|
||||
|
123
flight/PipXtreme/System/pios_usb_board_data.c
Normal file
123
flight/PipXtreme/System/pios_usb_board_data.c
Normal file
@ -0,0 +1,123 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_USB_BOARD Board specific USB definitions
|
||||
* @brief Board specific USB definitions
|
||||
* @{
|
||||
*
|
||||
* @file pios_usb_board_data.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Board specific USB definitions
|
||||
* @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_usb_board_data.h" /* struct usb_*, USB_* */
|
||||
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||
|
||||
static const uint8_t usb_product_id[28] = {
|
||||
sizeof(usb_product_id),
|
||||
USB_DESC_TYPE_STRING,
|
||||
'C', 0,
|
||||
'o', 0,
|
||||
'p', 0,
|
||||
't', 0,
|
||||
'e', 0,
|
||||
'r', 0,
|
||||
'C', 0,
|
||||
'o', 0,
|
||||
'n', 0,
|
||||
't', 0,
|
||||
'r', 0,
|
||||
'o', 0,
|
||||
'l', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[52] = {
|
||||
sizeof(usb_serial_number),
|
||||
USB_DESC_TYPE_STRING,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0
|
||||
};
|
||||
|
||||
static const struct usb_string_langid usb_lang_id = {
|
||||
.bLength = sizeof(usb_lang_id),
|
||||
.bDescriptorType = USB_DESC_TYPE_STRING,
|
||||
.bLangID = htousbs(USB_LANGID_ENGLISH_UK),
|
||||
};
|
||||
|
||||
static const uint8_t usb_vendor_id[28] = {
|
||||
sizeof(usb_vendor_id),
|
||||
USB_DESC_TYPE_STRING,
|
||||
'o', 0,
|
||||
'p', 0,
|
||||
'e', 0,
|
||||
'n', 0,
|
||||
'p', 0,
|
||||
'i', 0,
|
||||
'l', 0,
|
||||
'o', 0,
|
||||
't', 0,
|
||||
'.', 0,
|
||||
'o', 0,
|
||||
'r', 0,
|
||||
'g', 0
|
||||
};
|
||||
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25];
|
||||
PIOS_SYS_SerialNumberGet((char *)sn);
|
||||
for (uint8_t i = 0; sn[i] != '\0' && (2 * i) < usb_serial_number[0]; i++) {
|
||||
usb_serial_number[2 + 2 * i] = sn[i];
|
||||
}
|
||||
|
||||
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
|
||||
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
|
||||
|
||||
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
|
||||
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
|
||||
|
||||
return 0;
|
||||
}
|
99
flight/PipXtreme/System/pipxtreme.c
Executable file
99
flight/PipXtreme/System/pipxtreme.c
Executable file
@ -0,0 +1,99 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup OpenPilotSystem OpenPilot System
|
||||
* @brief These files are the core system files of OpenPilot.
|
||||
* They are the ground layer just above PiOS. In practice, OpenPilot actually starts
|
||||
* in the main() function of openpilot.c
|
||||
* @{
|
||||
* @addtogroup OpenPilotCore OpenPilot Core
|
||||
* @brief This is where the OP firmware starts. Those files also define the compile-time
|
||||
* options of the firmware.
|
||||
* @{
|
||||
* @file openpilot.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Sets up and runs main OpenPilot tasks.
|
||||
* @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
|
||||
*/
|
||||
|
||||
|
||||
/* OpenPilot Includes */
|
||||
#include "openpilot.h"
|
||||
#include "uavobjectsinit.h"
|
||||
#include "hwsettings.h"
|
||||
#include "systemmod.h"
|
||||
|
||||
/* Task Priorities */
|
||||
#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3)
|
||||
|
||||
/* Global Variables */
|
||||
|
||||
/* Prototype of PIOS_Board_Init() function */
|
||||
extern void PIOS_Board_Init(void);
|
||||
extern void Stack_Change(void);
|
||||
|
||||
/**
|
||||
* OpenPilot Main function:
|
||||
*
|
||||
* Initialize PiOS<BR>
|
||||
* Create the "System" task (SystemModInitializein Modules/System/systemmod.c) <BR>
|
||||
* Start FreeRTOS Scheduler (vTaskStartScheduler) (Now handled by caller)
|
||||
* If something goes wrong, blink LED1 and LED2 every 100ms
|
||||
*
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/* NOTE: Do NOT modify the following start-up sequence */
|
||||
/* Any new initialization functions should be added in OpenPilotInit() */
|
||||
|
||||
/* Brings up System using CMSIS functions, enables the LEDs. */
|
||||
PIOS_SYS_Init();
|
||||
|
||||
/* Architecture dependant Hardware and
|
||||
* core subsystem initialisation
|
||||
* (see pios_board.c for your arch)
|
||||
* */
|
||||
PIOS_Board_Init();
|
||||
|
||||
/* Initialize modules */
|
||||
MODULE_INITIALISE_ALL
|
||||
|
||||
/* swap the stack to use the IRQ stack */
|
||||
Stack_Change();
|
||||
|
||||
/* Start the FreeRTOS scheduler which should never returns.*/
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well we will never reach here as the scheduler will now be running. */
|
||||
|
||||
/* Do some indication to user that something bad just happened */
|
||||
while (1) {
|
||||
#if defined(PIOS_LED_HEARTBEAT)
|
||||
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
|
||||
#endif /* PIOS_LED_HEARTBEAT */
|
||||
PIOS_DELAY_WaitmS(100);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user