2727 *
2828 * @brief The principle dfu state machine as well as the data
2929 * transfer callbacks accessed by the usb library
30- *
30+ *
3131 *
3232 */
3333
@@ -50,9 +50,9 @@ PLOT code_copy_lock;
5050/* todo: force dfu globals to be singleton to avoid re-inits? */
5151void dfuInit (void ) {
5252 dfuAppStatus .bStatus = OK ;
53- dfuAppStatus .bwPollTimeout0 = 0x00 ;
54- dfuAppStatus .bwPollTimeout1 = 0x00 ;
55- dfuAppStatus .bwPollTimeout2 = 0x00 ;
53+ dfuAppStatus .bwPollTimeout0 = 0x00 ;
54+ dfuAppStatus .bwPollTimeout1 = 0x00 ;
55+ dfuAppStatus .bwPollTimeout2 = 0x00 ;
5656 dfuAppStatus .bState = dfuIDLE ;
5757 dfuAppStatus .iString = 0x00 ; /* all strings must be 0x00 until we make them! */
5858 userFirmwareLen = 0 ;
@@ -69,7 +69,7 @@ bool dfuUpdateByRequest(void) {
6969 dfuBusy = TRUE;
7070
7171 u8 startState = dfuAppStatus .bState ;
72- dfuAppStatus .bStatus = OK ;
72+ dfuAppStatus .bStatus = OK ;
7373 /* often leaner to nest if's then embed a switch/case */
7474 if (startState == dfuIDLE ) {
7575 /* device running inside DFU mode */
@@ -84,7 +84,7 @@ bool dfuUpdateByRequest(void) {
8484 if (pInformation -> Current_AlternateSetting == 1 ) {
8585 userAppAddr = USER_CODE_FLASH ;
8686 userFlash = TRUE;
87-
87+
8888 /* make sure the flash is setup properly, unlock it */
8989 setupFLASH ();
9090 flashUnlock ();
@@ -95,26 +95,26 @@ bool dfuUpdateByRequest(void) {
9595 }
9696 } else {
9797 dfuAppStatus .bState = dfuERROR ;
98- dfuAppStatus .bStatus = errNOTDONE ;
98+ dfuAppStatus .bStatus = errNOTDONE ;
9999 }
100100 } else if (pInformation -> USBbRequest == DFU_UPLOAD ) {
101101 dfuAppStatus .bState = dfuUPLOAD_IDLE ;
102102 } else if (pInformation -> USBbRequest == DFU_ABORT ) {
103103 dfuAppStatus .bState = dfuIDLE ;
104- dfuAppStatus .bStatus = OK ; /* are we really ok? we were just aborted */
104+ dfuAppStatus .bStatus = OK ; /* are we really ok? we were just aborted */
105105 } else if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
106106 dfuAppStatus .bState = dfuIDLE ;
107107 } else if (pInformation -> USBbRequest == DFU_GETSTATE ) {
108108 dfuAppStatus .bState = dfuIDLE ;
109109 } else {
110110 dfuAppStatus .bState = dfuERROR ;
111- dfuAppStatus .bStatus = errSTALLEDPKT ;
111+ dfuAppStatus .bStatus = errSTALLEDPKT ;
112112 }
113113
114114 } else if (startState == dfuDNLOAD_SYNC ) {
115115 /* device received block, waiting for DFU_GETSTATUS request */
116116
117- if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
117+ if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
118118 /* todo, add routine to wait for last block write to finish */
119119 if (userFlash ) {
120120 if (code_copy_lock == WAIT ) {
@@ -124,7 +124,7 @@ bool dfuUpdateByRequest(void) {
124124 dfuAppStatus .bState = dfuDNBUSY ;
125125
126126 } else if (code_copy_lock == BEGINNING ) {
127- dfuAppStatus .bState = dfuDNLOAD_SYNC ;
127+ dfuAppStatus .bState = dfuDNLOAD_SYNC ;
128128
129129 } else if (code_copy_lock == MIDDLE ) {
130130 dfuAppStatus .bState = dfuDNLOAD_SYNC ;
@@ -144,7 +144,7 @@ bool dfuUpdateByRequest(void) {
144144 dfuAppStatus .bState = dfuDNLOAD_SYNC ;
145145 } else {
146146 dfuAppStatus .bState = dfuERROR ;
147- dfuAppStatus .bStatus = errSTALLEDPKT ;
147+ dfuAppStatus .bStatus = errSTALLEDPKT ;
148148 }
149149
150150 } else if (startState == dfuDNBUSY ) {
@@ -165,10 +165,10 @@ bool dfuUpdateByRequest(void) {
165165 } else {
166166 /* todo, support "disagreement" if device expects more data than this */
167167 dfuAppStatus .bState = dfuMANIFEST_SYNC ;
168-
168+
169169 /* relock the flash */
170170 flashLock ();
171- }
171+ }
172172 } else if (pInformation -> USBbRequest == DFU_ABORT ) {
173173 dfuAppStatus .bState = dfuIDLE ;
174174 } else if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
@@ -177,20 +177,20 @@ bool dfuUpdateByRequest(void) {
177177 dfuAppStatus .bState = dfuIDLE ;
178178 } else {
179179 dfuAppStatus .bState = dfuERROR ;
180- dfuAppStatus .bStatus = errSTALLEDPKT ;
180+ dfuAppStatus .bStatus = errSTALLEDPKT ;
181181 }
182182
183183 } else if (startState == dfuMANIFEST_SYNC ) {
184184 /* device has received last block, waiting DFU_GETSTATUS request */
185-
185+
186186 if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
187187 dfuAppStatus .bState = dfuMANIFEST_WAIT_RESET ;
188188 dfuAppStatus .bStatus = OK ;
189189 } else if (pInformation -> USBbRequest == DFU_GETSTATE ) {
190190 dfuAppStatus .bState = dfuMANIFEST_SYNC ;
191191 } else {
192192 dfuAppStatus .bState = dfuERROR ;
193- dfuAppStatus .bStatus = errSTALLEDPKT ;
193+ dfuAppStatus .bStatus = errSTALLEDPKT ;
194194 }
195195
196196 } else if (startState == dfuMANIFEST ) {
@@ -210,10 +210,10 @@ bool dfuUpdateByRequest(void) {
210210 } else if (startState == dfuUPLOAD_IDLE ) {
211211 /* device expecting further dfu_upload requests */
212212
213- if (pInformation -> USBbRequest == DFU_UPLOAD ) {
213+ if (pInformation -> USBbRequest == DFU_UPLOAD ) {
214214 /* todo, add routine to wait for last block write to finish */
215215 dfuAppStatus .bState = dfuERROR ;
216- dfuAppStatus .bStatus = errSTALLEDPKT ;
216+ dfuAppStatus .bStatus = errSTALLEDPKT ;
217217 } else if (pInformation -> USBbRequest == DFU_ABORT ) {
218218 dfuAppStatus .bState = dfuIDLE ;
219219 } else if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
@@ -222,31 +222,31 @@ bool dfuUpdateByRequest(void) {
222222 dfuAppStatus .bState = dfuUPLOAD_IDLE ;
223223 } else {
224224 dfuAppStatus .bState = dfuERROR ;
225- dfuAppStatus .bStatus = errSTALLEDPKT ;
225+ dfuAppStatus .bStatus = errSTALLEDPKT ;
226226 }
227-
227+
228228
229229 } else if (startState == dfuERROR ) {
230230 /* status is in error, awaiting DFU_CLRSTATUS request */
231231
232- if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
232+ if (pInformation -> USBbRequest == DFU_GETSTATUS ) {
233233 /* todo, add routine to wait for last block write to finish */
234234 dfuAppStatus .bState = dfuERROR ;
235235 } else if (pInformation -> USBbRequest == DFU_GETSTATE ) {
236236 dfuAppStatus .bState = dfuERROR ;
237237 } else if (pInformation -> USBbRequest == DFU_CLRSTATUS ) {
238238 /* todo handle any cleanup we need here */
239239 dfuAppStatus .bState = dfuIDLE ;
240- dfuAppStatus .bStatus = OK ;
240+ dfuAppStatus .bStatus = OK ;
241241 } else {
242242 dfuAppStatus .bState = dfuERROR ;
243- dfuAppStatus .bStatus = errSTALLEDPKT ;
244- }
243+ dfuAppStatus .bStatus = errSTALLEDPKT ;
244+ }
245245
246246 } else {
247247 /* some kind of error... */
248248 dfuAppStatus .bState = dfuERROR ;
249- dfuAppStatus .bStatus = errSTALLEDPKT ;
249+ dfuAppStatus .bStatus = errSTALLEDPKT ;
250250 }
251251
252252 if (dfuAppStatus .bStatus == OK ) {
@@ -271,7 +271,7 @@ void dfuUpdateByReset(void) {
271271 /* do nothing...might be normal usb bus activity */
272272 } else {
273273 /* we reset from the dfu, reset everything and startover,
274- which is the correct operation if this is an erroneous
274+ which is the correct operation if this is an erroneous
275275 event or properly following a MANIFEST */
276276 dfuAppStatus .bState = dfuIDLE ;
277277 dfuAppStatus .bStatus = OK ;
0 commit comments