1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

Merge remote-tracking branch 'raid/PipXtreme' into PipXtreme

This commit is contained in:
Brian Webb 2012-02-27 18:06:59 -07:00
commit fbe6095474
9 changed files with 696 additions and 331 deletions

View File

@ -0,0 +1,199 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup RadioComBridgeModule Com Port to Radio Bridge Module
* @brief Bridge Com and Radio ports
* @{
*
* @file RadioComBridge.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief Bridges selected Com Port to the COM VCP emulated serial port
* @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 "openpilot.h"
#include "hwsettings.h"
#include "radiocombridge.h"
#include <stdbool.h>
// ****************
// Private functions
static void radio2ComBridgeTask(void *parameters);
static void com2RadioBridgeTask(void *parameters);
static void updateSettings();
// ****************
// Private constants
#define STACK_SIZE_BYTES 280
#define TASK_PRIORITY (tskIDLE_PRIORITY + 1)
#define BRIDGE_BUF_LEN 10
// ****************
// Private types
typedef struct {
// The task handles.
xTaskHandle radio2ComBridgeTaskHandle;
xTaskHandle com2RadioBridgeTaskHandle;
// The com buffers.
uint8_t *radio2com_buf;
uint8_t *com2radio_buf;
// The com ports
uint32_t com_port;
uint32_t radio_port;
} RadioComBridgeData;
// ****************
// Private variables
static RadioComBridgeData *data;
/**
* Initialise the module
* \return -1 if initialisation failed
* \return 0 on success
*/
static int32_t RadioComBridgeStart(void)
{
if(data) {
// Start the tasks
xTaskCreate(radio2ComBridgeTask, (signed char *)"Radio2ComBridge", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &(data->radio2ComBridgeTaskHandle));
xTaskCreate(com2RadioBridgeTask, (signed char *)"Com2RadioBridge", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &(data->com2RadioBridgeTaskHandle));
return 0;
}
return -1;
}
/**
* Initialise the module
* \return -1 if initialisation failed
* \return 0 on success
*/
static int32_t RadioComBridgeInitialize(void)
{
// allocate and initialize the static data storage only if module is enabled
data = (RadioComBridgeData *)pvPortMalloc(sizeof(RadioComBridgeData));
if (!data)
return -1;
// TODO: Get from settings object
//data->com_port = PIOS_COM_VCP;
data->com_port = PIOS_COM_TELEM_USB;
data->radio_port = PIOS_COM_TELEM_SERIAL;
data->radio2com_buf = pvPortMalloc(BRIDGE_BUF_LEN);
PIOS_Assert(data->radio2com_buf);
data->com2radio_buf = pvPortMalloc(BRIDGE_BUF_LEN);
PIOS_Assert(data->com2radio_buf);
updateSettings();
return 0;
}
MODULE_INITCALL(RadioComBridgeInitialize, RadioComBridgeStart)
/**
* Main task. It does not return.
*/
static void radio2ComBridgeTask(void *parameters)
{
/* Handle radio -> usart/usb direction */
volatile uint32_t tx_errors = 0;
while (1) {
uint32_t rx_bytes;
rx_bytes = PIOS_COM_ReceiveBuffer(data->radio_port, data->radio2com_buf, BRIDGE_BUF_LEN, 500);
if (rx_bytes > 0) {
/* Bytes available to transfer */
if (PIOS_COM_SendBuffer(data->com_port, data->radio2com_buf, rx_bytes) != rx_bytes) {
/* Error on transmit */
tx_errors++;
}
}
}
}
static void com2RadioBridgeTask(void * parameters)
{
/* Handle usart/usb -> radio direction */
volatile uint32_t tx_errors = 0;
while (1) {
uint32_t rx_bytes;
rx_bytes = PIOS_COM_ReceiveBuffer(data->com_port, data->com2radio_buf, BRIDGE_BUF_LEN, 500);
if (rx_bytes > 0) {
PIOS_COM_SendString(PIOS_COM_TELEM_SERIAL, "Rec com\n\r");
/* Bytes available to transfer */
if (PIOS_COM_SendBuffer(data->radio_port, data->com2radio_buf, rx_bytes) != rx_bytes) {
/* Error on transmit */
tx_errors++;
}
}
}
}
static void updateSettings()
{
if (data->com_port) {
#ifdef NEVER
// Retrieve settings
uint8_t speed;
HwSettingsRadioComBridgeSpeedGet(&speed);
// Set port speed
switch (speed) {
case HWSETTINGS_RADIOCOMBRIDGESPEED_2400:
PIOS_COM_ChangeBaud(data->com_port, 2400);
break;
case HWSETTINGS_RADIOCOMBRIDGESPEED_4800:
PIOS_COM_ChangeBaud(data->com_port, 4800);
break;
case HWSETTINGS_RADIOCOMBRIDGESPEED_9600:
PIOS_COM_ChangeBaud(data->com_port, 9600);
break;
case HWSETTINGS_RADIOCOMBRIDGESPEED_19200:
PIOS_COM_ChangeBaud(data->com_port, 19200);
break;
case HWSETTINGS_RADIOCOMBRIDGESPEED_38400:
PIOS_COM_ChangeBaud(data->com_port, 38400);
break;
case HWSETTINGS_RADIOCOMBRIDGESPEED_57600:
PIOS_COM_ChangeBaud(data->com_port, 57600);
break;
case HWSETTINGS_RADIOCOMBRIDGESPEED_115200:
PIOS_COM_ChangeBaud(data->com_port, 115200);
break;
}
#endif
}
}

View File

@ -0,0 +1,39 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup RadioComBridgeModule Com Port to Radio Bridge Module
* @brief Bridge Com and Radio ports
* @{
*
* @file radiocombridge.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Include file of the telemetry module.
* @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 RADIOCOMBRIDGE_H
#define RADIOCOMBRIDGE_H
#endif // RADIOCOMBRIDGE_H
/**
* @}
* @}
*/

View File

@ -150,305 +150,15 @@ extern uint32_t pios_i2c_flexi_adapter_id;
#define PIOS_COM_MAX_DEVS 4
extern uint32_t pios_com_telem_usb_id;
#if defined(MOVE_CONTROLLER)
extern uint32_t pios_com_usart1_id;
#define PIOS_COM_TELEM_GCS (pios_com_usart1_id)
#define PIOS_COM_TELEM_OUT (pios_com_usart1_id)
#define PIOS_COM_DEBUG (pios_com_usart1_id)
#elif defined(ANALOG_TRANSMITTER)
extern uint32_t pios_com_vcp_usb_id;
extern uint32_t pios_com_usart1_id;
extern uint32_t pios_com_usart2_id;
extern uint32_t pios_com_usart3_id;
// 1 = Xbee, 2 = Extra, 3 = USB
// Debug mode
//#define PIOS_COM_TELEM_GCS (pios_com_usart1_id)
//#define PIOS_COM_TELEM_OUT (pios_com_usart2_id)
//#define PIOS_COM_DEBUG (pios_com_usart3_id)
// Normal mode
//#define PIOS_COM_TELEM_GCS (pios_com_usart3_id)
//#define PIOS_COM_TELEM_OUT (pios_com_usart1_id)
//#define PIOS_COM_DEBUG (pios_com_usart2_id)
#elif defined(MAPLE_MINI)
extern uint32_t pios_com_usart1_id;
extern uint32_t pios_com_usart2_id;
extern uint32_t pios_com_usart3_id;
// On Maple Mini:
// 1 = Debug, 2 = Xbee, 3 = GCS
#define PIOS_COM_TELEM_GCS (pios_com_usart3_id)
#define PIOS_COM_TELEM_OUT (pios_com_usart2_id)
#define PIOS_COM_DEBUG (pios_com_usart1_id)
#endif
#define PIOS_COM_TELEM_SERIAL (pios_com_usart1_id)
#define PIOS_COM_DEBUG (pios_com_usart2_id)
#define PIOS_COM_FLEXI (pios_com_usart3_id)
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
#if defined(ANALOG_TRANSMITTER)
//-------------------------
// ADC
// PIOS_ADC_PinGet(0) = Roll Prim
// PIOS_ADC_PinGet(1) = Roll Trim
// PIOS_ADC_PinGet(2) = Pitch Prim
// PIOS_ADC_PinGet(3) = Pitch Trim
// PIOS_ADC_PinGet(4) = Yaw Prim
// PIOS_ADC_PinGet(5) = Yaw Trim
// PIOS_ADC_PinGet(6) = Throt Prim
// PIOS_ADC_PinGet(7) = Throt Trim
// PIOS_ADC_PinGet(8) = Poten
//-------------------------
//#define PIOS_ADC_OVERSAMPLING_RATE 1
#define PIOS_ADC_USE_TEMP_SENSOR 1
#define PIOS_ADC_TEMP_SENSOR_ADC ADC1
#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
#define PIOS_ADC_PIN1_GPIO_PORT GPIOA // PA0
#define PIOS_ADC_PIN1_GPIO_PIN GPIO_Pin_0 // ADC12_IN0
#define PIOS_ADC_PIN1_GPIO_CHANNEL ADC_Channel_0
#define PIOS_ADC_PIN1_ADC ADC2
#define PIOS_ADC_PIN1_ADC_NUMBER 1
#define PIOS_ADC_PIN2_GPIO_PORT GPIOA // PA1
#define PIOS_ADC_PIN2_GPIO_PIN GPIO_Pin_1 // ADC123_IN1
#define PIOS_ADC_PIN2_GPIO_CHANNEL ADC_Channel_1
#define PIOS_ADC_PIN2_ADC ADC1
#define PIOS_ADC_PIN2_ADC_NUMBER 2
#define PIOS_ADC_PIN3_GPIO_PORT GPIOA // PA2
#define PIOS_ADC_PIN3_GPIO_PIN GPIO_Pin_2 // ADC12_IN2
#define PIOS_ADC_PIN3_GPIO_CHANNEL ADC_Channel_2
#define PIOS_ADC_PIN3_ADC ADC2
#define PIOS_ADC_PIN3_ADC_NUMBER 2
#define PIOS_ADC_PIN4_GPIO_PORT GPIOA // PA3
#define PIOS_ADC_PIN4_GPIO_PIN GPIO_Pin_3 // ADC12_IN3
#define PIOS_ADC_PIN4_GPIO_CHANNEL ADC_Channel_3
#define PIOS_ADC_PIN4_ADC ADC1
#define PIOS_ADC_PIN4_ADC_NUMBER 3
#define PIOS_ADC_PIN5_GPIO_PORT GPIOA // PA4
#define PIOS_ADC_PIN5_GPIO_PIN GPIO_Pin_4 // ADC12_IN4
#define PIOS_ADC_PIN5_GPIO_CHANNEL ADC_Channel_4
#define PIOS_ADC_PIN5_ADC ADC2
#define PIOS_ADC_PIN5_ADC_NUMBER 3
#define PIOS_ADC_PIN6_GPIO_PORT GPIOA // PA5
#define PIOS_ADC_PIN6_GPIO_PIN GPIO_Pin_5 // ADC12_IN5
#define PIOS_ADC_PIN6_GPIO_CHANNEL ADC_Channel_5
#define PIOS_ADC_PIN6_ADC ADC1
#define PIOS_ADC_PIN6_ADC_NUMBER 4
#define PIOS_ADC_PIN7_GPIO_PORT GPIOA // PA6
#define PIOS_ADC_PIN7_GPIO_PIN GPIO_Pin_6 // ADC12_IN6
#define PIOS_ADC_PIN7_GPIO_CHANNEL ADC_Channel_6
#define PIOS_ADC_PIN7_ADC ADC2
#define PIOS_ADC_PIN7_ADC_NUMBER 4
#define PIOS_ADC_PIN8_GPIO_PORT GPIOA // PA7
#define PIOS_ADC_PIN8_GPIO_PIN GPIO_Pin_7 // ADC12_IN7
#define PIOS_ADC_PIN8_GPIO_CHANNEL ADC_Channel_7
#define PIOS_ADC_PIN8_ADC ADC1
#define PIOS_ADC_PIN8_ADC_NUMBER 5
#define PIOS_ADC_PIN9_GPIO_PORT GPIOB // PB0
#define PIOS_ADC_PIN9_GPIO_PIN GPIO_Pin_0 // ADC12_IN8
#define PIOS_ADC_PIN9_GPIO_CHANNEL ADC_Channel_8
#define PIOS_ADC_PIN9_ADC ADC2
#define PIOS_ADC_PIN9_ADC_NUMBER 5
#define PIOS_ADC_NUM_PINS 9
#define PIOS_ADC_PORTS { PIOS_ADC_PIN1_GPIO_PORT, PIOS_ADC_PIN2_GPIO_PORT, PIOS_ADC_PIN3_GPIO_PORT, PIOS_ADC_PIN4_GPIO_PORT, PIOS_ADC_PIN5_GPIO_PORT, PIOS_ADC_PIN6_GPIO_PORT, PIOS_ADC_PIN7_GPIO_PORT, PIOS_ADC_PIN8_GPIO_PORT, PIOS_ADC_PIN9_GPIO_PORT }
#define PIOS_ADC_PINS { PIOS_ADC_PIN1_GPIO_PIN, PIOS_ADC_PIN2_GPIO_PIN, PIOS_ADC_PIN3_GPIO_PIN, PIOS_ADC_PIN4_GPIO_PIN, PIOS_ADC_PIN5_GPIO_PIN, PIOS_ADC_PIN6_GPIO_PIN, PIOS_ADC_PIN7_GPIO_PIN, PIOS_ADC_PIN8_GPIO_PIN, PIOS_ADC_PIN9_GPIO_PIN }
#define PIOS_ADC_CHANNELS { PIOS_ADC_PIN1_GPIO_CHANNEL, PIOS_ADC_PIN2_GPIO_CHANNEL, PIOS_ADC_PIN3_GPIO_CHANNEL, PIOS_ADC_PIN4_GPIO_CHANNEL, PIOS_ADC_PIN5_GPIO_CHANNEL, PIOS_ADC_PIN6_GPIO_CHANNEL, PIOS_ADC_PIN7_GPIO_CHANNEL, PIOS_ADC_PIN8_GPIO_CHANNEL, PIOS_ADC_PIN9_GPIO_CHANNEL }
#define PIOS_ADC_MAPPING { PIOS_ADC_PIN1_ADC, PIOS_ADC_PIN2_ADC, PIOS_ADC_PIN3_ADC, PIOS_ADC_PIN4_ADC, PIOS_ADC_PIN5_ADC, PIOS_ADC_PIN6_ADC, PIOS_ADC_PIN7_ADC, PIOS_ADC_PIN8_ADC, PIOS_ADC_PIN9_ADC }
#define PIOS_ADC_CHANNEL_MAPPING { PIOS_ADC_PIN1_ADC_NUMBER, PIOS_ADC_PIN2_ADC_NUMBER, PIOS_ADC_PIN3_ADC_NUMBER, PIOS_ADC_PIN4_ADC_NUMBER, PIOS_ADC_PIN5_ADC_NUMBER, PIOS_ADC_PIN6_ADC_NUMBER, PIOS_ADC_PIN7_ADC_NUMBER, PIOS_ADC_PIN8_ADC_NUMBER, PIOS_ADC_PIN9_ADC_NUMBER }
#define PIOS_ADC_NUM_ADC_CHANNELS 2
#define PIOS_ADC_USE_ADC2 1
#elif defined(MAPLE_MINI)
//-------------------------
// ADC
// PIOS_ADC_PinGet(0) = Roll
// PIOS_ADC_PinGet(1) = Pitch
// PIOS_ADC_PinGet(2) = Yaw
// PIOS_ADC_PinGet(3) = Throt
//-------------------------
//#define PIOS_ADC_OVERSAMPLING_RATE 1
//#define PIOS_ADC_USE_TEMP_SENSOR 1
#define PIOS_ADC_USE_TEMP_SENSOR 0
#define PIOS_ADC_TEMP_SENSOR_ADC ADC1
#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
#define PIOS_ADC_PIN1_GPIO_PORT GPIOA // PA4
#define PIOS_ADC_PIN1_GPIO_PIN GPIO_Pin_4 // ADC12_IN4
#define PIOS_ADC_PIN1_GPIO_CHANNEL ADC_Channel_4
#define PIOS_ADC_PIN1_ADC ADC1
#define PIOS_ADC_PIN1_ADC_NUMBER 1
#define PIOS_ADC_PIN2_GPIO_PORT GPIOA // PA5
#define PIOS_ADC_PIN2_GPIO_PIN GPIO_Pin_5 // ADC12_IN5
#define PIOS_ADC_PIN2_GPIO_CHANNEL ADC_Channel_5
#define PIOS_ADC_PIN2_ADC ADC2
#define PIOS_ADC_PIN2_ADC_NUMBER 1
#define PIOS_ADC_PIN3_GPIO_PORT GPIOA // PA6
#define PIOS_ADC_PIN3_GPIO_PIN GPIO_Pin_6 // ADC12_IN6
#define PIOS_ADC_PIN3_GPIO_CHANNEL ADC_Channel_6
#define PIOS_ADC_PIN3_ADC ADC1
#define PIOS_ADC_PIN3_ADC_NUMBER 2
#define PIOS_ADC_PIN4_GPIO_PORT GPIOA // PA7
#define PIOS_ADC_PIN4_GPIO_PIN GPIO_Pin_7 // ADC12_IN7
#define PIOS_ADC_PIN4_GPIO_CHANNEL ADC_Channel_7
#define PIOS_ADC_PIN4_ADC ADC2
#define PIOS_ADC_PIN4_ADC_NUMBER 2
#ifdef NEVER
#define PIOS_ADC_PIN5_GPIO_PORT GPIOA // PA0
#define PIOS_ADC_PIN5_GPIO_PIN GPIO_Pin_0 // ADC12_IN0
#define PIOS_ADC_PIN5_GPIO_CHANNEL ADC_Channel_0
#define PIOS_ADC_PIN5_ADC ADC2
#define PIOS_ADC_PIN5_ADC_NUMBER 3
#define PIOS_ADC_NUM_PINS 5
#define PIOS_ADC_PORTS { PIOS_ADC_PIN1_GPIO_PORT, PIOS_ADC_PIN2_GPIO_PORT, PIOS_ADC_PIN3_GPIO_PORT, PIOS_ADC_PIN4_GPIO_PORT, PIOS_ADC_PIN5_GPIO_PORT }
#define PIOS_ADC_PINS { PIOS_ADC_PIN1_GPIO_PIN, PIOS_ADC_PIN2_GPIO_PIN, PIOS_ADC_PIN3_GPIO_PIN, PIOS_ADC_PIN4_GPIO_PIN, PIOS_ADC_PIN5_GPIO_PIN }
#define PIOS_ADC_CHANNELS { PIOS_ADC_PIN1_GPIO_CHANNEL, PIOS_ADC_PIN2_GPIO_CHANNEL, PIOS_ADC_PIN3_GPIO_CHANNEL, PIOS_ADC_PIN4_GPIO_CHANNEL, PIOS_ADC_PIN5_GPIO_CHANNEL }
#define PIOS_ADC_MAPPING { PIOS_ADC_PIN1_ADC, PIOS_ADC_PIN2_ADC, PIOS_ADC_PIN3_ADC, PIOS_ADC_PIN4_ADC, PIOS_ADC_PIN5_ADC }
#define PIOS_ADC_CHANNEL_MAPPING { PIOS_ADC_PIN1_ADC_NUMBER, PIOS_ADC_PIN2_ADC_NUMBER, PIOS_ADC_PIN3_ADC_NUMBER, PIOS_ADC_PIN4_ADC_NUMBER, PIOS_ADC_PIN5_ADC_NUMBER }
#endif
#define PIOS_ADC_NUM_PINS 4
#define PIOS_ADC_PORTS { PIOS_ADC_PIN1_GPIO_PORT, PIOS_ADC_PIN2_GPIO_PORT, PIOS_ADC_PIN3_GPIO_PORT, PIOS_ADC_PIN4_GPIO_PORT }
#define PIOS_ADC_PINS { PIOS_ADC_PIN1_GPIO_PIN, PIOS_ADC_PIN2_GPIO_PIN, PIOS_ADC_PIN3_GPIO_PIN, PIOS_ADC_PIN4_GPIO_PIN }
#define PIOS_ADC_CHANNELS { PIOS_ADC_PIN1_GPIO_CHANNEL, PIOS_ADC_PIN2_GPIO_CHANNEL, PIOS_ADC_PIN3_GPIO_CHANNEL, PIOS_ADC_PIN4_GPIO_CHANNEL }
#define PIOS_ADC_MAPPING { PIOS_ADC_PIN1_ADC, PIOS_ADC_PIN2_ADC, PIOS_ADC_PIN3_ADC, PIOS_ADC_PIN4_ADC }
#define PIOS_ADC_CHANNEL_MAPPING { PIOS_ADC_PIN1_ADC_NUMBER, PIOS_ADC_PIN2_ADC_NUMBER, PIOS_ADC_PIN3_ADC_NUMBER, PIOS_ADC_PIN4_ADC_NUMBER }
#define PIOS_ADC_NUM_ADC_CHANNELS 2
#define PIOS_ADC_USE_ADC2 1
#elif defined(MOVE_CONTROLLER)
//-------------------------
// ADC
// PIOS_ADC_PinGet(0) = Accel X
// PIOS_ADC_PinGet(1) = Accel Y
// PIOS_ADC_PinGet(2) = Accel Z
// PIOS_ADC_PinGet(3) = (ND)
// PIOS_ADC_PinGet(4) = Gyro X
// PIOS_ADC_PinGet(5) = Gyro Y
// PIOS_ADC_PinGet(6) = Gyro Z
// PIOS_ADC_PinGet(7) = (ND)
//-------------------------
//#define PIOS_ADC_OVERSAMPLING_RATE 1
#define PIOS_ADC_USE_TEMP_SENSOR 0
#define PIOS_ADC_TEMP_SENSOR_ADC ADC1
#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
#define PIOS_ADC_PIN1_GPIO_PORT GPIOA // PA1 (Accel X)
#define PIOS_ADC_PIN1_GPIO_PIN GPIO_Pin_1 // ADC12_IN1
#define PIOS_ADC_PIN1_GPIO_CHANNEL ADC_Channel_1
#define PIOS_ADC_PIN1_ADC ADC1
#define PIOS_ADC_PIN1_ADC_NUMBER 1
#define PIOS_ADC_PIN2_GPIO_PORT GPIOC // PC3 (Accel Y)
#define PIOS_ADC_PIN2_GPIO_PIN GPIO_Pin_3 // ADC12_IN13
#define PIOS_ADC_PIN2_GPIO_CHANNEL ADC_Channel_13
#define PIOS_ADC_PIN2_ADC ADC2
#define PIOS_ADC_PIN2_ADC_NUMBER 1
#define PIOS_ADC_PIN3_GPIO_PORT GPIOA // PA3 (Accel Z)
#define PIOS_ADC_PIN3_GPIO_PIN GPIO_Pin_3 // ADC12_IN3
#define PIOS_ADC_PIN3_GPIO_CHANNEL ADC_Channel_3
#define PIOS_ADC_PIN3_ADC ADC1
#define PIOS_ADC_PIN3_ADC_NUMBER 2
#define PIOS_ADC_PIN4_GPIO_PORT GPIOA // PA6 (not used)
#define PIOS_ADC_PIN4_GPIO_PIN GPIO_Pin_6 // ADC12_IN6
#define PIOS_ADC_PIN4_GPIO_CHANNEL ADC_Channel_6
#define PIOS_ADC_PIN4_ADC ADC2
#define PIOS_ADC_PIN4_ADC_NUMBER 2
#define PIOS_ADC_PIN5_GPIO_PORT GPIOC // PC1 (Gyro X)
#define PIOS_ADC_PIN5_GPIO_PIN GPIO_Pin_1 // ADC12_IN11
#define PIOS_ADC_PIN5_GPIO_CHANNEL ADC_Channel_11
#define PIOS_ADC_PIN5_ADC ADC1
#define PIOS_ADC_PIN5_ADC_NUMBER 3
#define PIOS_ADC_PIN6_GPIO_PORT GPIOC // PC0 (Gyro Y)
#define PIOS_ADC_PIN6_GPIO_PIN GPIO_Pin_0 // ADC12_IN10
#define PIOS_ADC_PIN6_GPIO_CHANNEL ADC_Channel_10
#define PIOS_ADC_PIN6_ADC ADC2
#define PIOS_ADC_PIN6_ADC_NUMBER 3
#define PIOS_ADC_PIN7_GPIO_PORT GPIOC // PC2 (Gyro Z)
#define PIOS_ADC_PIN7_GPIO_PIN GPIO_Pin_2 // ADC12_IN12
#define PIOS_ADC_PIN7_GPIO_CHANNEL ADC_Channel_12
#define PIOS_ADC_PIN7_ADC ADC1
#define PIOS_ADC_PIN7_ADC_NUMBER 4
#define PIOS_ADC_PIN8_GPIO_PORT GPIOB // PB1 (not used)
#define PIOS_ADC_PIN8_GPIO_PIN GPIO_Pin_1 // ADC12_IN9
#define PIOS_ADC_PIN8_GPIO_CHANNEL ADC_Channel_9
#define PIOS_ADC_PIN8_ADC ADC2
#define PIOS_ADC_PIN8_ADC_NUMBER 4
#define PIOS_ADC_NUM_PINS 8
#define PIOS_ADC_PORTS { PIOS_ADC_PIN1_GPIO_PORT, PIOS_ADC_PIN2_GPIO_PORT, PIOS_ADC_PIN3_GPIO_PORT, PIOS_ADC_PIN4_GPIO_PORT, PIOS_ADC_PIN5_GPIO_PORT, PIOS_ADC_PIN6_GPIO_PORT, PIOS_ADC_PIN7_GPIO_PORT, PIOS_ADC_PIN8_GPIO_PORT }
#define PIOS_ADC_PINS { PIOS_ADC_PIN1_GPIO_PIN, PIOS_ADC_PIN2_GPIO_PIN, PIOS_ADC_PIN3_GPIO_PIN, PIOS_ADC_PIN4_GPIO_PIN, PIOS_ADC_PIN5_GPIO_PIN, PIOS_ADC_PIN6_GPIO_PIN, PIOS_ADC_PIN7_GPIO_PIN, PIOS_ADC_PIN8_GPIO_PIN }
#define PIOS_ADC_CHANNELS { PIOS_ADC_PIN1_GPIO_CHANNEL, PIOS_ADC_PIN2_GPIO_CHANNEL, PIOS_ADC_PIN3_GPIO_CHANNEL, PIOS_ADC_PIN4_GPIO_CHANNEL, PIOS_ADC_PIN5_GPIO_CHANNEL, PIOS_ADC_PIN6_GPIO_CHANNEL, PIOS_ADC_PIN7_GPIO_CHANNEL, PIOS_ADC_PIN8_GPIO_CHANNEL }
#define PIOS_ADC_MAPPING { PIOS_ADC_PIN1_ADC, PIOS_ADC_PIN2_ADC, PIOS_ADC_PIN3_ADC, PIOS_ADC_PIN4_ADC, PIOS_ADC_PIN5_ADC, PIOS_ADC_PIN6_ADC, PIOS_ADC_PIN7_ADC, PIOS_ADC_PIN8_ADC }
#define PIOS_ADC_CHANNEL_MAPPING { PIOS_ADC_PIN1_ADC_NUMBER, PIOS_ADC_PIN2_ADC_NUMBER, PIOS_ADC_PIN3_ADC_NUMBER, PIOS_ADC_PIN4_ADC_NUMBER, PIOS_ADC_PIN5_ADC_NUMBER, PIOS_ADC_PIN6_ADC_NUMBER, PIOS_ADC_PIN7_ADC_NUMBER,PIOS_ADC_PIN8_ADC_NUMBER }
#define PIOS_ADC_NUM_ADC_CHANNELS 2
#define PIOS_ADC_USE_ADC2 1
#else
#define PIOS_ADC_USE_TEMP_SENSOR 0
#define PIOS_ADC_TEMP_SENSOR_ADC ADC1
#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
#define PIOS_ADC_NUM_PINS 0
#define PIOS_ADC_PORTS { }
#define PIOS_ADC_PINS { }
#define PIOS_ADC_CHANNELS { }
#define PIOS_ADC_MAPPING { }
#define PIOS_ADC_CHANNEL_MAPPING { }
#define PIOS_ADC_NUM_ADC_CHANNELS 0
#define PIOS_ADC_USE_ADC2 0
#endif
#define PIOS_ADC_NUM_CHANNELS (PIOS_ADC_NUM_PINS + PIOS_ADC_USE_TEMP_SENSOR)
#define PIOS_ADC_CLOCK_FUNCTION RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE)
#define PIOS_ADC_ADCCLK RCC_PCLK2_Div8
/* RCC_PCLK2_Div2: ADC clock = PCLK2/2 */
/* RCC_PCLK2_Div4: ADC clock = PCLK2/4 */
/* RCC_PCLK2_Div6: ADC clock = PCLK2/6 */
/* RCC_PCLK2_Div8: ADC clock = PCLK2/8 */
#define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5
/* Sample time: */
/* With an ADCCLK = 14 MHz and a sampling time of 239.5 cycles: */
/* Tconv = 239.5 + 12.5 = 252 cycles = 18<31>s */
/* (1 / (ADCCLK / CYCLES)) = Sample Time (<28>S) */
#define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_LOW
// Currently analog acquistion hard coded at 480 Hz
// PCKL2 = HCLK / 16
// ADCCLK = PCLK2 / 2
#define PIOS_ADC_RATE (72.0e6 / 1.0 / 8.0 / 252.0 / (PIOS_ADC_NUM_CHANNELS >> PIOS_ADC_USE_ADC2))
#define PIOS_ADC_MAX_OVERSAMPLING 36
#define PIOS_COM_VCP_USB (pios_com_vcp_usb_id)
//------------------------
// PIOS_RCVR
@ -492,18 +202,11 @@ extern uint32_t pios_com_usart3_id;
// USB
//-------------------------
#define PIOS_USB_HID_MAX_DEVS 1
#define PIOS_USB_ENABLED 1
#define PIOS_USB_HID_MAX_DEVS 1
#define PIOS_USB_MAX_DEVS 1
#ifdef MOVE_CONTROLLER
#define PIOS_USB_DETECT_GPIO_PORT GPIOD
#define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_7
#define PIOS_USB_DETECT_EXTI_LINE EXTI_Line4
#else
#define PIOS_USB_DETECT_GPIO_PORT GPIOC
#define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_15
#define PIOS_USB_DETECT_EXTI_LINE EXTI_Line15
#endif
#endif /* STM32103CB_AHRS_H_ */
#endif /* STM32103CB_PIPXTREME_H_ */

View File

@ -72,7 +72,7 @@ FLASH_TOOL = OPENOCD
# List of modules to include
OPTMODULES =
MODULES = TransmitterControls FirmwareIAP
MODULES = TransmitterControls FirmwareIAP RadioComBridge
ifeq ($(ENABLE_MOVE_CONTROLLER), YES)
MODULES += AttitudeMARG
endif
@ -196,6 +196,16 @@ SRC += $(PIOSSTM32F10X)/pios_wdg.c
SRC += $(PIOSSTM32F10X)/pios_tim.c
SRC += $(PIOSSTM32F10X)/pios_pwm.c
# PIOS USB related files (separated to make code maintenance more easy)
SRC += $(PIOSSTM32F10X)/pios_usb.c
SRC += $(PIOSSTM32F10X)/pios_usbhook.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid.c
SRC += $(PIOSSTM32F10X)/pios_usb_cdc.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c
SRC += $(OPSYSTEM)/pios_usb_board_data.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
## PIOS Hardware (Common)
SRC += $(PIOSCOMMON)/pios_crc.c

View File

@ -36,9 +36,7 @@
/* Enable/Disable PiOS Modules */
//#define PIOS_INCLUDE_ADC
#define PIOS_INCLUDE_DELAY
#ifdef MOVE_CONTROLLER
#define PIOS_INCLUDE_I2C
#endif
//#define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP
@ -56,9 +54,12 @@
//#define PIOS_INCLUDE_GPS
//#define PIOS_INCLUDE_SERVO
//#define PIOS_INCLUDE_SPI
#define PIOS_INCLUDE_SPI
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_USART
#define PIOS_INCLUDE_USB
#define PIOS_INCLUDE_USB_HID
#define PIOS_INCLUDE_USB_CDC
#define PIOS_INCLUDE_COM
#define PIOS_INCLUDE_SETTINGS
#define PIOS_INCLUDE_FREERTOS
@ -69,11 +70,6 @@
#define PIOS_INCLUDE_BL_HELPER
#define PIOS_INCLUDE_FLASH
#ifdef MOVE_CONTROLLER
#define PIOS_INCLUDE_MARG_MAHONY
#define PIOS_INCLUDE_AK8974
#define PIOS_INCLUDE_KXSC4
#endif
#define PIOS_UAVTALK_DEBUG

View File

@ -39,7 +39,7 @@
#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)
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_PIPXTREME
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_PIPXTREME, USB_OP_BOARD_MODE_FW)
#endif /* PIOS_USB_BOARD_DATA_H */

View File

@ -35,6 +35,250 @@
#include <manualcontrolsettings.h>
#include <gcsreceiver.h>
#if defined(PIOS_INCLUDE_LED)
#include <pios_led_priv.h>
static const struct pios_led pios_leds[] = {
[PIOS_LED_USB] = {
.pin = {
//.gpio = GPIOA,
.gpio = GPIOC,
.init = {
//.GPIO_Pin = GPIO_Pin_3,
.GPIO_Pin = GPIO_Pin_13,
.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 */
#if defined(PIOS_INCLUDE_SPI)
#include <pios_spi_priv.h>
/* OP Interface
*
* NOTE: Leave this declared as const data so that it ends up in the
* .rodata section (ie. Flash) rather than in the .bss section (RAM).
*/
void PIOS_SPI_port_irq_handler(void);
void DMA1_Channel5_IRQHandler() __attribute__ ((alias ("PIOS_SPI_port_irq_handler")));
void DMA1_Channel4_IRQHandler() __attribute__ ((alias ("PIOS_SPI_port_irq_handler")));
static const struct pios_spi_cfg pios_spi_port_cfg =
{
.regs = SPI1,
.init =
{
.SPI_Mode = SPI_Mode_Master,
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
.SPI_DataSize = SPI_DataSize_8b,
.SPI_NSS = SPI_NSS_Soft,
.SPI_FirstBit = SPI_FirstBit_MSB,
.SPI_CRCPolynomial = 0,
.SPI_CPOL = SPI_CPOL_Low,
.SPI_CPHA = SPI_CPHA_1Edge,
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256, // slowest SCLK
},
.use_crc = FALSE,
.dma =
{
.ahb_clk = RCC_AHBPeriph_DMA1,
.irq =
{
.flags = (DMA1_FLAG_TC2 | DMA1_FLAG_TE2 | DMA1_FLAG_HT2 | DMA1_FLAG_GL2),
.init = {
.NVIC_IRQChannel = DMA1_Channel2_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.rx = {
.channel = DMA1_Channel2,
.init = {
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
.DMA_DIR = DMA_DIR_PeripheralSRC,
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
.DMA_MemoryInc = DMA_MemoryInc_Enable,
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
.DMA_Mode = DMA_Mode_Normal,
.DMA_Priority = DMA_Priority_Medium,
.DMA_M2M = DMA_M2M_Disable,
},
},
.tx = {
.channel = DMA1_Channel3,
.init = {
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
.DMA_DIR = DMA_DIR_PeripheralDST,
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
.DMA_MemoryInc = DMA_MemoryInc_Enable,
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
.DMA_Mode = DMA_Mode_Normal,
.DMA_Priority = DMA_Priority_Medium,
.DMA_M2M = DMA_M2M_Disable,
},
},
},
.ssel =
{
.gpio = GPIOA,
.init =
{
.GPIO_Pin = GPIO_Pin_4,
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_Out_PP,
},
},
.sclk =
{
.gpio = GPIOA,
.init =
{
.GPIO_Pin = GPIO_Pin_5,
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_AF_PP,
},
},
.miso =
{
.gpio = GPIOA,
.init =
{
.GPIO_Pin = GPIO_Pin_6,
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
},
},
.mosi =
{
.gpio = GPIOA,
.init =
{
.GPIO_Pin = GPIO_Pin_7,
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_AF_PP,
},
},
};
uint32_t pios_spi_port_id;
void PIOS_SPI_port_irq_handler(void)
{
/* Call into the generic code to handle the IRQ for this specific device */
PIOS_SPI_IRQ_Handler(pios_spi_port_id);
}
#endif /* PIOS_INCLUDE_SPI */
#if defined(PIOS_INCLUDE_ADC)
/*
* 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();
}
#endif /* PIOS_INCLUDE_ADC */
#if defined(PIOS_INCLUDE_COM)
#include "pios_com_priv.h"
#endif /* PIOS_INCLUDE_COM */
#if defined(PIOS_INCLUDE_USART)
#include "pios_usart_priv.h"
/*
@ -148,16 +392,17 @@ static const struct pios_usart_cfg pios_usart_telem_flexi_cfg = {
},
};
#include "pios_com_priv.h"
#endif /* PIOS_INCLUDE_USART */
#define PIOS_COM_TELEM_RF_RX_BUF_LEN 192
#define PIOS_COM_TELEM_RF_TX_BUF_LEN 192
#define PIOS_COM_GPS_RX_BUF_LEN 96
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 192
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 192
#define PIOS_COM_VCP_USB_RX_BUF_LEN 192
#define PIOS_COM_VCP_USB_TX_BUF_LEN 192
#if defined(PIOS_INCLUDE_RTC)
/*
* Realtime Clock (RTC)
@ -362,10 +607,61 @@ const struct pios_ppm_cfg pios_ppm_cfg = {
*/
uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE];
uint32_t pios_com_telem_usb_id;
uint32_t pios_com_vcp_usb_id;
uint32_t pios_com_usart1_id;
uint32_t pios_com_usart2_id;
uint32_t pios_com_usart3_id;
#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,
},
},
};
#include "pios_usb_board_data_priv.h"
#include "pios_usb_desc_hid_cdc_priv.h"
#include "pios_usb_desc_hid_only_priv.h"
#endif /* PIOS_INCLUDE_USB */
#if defined(PIOS_INCLUDE_COM_MSG)
#include <pios_com_msg_priv.h>
#endif /* PIOS_INCLUDE_COM_MSG */
#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 */
#if defined(PIOS_INCLUDE_USB_CDC)
#include <pios_usb_cdc_priv.h>
const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = {
.ctrl_if = 1,
.ctrl_tx_ep = 2,
.data_if = 2,
.data_rx_ep = 3,
.data_tx_ep = 3,
};
#endif /* PIOS_INCLUDE_USB_CDC */
/**
* PIOS_Board_Init()
* initializes all the core subsystems on this specific hardware
@ -376,6 +672,11 @@ void PIOS_Board_Init(void) {
/* Delay system */
PIOS_DELAY_Init();
/* Set up the SPI interface to the serial flash */
if (PIOS_SPI_Init(&pios_spi_port_id, &pios_spi_port_cfg)) {
PIOS_Assert(0);
}
/* Initialize UAVObject libraries */
EventDispatcherInitialize();
UAVObjInitialize();
@ -398,6 +699,10 @@ void PIOS_Board_Init(void) {
PIOS_RTC_Init(&pios_rtc_main_cfg);
#endif
#if defined(PIOS_INCLUDE_LED)
PIOS_LED_Init(&pios_led_cfg);
#endif /* PIOS_INCLUDE_LED */
/* Initialize the task monitor library */
TaskMonitorInitialize();
@ -407,6 +712,70 @@ void PIOS_Board_Init(void) {
PIOS_TIM_InitClock(&tim_3_cfg);
PIOS_TIM_InitClock(&tim_4_cfg);
#if defined(PIOS_INCLUDE_USB)
/* Initialize board specific USB data */
PIOS_USB_BOARD_DATA_Init();
#if defined(PIOS_INCLUDE_USB_CDC)
if (PIOS_USB_DESC_HID_CDC_Init()) {
PIOS_Assert(0);
}
#else
if (PIOS_USB_DESC_HID_ONLY_Init()) {
PIOS_Assert(0);
}
#endif
uint32_t pios_usb_id;
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
#if defined(PIOS_INCLUDE_USB_CDC)
#if defined(PIOS_INCLUDE_COM)
{
uint32_t pios_usb_cdc_id;
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_VCP_USB_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_VCP_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
rx_buffer, PIOS_COM_VCP_USB_RX_BUF_LEN,
tx_buffer, PIOS_COM_VCP_USB_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_CDC */
#if defined(PIOS_INCLUDE_USB_HID)
/* Configure the usb HID port */
#if defined(PIOS_INCLUDE_COM)
{
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);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN,
tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_HID */
#endif /* PIOS_INCLUDE_USB */
#ifdef TRANSMITTER_BOX
/* Configure the rcvr port */
{
@ -473,9 +842,9 @@ void PIOS_Board_Init(void) {
PIOS_Assert(0);
}
}
PIOS_COM_SendString(PIOS_COM_TELEM_SERIAL, "Hello Telem\n\r");
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");
PIOS_COM_SendString(PIOS_COM_FLEXI, "Hello Flexi\n\r");
/* Remap AFIO pin */
GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE);

View File

@ -32,22 +32,18 @@
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
static const uint8_t usb_product_id[28] = {
static const uint8_t usb_product_id[20] = {
sizeof(usb_product_id),
USB_DESC_TYPE_STRING,
'C', 0,
'o', 0,
'P', 0,
'i', 0,
'p', 0,
'X', 0,
't', 0,
'r', 0,
'e', 0,
'm', 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] = {

View File

@ -1,5 +1,58 @@
#include <pios_config.h>
#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 */
#if defined(PIOS_INCLUDE_SPI)
#include <pios_spi_priv.h>