mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-26 20:14:37 +02:00
f91738c306
- dfu.c: updated includes - dfu.c (device_descriptor): renamed USB IDs from USB_VENDOR/PRODUCT to DFU_USB_VENDOR/PRODUCT to allow differentiation - dfu.c: changed all __bit to "int" - dfu.c: removed all __xdata and __reentrant - dfu.c: changed "ep0" to "eps[0]" - dfu.c (payload, flash_erase_page, flash_write_byte, block_write, block_receive, block_transmit, my_setup): abstracted Flash interface and removed target-specific operations - dfu.h: added prototypes for target-specific Flash operations - dfu,c (my_setup, my_descr): removed SDCC-specific hacks - dfu.c (my_reset): commented out - did we actually use this ?
93 lines
1.5 KiB
C
93 lines
1.5 KiB
C
/*
|
|
* boot/dfu.h - DFU protocol constants and data structures
|
|
*
|
|
* Written 2008, 2011 by Werner Almesberger
|
|
* Copyright 2008, 2011 Werner Almesberger
|
|
*
|
|
* 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 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
|
|
#ifndef DFU_H
|
|
#define DFU_H
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
enum dfu_request {
|
|
DFU_DETACH,
|
|
DFU_DNLOAD,
|
|
DFU_UPLOAD,
|
|
DFU_GETSTATUS,
|
|
DFU_CLRSTATUS,
|
|
DFU_GETSTATE,
|
|
DFU_ABORT,
|
|
};
|
|
|
|
|
|
enum dfu_status {
|
|
OK,
|
|
errTARGET,
|
|
errFILE,
|
|
errWRITE,
|
|
errERASE,
|
|
errCHECK_ERASED,
|
|
errPROG,
|
|
errVERIFY,
|
|
errADDRESS,
|
|
errNOTDONE,
|
|
errFIRMWARE,
|
|
errVENDOR,
|
|
errUSBR,
|
|
errPOR,
|
|
errUNKNOWN,
|
|
errSTALLEDPKT,
|
|
};
|
|
|
|
|
|
enum dfu_state {
|
|
appIDLE,
|
|
appDETACH,
|
|
dfuIDLE,
|
|
dfuDNLOAD_SYNC,
|
|
dfuDNBUSY,
|
|
dfuDNLOAD_IDLE,
|
|
dfuMANIFEST_SYNC,
|
|
dfuMANIFEST,
|
|
dfuMANIFEST_WAIT_RESET,
|
|
dfuUPLOAD_IDLE,
|
|
dfuERROR
|
|
};
|
|
|
|
|
|
#define DFU_DT_FUNCTIONAL 0x21 /* DFU FUNCTIONAL descriptor type */
|
|
|
|
|
|
#define DFU_TO_DEV(req) (0x21 | (req) << 8)
|
|
#define DFU_FROM_DEV(req) (0xa1 | (req) << 8)
|
|
|
|
|
|
struct dfu {
|
|
uint8_t status; /* bStatus */
|
|
uint8_t toL, toM, toH; /* bwPollTimeout */
|
|
uint8_t state; /* bState */
|
|
uint8_t iString;
|
|
};
|
|
|
|
|
|
extern struct dfu dfu;
|
|
|
|
|
|
void flash_start(void);
|
|
int flash_can_write(uint16_t size);
|
|
void flash_write(const uint8_t *buf, uint16_t size);
|
|
uint16_t flash_read(uint8_t *buf, uint16_t size);
|
|
|
|
|
|
void dfu_init(void);
|
|
|
|
#endif /* !DFU_H */
|