1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-21/Bootloader - fixes GPS connected issues, enhances timings problems, further work on serial support

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2136 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-11-21 19:37:40 +00:00 committed by zedamota
parent 063d517ae7
commit 98b0f406dc
7 changed files with 36 additions and 168 deletions

View File

@ -155,7 +155,7 @@ SRC += $(PIOSCOMMON)/pios_com.c
#SRC += $(PIOSCOMMON)/pios_bmp085.c
SRC += $(PIOSCOMMON)/pios_opahrs_v0.c
SRC += $(PIOSCOMMON)/pios_bl_helper.c
SRC += $(PIOSCOMMON)/pios_iap.c
SRC += $(PIOSCOMMON)/pios_opahrs_proto.c
SRC += $(PIOSCOMMON)/printf-stdarg.c

View File

@ -66,6 +66,14 @@ typedef enum {
//2
} DFUTransfer;
/**************************************************/
/* OP_DFU transfer port */
/**************************************************/
typedef enum {
Usb, //0
Serial
//2
} DFUPort;
/**************************************************/
/* OP_DFU programable programable HW types */
/**************************************************/
typedef enum {

View File

@ -36,27 +36,17 @@
#define PIOS_INCLUDE_BL_HELPER
#define USB_HID
/* Enable/Disable PiOS Modules */
//#define PIOS_INCLUDE_ADC
#define PIOS_INCLUDE_DELAY
//#define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_LED
//#define PIOS_INCLUDE_SPEKTRUM
//#define PIOS_INCLUDE_PPM
//#define PIOS_INCLUDE_PWM
//#define PIOS_INCLUDE_SERVO
#define PIOS_INCLUDE_SPI
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_USART
#define PIOS_INCLUDE_USB_HID
//#define PIOS_INCLUDE_BMP085
#define PIOS_INCLUDE_OPAHRS
#define PIOS_INCLUDE_COM
//#define PIOS_INCLUDE_SDCARD
//#define PIOS_INCLUDE_SETTINGS
//#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_GPIO
//#define PIOS_INCLUDE_EXTI
#define PIOS_NO_GPS
/* Defaults for Logging */
@ -73,7 +63,6 @@
#define SERVOS_POSITION_MIN 800
#define SERVOS_POSITION_MAX 2200
#endif /* PIOS_CONFIG_H */
/**
* @}

View File

@ -38,6 +38,7 @@
#include "stopwatch.h"
#include "op_dfu.h"
#include "usb_lib.h"
#include "pios_iap.h"
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void FLASH_Download();
@ -59,6 +60,7 @@ uint32_t sweep_steps2 = 100; // * 5 mS -> 500 mS
/* Extern variables ----------------------------------------------------------*/
DFUStates DeviceState;
DFUPort ProgPort;
uint8_t JumpToApp = FALSE;
uint8_t GO_dfu = FALSE;
uint8_t USB_connected = FALSE;
@ -81,13 +83,21 @@ int main() {
if (BSL_HOLD_STATE == 0)
USB_connected = TRUE;
PIOS_IAP_Init();
if (PIOS_IAP_CheckRequest() == TRUE) {
User_DFU_request = TRUE;
PIOS_IAP_ClearRequest();
}
GO_dfu = (USB_connected==TRUE) || (User_DFU_request==TRUE);
if (GO_dfu == TRUE) {
if(USB_connected)
ProgPort=Usb;
else
ProgPort=Serial;
PIOS_Board_Init();
PIOS_OPAHRS_Init();
DeviceState = BLidle;
STOPWATCH_Init(100);
USB_connected = TRUE;
PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 0);
//OPDfuIni(false);

View File

@ -158,7 +158,7 @@ void processComand(uint8_t *xReceive_Buffer) {
case EnterDFU:
if (((DeviceState == BLidle) && (Data0 < numberOfDevices))
|| (DeviceState == DFUidle)) {
if (Data0 > 0)
if (Data0 > 0)//PORQUE???
OPDfuIni(TRUE);
DeviceState = DFUidle;
currentProgrammingDestination = devicesTable[Data0].programmingType;

View File

@ -55,33 +55,11 @@ void PIOS_Board_Init(void) {
/* SPI Init */
PIOS_SPI_Init();
/* Enable and mount the SDCard */
// PIOS_SDCARD_Init();
// PIOS_SDCARD_MountFS(0);
#if defined(PIOS_INCLUDE_SPEKTRUM)
/* SPEKTRUM init must come before comms */
PIOS_SPEKTRUM_Init();
#endif
/* Initialize UAVObject libraries */
// EventDispatcherInitialize();
// UAVObjInitialize();
// UAVObjectsInitializeAll();
/* Initialize the alarms library */
// AlarmsInitialize();
/* Initialize the PiOS library */
PIOS_COM_Init();
//PIOS_Servo_Init();
//PIOS_ADC_Init();
PIOS_GPIO_Init();
#if defined(PIOS_INCLUDE_PWM)
PIOS_PWM_Init();
#endif
#if defined(PIOS_INCLUDE_PPM)
PIOS_PPM_Init();
#endif
#if defined(PIOS_INCLUDE_USB_HID)
PIOS_USB_HID_Init(0);
#endif
@ -358,52 +336,7 @@ const struct pios_usart_cfg pios_usart_telem_cfg = {
},
};
/*
* GPS USART
*/
void PIOS_USART_gps_irq_handler(void);
void USART3_IRQHandler() __attribute__ ((alias ("PIOS_USART_gps_irq_handler")));
const struct pios_usart_cfg pios_usart_gps_cfg = {
.regs = USART3,
.remap = GPIO_PartialRemap_USART3,
.init = {
#if defined (PIOS_COM_GPS_BAUDRATE)
.USART_BaudRate = PIOS_COM_GPS_BAUDRATE,
#else
.USART_BaudRate = 57600,
#endif
.USART_WordLength = USART_WordLength_8b,
.USART_Parity = USART_Parity_No,
.USART_StopBits = USART_StopBits_1,
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
},
.irq = {
.handler = PIOS_USART_gps_irq_handler,
.init = {
.NVIC_IRQChannel = USART3_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.rx = {
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_11,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_IPU,
},
},
.tx = {
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_10,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_AF_PP,
},
},
};
#ifdef PIOS_COM_AUX
/*
@ -454,54 +387,6 @@ const struct pios_usart_cfg pios_usart_aux_cfg = {
};
#endif
#ifdef PIOS_COM_SPEKTRUM
/*
* SPEKTRUM USART
*/
void PIOS_USART_spektrum_irq_handler(void);
void USART1_IRQHandler() __attribute__ ((alias ("PIOS_USART_spektrum_irq_handler")));
const struct pios_usart_cfg pios_usart_spektrum_cfg = {
.regs = USART1,
.init = {
#if defined (PIOS_COM_SPEKTRUM_BAUDRATE)
.USART_BaudRate = PIOS_COM_SPEKTRUM_BAUDRATE,
#else
.USART_BaudRate = 115200,
#endif
.USART_WordLength = USART_WordLength_8b,
.USART_Parity = USART_Parity_No,
.USART_StopBits = USART_StopBits_1,
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
.USART_Mode = USART_Mode_Rx,
},
.irq = {
.handler = PIOS_USART_spektrum_irq_handler,
.init = {
.NVIC_IRQChannel = USART1_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.rx = {
.gpio = GPIOA,
.init = {
.GPIO_Pin = GPIO_Pin_10,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_IPU,
},
},
.tx = {
.gpio = GPIOA,
.init = {
.GPIO_Pin = GPIO_Pin_9,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
},
},
};
#endif
/*
* Board specific number of devices.
*/
@ -510,22 +395,12 @@ struct pios_usart_dev pios_usart_devs[] = {
{
.cfg = &pios_usart_telem_cfg,
},
#define PIOS_USART_GPS 1
{
.cfg = &pios_usart_gps_cfg,
},
#ifdef PIOS_COM_AUX
#define PIOS_USART_AUX 2
#define PIOS_USART_AUX 1
{
.cfg = &pios_usart_aux_cfg,
},
#endif
#ifdef PIOS_COM_SPEKTRUM
#define PIOS_USART_AUX 2
{
.cfg = &pios_usart_spektrum_cfg,
},
#endif
};
uint8_t pios_usart_num_devices = NELEMENTS(pios_usart_devs);
@ -535,10 +410,6 @@ void PIOS_USART_telem_irq_handler(void)
PIOS_USART_IRQ_Handler(PIOS_USART_TELEM);
}
void PIOS_USART_gps_irq_handler(void)
{
PIOS_USART_IRQ_Handler(PIOS_USART_GPS);
}
#ifdef PIOS_COM_AUX
void PIOS_USART_aux_irq_handler(void)
@ -547,12 +418,6 @@ void PIOS_USART_aux_irq_handler(void)
}
#endif
#ifdef PIOS_COM_SPEKTRUM
void PIOS_USART_spektrum_irq_handler(void)
{
SPEKTRUM_IRQHandler();
}
#endif
/*
* COM devices
@ -569,10 +434,6 @@ struct pios_com_dev pios_com_devs[] = {
.id = PIOS_USART_TELEM,
.driver = &pios_usart_com_driver,
},
{
.id = PIOS_USART_GPS,
.driver = &pios_usart_com_driver,
},
#if defined(PIOS_INCLUDE_USB_HID)
{
.id = 0,
@ -585,12 +446,7 @@ struct pios_com_dev pios_com_devs[] = {
.driver = &pios_usart_com_driver,
},
#endif
#ifdef PIOS_COM_SPEKTRUM
{
.id = PIOS_USART_AUX,
.driver = &pios_usart_com_driver,
},
#endif
};
const uint8_t pios_com_num_devices = NELEMENTS(pios_com_devs);

View File

@ -128,9 +128,14 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
#define PIOS_COM_TELEM_BAUDRATE 57600
#define PIOS_COM_GPS_BAUDRATE 57600
#define PIOS_COM_TELEM_RF 0
#define PIOS_COM_GPS 1
#define PIOS_COM_TELEM_USB 2
#ifdef PIOS_NO_GPS
#define PIOS_COM_TELEM_RF 0
#define PIOS_COM_TELEM_USB 1
#else
#define PIOS_COM_TELEM_RF 0
#define PIOS_COM_GPS 1
#define PIOS_COM_TELEM_USB 2
#endif
#ifdef PIOS_ENABLE_AUX_UART
#define PIOS_COM_AUX_BAUDRATE 57600