C8051F32x firmware infrastructure
Sign in or create your account | Project List | Help
C8051F32x firmware infrastructure Git Source Tree
Root/
| 1 | /* |
| 2 | * boot/dfu.h - DFU protocol constants and data structures |
| 3 | * |
| 4 | * Written 2008 by Werner Almesberger |
| 5 | * Copyright 2008 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #ifndef DFU_H |
| 15 | #define DFU_H |
| 16 | |
| 17 | #include <stdint.h> |
| 18 | |
| 19 | |
| 20 | enum dfu_request { |
| 21 | DFU_DETACH, |
| 22 | DFU_DNLOAD, |
| 23 | DFU_UPLOAD, |
| 24 | DFU_GETSTATUS, |
| 25 | DFU_CLRSTATUS, |
| 26 | DFU_GETSTATE, |
| 27 | DFU_ABORT, |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | enum dfu_status { |
| 32 | OK, |
| 33 | errTARGET, |
| 34 | errFILE, |
| 35 | errWRITE, |
| 36 | errERASE, |
| 37 | errCHECK_ERASED, |
| 38 | errPROG, |
| 39 | errVERIFY, |
| 40 | errADDRESS, |
| 41 | errNOTDONE, |
| 42 | errFIRMWARE, |
| 43 | errVENDOR, |
| 44 | errUSBR, |
| 45 | errPOR, |
| 46 | errUNKNOWN, |
| 47 | errSTALLEDPKT, |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | enum dfu_state { |
| 52 | appIDLE, |
| 53 | appDETACH, |
| 54 | dfuIDLE, |
| 55 | dfuDNLOAD_SYNC, |
| 56 | dfuDNBUSY, |
| 57 | dfuDNLOAD_IDLE, |
| 58 | dfuMANIFEST_SYNC, |
| 59 | dfuMANIFEST, |
| 60 | dfuMANIFEST_WAIT_RESET, |
| 61 | dfuUPLOAD_IDLE, |
| 62 | dfuERROR |
| 63 | }; |
| 64 | |
| 65 | |
| 66 | #define DFU_DT_FUNCTIONAL 0x21 /* DFU FUNCTIONAL descriptor type */ |
| 67 | |
| 68 | |
| 69 | #define DFU_TO_DEV(req) (0x21 | (req) << 8) |
| 70 | #define DFU_FROM_DEV(req) (0xa1 | (req) << 8) |
| 71 | |
| 72 | |
| 73 | struct dfu { |
| 74 | uint8_t status; /* bStatus */ |
| 75 | uint8_t toL, toM, toH; /* bwPollTimeout */ |
| 76 | uint8_t state; /* bState */ |
| 77 | uint8_t iString; |
| 78 | }; |
| 79 | |
| 80 | |
| 81 | extern struct dfu dfu; |
| 82 | |
| 83 | |
| 84 | void dfu_init(void); |
| 85 | |
| 86 | #endif /* !DFU_H */ |
| 87 |
Branches:
master
