mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-21/Flight Bootloader - Donwload function is now interrupt driven. Had to increase IN polling interval due to some problems.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1530 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
f9a0b799a2
commit
492227c916
@ -10,60 +10,64 @@
|
||||
|
||||
#include "board.h"
|
||||
|
||||
typedef enum {
|
||||
start, keepgoing,
|
||||
} DownloadAction;
|
||||
|
||||
/**************************************************/
|
||||
/* OP_DFU states */
|
||||
/**************************************************/
|
||||
|
||||
typedef enum
|
||||
{DFUidle, //0
|
||||
uploading, //1
|
||||
wrong_packet_received, //2
|
||||
too_many_packets, //3
|
||||
too_few_packets, //4
|
||||
Last_operation_Success, //5
|
||||
downloading, //6
|
||||
idle, //7
|
||||
Last_operation_failed, //8
|
||||
uploadingStarting, //9
|
||||
outsideDevCapabilities, //10
|
||||
test
|
||||
}DFUStates;
|
||||
typedef enum {
|
||||
DFUidle, //0
|
||||
uploading, //1
|
||||
wrong_packet_received, //2
|
||||
too_many_packets, //3
|
||||
too_few_packets, //4
|
||||
Last_operation_Success, //5
|
||||
downloading, //6
|
||||
idle, //7
|
||||
Last_operation_failed, //8
|
||||
uploadingStarting, //9
|
||||
outsideDevCapabilities, //10
|
||||
test
|
||||
} DFUStates;
|
||||
/**************************************************/
|
||||
/* OP_DFU commands */
|
||||
/**************************************************/
|
||||
typedef enum
|
||||
{
|
||||
Reserved, //0
|
||||
Req_Capabilities, //1
|
||||
Rep_Capabilities, //2
|
||||
EnterDFU, //3
|
||||
JumpFW, //4
|
||||
Reset, //5
|
||||
Abort_Operation, //6
|
||||
Upload, //7
|
||||
Op_END, //8
|
||||
Download_Req, //9
|
||||
Download, //10
|
||||
Status_Request, //11
|
||||
Status_Rep //12
|
||||
}DFUCommands;
|
||||
typedef enum {
|
||||
Reserved, //0
|
||||
Req_Capabilities, //1
|
||||
Rep_Capabilities, //2
|
||||
EnterDFU, //3
|
||||
JumpFW, //4
|
||||
Reset, //5
|
||||
Abort_Operation, //6
|
||||
Upload, //7
|
||||
Op_END, //8
|
||||
Download_Req, //9
|
||||
Download, //10
|
||||
Status_Request, //11
|
||||
Status_Rep
|
||||
//12
|
||||
} DFUCommands;
|
||||
/**************************************************/
|
||||
/* OP_DFU transfer types */
|
||||
/**************************************************/
|
||||
typedef enum
|
||||
{
|
||||
FW, //0
|
||||
Hash, //1
|
||||
Descript //2
|
||||
}DFUTransfer;
|
||||
typedef enum {
|
||||
FW, //0
|
||||
Hash, //1
|
||||
Descript
|
||||
//2
|
||||
} DFUTransfer;
|
||||
/**************************************************/
|
||||
/* OP_DFU programable programable HW types */
|
||||
/**************************************************/
|
||||
typedef enum
|
||||
{
|
||||
Self_flash, //0
|
||||
Remote_flash_via_spi //1
|
||||
}DFUProgType;
|
||||
typedef enum {
|
||||
Self_flash, //0
|
||||
Remote_flash_via_spi
|
||||
//1
|
||||
} DFUProgType;
|
||||
/**************************************************/
|
||||
/* OP_DFU programable sources */
|
||||
/**************************************************/
|
||||
|
@ -16,7 +16,7 @@
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __OP_DFU_H
|
||||
#define __OP_DFU_H
|
||||
|
||||
#include "common.h"
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct
|
||||
@ -42,7 +42,7 @@ void processComand(uint8_t *Receive_Buffer);
|
||||
uint32_t baseOfAdressType(uint8_t type);
|
||||
uint8_t isBiggerThanAvailable(uint8_t type, uint32_t size);
|
||||
void OPDfuIni(void);
|
||||
void DataDownload();
|
||||
void DataDownload(DownloadAction);
|
||||
#endif /* __OP_DFU_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -164,7 +164,7 @@
|
||||
|
||||
/* CTR service routines */
|
||||
/* associated to defined endpoints */
|
||||
#define EP1_IN_Callback NOP_Process
|
||||
//#define EP1_IN_Callback NOP_Process
|
||||
#define EP2_IN_Callback NOP_Process
|
||||
#define EP3_IN_Callback NOP_Process
|
||||
#define EP4_IN_Callback NOP_Process
|
||||
|
@ -129,7 +129,9 @@ int main(void) {
|
||||
STOPWATCH_Reset();
|
||||
if ((STOPWATCH_ValueGet() > 70000) && (DeviceState == idle))
|
||||
JumpToApp = TRUE;
|
||||
DataDownload();
|
||||
|
||||
|
||||
DataDownload(start);
|
||||
//DelayWithDown(10);//1000000);
|
||||
}
|
||||
if (((*(__IO uint32_t*) StartOfUserCode) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
||||
@ -161,7 +163,7 @@ int main(void) {
|
||||
}
|
||||
if (STOPWATCH_ValueGet() > 2*50 * 100)
|
||||
STOPWATCH_Reset();
|
||||
DataDownload();
|
||||
DataDownload(start);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "usb_istr.h"
|
||||
#include "stm32_eval.h"
|
||||
#include "stm32f10x_flash.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "hw_config.h"
|
||||
#include <string.h>
|
||||
#include "op_dfu.h"
|
||||
@ -70,8 +70,10 @@ extern uint8_t JumpToApp;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
void DataDownload() {
|
||||
if ((DeviceState == downloading) && (GetEPTxStatus(ENDP1) == EP_TX_NAK)) {
|
||||
void DataDownload(DownloadAction action) {
|
||||
if ((DeviceState == downloading)) {
|
||||
if((action==start) && downPacketCurrent!=0)
|
||||
return;
|
||||
uint8_t packetSize;
|
||||
uint32_t offset;
|
||||
SendBuffer[0] = 0x01;
|
||||
|
@ -103,7 +103,7 @@ const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
0x40, /* diff:0x40 wMaxPacketSize: 2 Bytes max */
|
||||
0x00,
|
||||
0x01, /* diff:0x08 bInterval: Polling Interval (32 ms) */
|
||||
0x03, /* diff:0x08 bInterval: Polling Interval (32 ms) */
|
||||
/* 34 */
|
||||
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
|
@ -43,6 +43,10 @@ void EP1_OUT_Callback(void)
|
||||
SetEPRxStatus(ENDP1, EP_RX_VALID);
|
||||
|
||||
}
|
||||
void EP1_IN_Callback(void)
|
||||
{
|
||||
DataDownload(keepgoing);
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user