IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
Source at commit c265151d2b24c011fde22d92154ddcb4aa42d318 created 13 years 17 days ago. By Werner Almesberger, atusb/fw: introduced function flash_end_write to properly finish flashing | |
---|---|
1 | /* |
2 | * boot/dfu.h - DFU protocol constants and data structures |
3 | * |
4 | * Written 2008, 2011 by Werner Almesberger |
5 | * Copyright 2008, 2011 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 flash_start(void); |
85 | int flash_can_write(uint16_t size); |
86 | void flash_write(const uint8_t *buf, uint16_t size); |
87 | void flash_end_write(void); |
88 | uint16_t flash_read(uint8_t *buf, uint16_t size); |
89 | |
90 | |
91 | void dfu_init(void); |
92 | |
93 | #endif /* !DFU_H */ |
94 |