Set all CDC and MassStorage device mode demos (LowLevel and ClassDriver) to use the...
[pub/USBasp.git] / Demos / Device / ClassDriver / MassStorage / Lib / DataflashManager.c
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Functions to manage the physical dataflash media, including reading and writing of
34 * blocks of data. These functions are called by the SCSI layer when data must be stored
35 * or retrieved to/from the physical storage media. If a different media is used (such
36 * as a SD card or EEPROM), functions similar to these will need to be generated.
37 */
38
39 #define INCLUDE_FROM_DATAFLASHMANAGER_C
40 #include "DataflashManager.h"
41
42 /** Writes blocks (OS blocks, not Dataflash pages) to the storage medium, the board dataflash IC(s), from
43 * the pre-selected data OUT endpoint. This routine reads in OS sized blocks from the endpoint and writes
44 * them to the dataflash in Dataflash page sized blocks.
45 *
46 * \param[in] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
47 * \param[in] BlockAddress Data block starting address for the write sequence
48 * \param[in] TotalBlocks Number of blocks of data to write
49 */
50 void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
51 {
52 uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
53 uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
54 uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
55 bool UsingSecondBuffer = false;
56
57 /* Select the correct starting Dataflash IC for the block requested */
58 Dataflash_SelectChipFromPage(CurrDFPage);
59
60 #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
61 /* Copy selected dataflash's current page contents to the dataflash buffer */
62 Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1);
63 Dataflash_SendAddressBytes(CurrDFPage, 0);
64 Dataflash_WaitWhileBusy();
65 #endif
66
67 /* Send the dataflash buffer write command */
68 Dataflash_SendByte(DF_CMD_BUFF1WRITE);
69 Dataflash_SendAddressBytes(0, CurrDFPageByte);
70
71 /* Wait until endpoint is ready before continuing */
72 while (!(Endpoint_IsReadWriteAllowed()))
73 {
74 if (USB_DeviceState == DEVICE_STATE_Unattached)
75 return;
76 }
77
78 while (TotalBlocks)
79 {
80 uint8_t BytesInBlockDiv16 = 0;
81
82 /* Write an endpoint packet sized data block to the dataflash */
83 while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
84 {
85 /* Check if the endpoint is currently empty */
86 if (!(Endpoint_IsReadWriteAllowed()))
87 {
88 /* Clear the current endpoint bank */
89 Endpoint_ClearOUT();
90
91 /* Wait until the host has sent another packet */
92 while (!(Endpoint_IsReadWriteAllowed()))
93 {
94 if (USB_DeviceState == DEVICE_STATE_Unattached)
95 return;
96 }
97 }
98
99 /* Check if end of dataflash page reached */
100 if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
101 {
102 /* Write the dataflash buffer contents back to the dataflash page */
103 Dataflash_WaitWhileBusy();
104 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2TOMAINMEMWITHERASE : DF_CMD_BUFF1TOMAINMEMWITHERASE);
105 Dataflash_SendAddressBytes(CurrDFPage, 0);
106
107 /* Reset the dataflash buffer counter, increment the page counter */
108 CurrDFPageByteDiv16 = 0;
109 CurrDFPage++;
110
111 /* Once all the dataflash ICs have had their first buffers filled, switch buffers to maintain throughput */
112 if (Dataflash_GetSelectedChip() == DATAFLASH_CHIP_MASK(DATAFLASH_TOTALCHIPS))
113 UsingSecondBuffer = !(UsingSecondBuffer);
114
115 /* Select the next dataflash chip based on the new dataflash page index */
116 Dataflash_SelectChipFromPage(CurrDFPage);
117
118 #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
119 /* If less than one dataflash page remaining, copy over the existing page to preserve trailing data */
120 if ((TotalBlocks * (VIRTUAL_MEMORY_BLOCK_SIZE >> 4)) < (DATAFLASH_PAGE_SIZE >> 4))
121 {
122 /* Copy selected dataflash's current page contents to the dataflash buffer */
123 Dataflash_WaitWhileBusy();
124 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_MAINMEMTOBUFF2 : DF_CMD_MAINMEMTOBUFF1);
125 Dataflash_SendAddressBytes(CurrDFPage, 0);
126 Dataflash_WaitWhileBusy();
127 }
128 #endif
129
130 /* Send the dataflash buffer write command */
131 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
132 Dataflash_SendAddressBytes(0, 0);
133 }
134
135 /* Write one 16-byte chunk of data to the dataflash */
136 Dataflash_SendByte(Endpoint_Read_Byte());
137 Dataflash_SendByte(Endpoint_Read_Byte());
138 Dataflash_SendByte(Endpoint_Read_Byte());
139 Dataflash_SendByte(Endpoint_Read_Byte());
140 Dataflash_SendByte(Endpoint_Read_Byte());
141 Dataflash_SendByte(Endpoint_Read_Byte());
142 Dataflash_SendByte(Endpoint_Read_Byte());
143 Dataflash_SendByte(Endpoint_Read_Byte());
144 Dataflash_SendByte(Endpoint_Read_Byte());
145 Dataflash_SendByte(Endpoint_Read_Byte());
146 Dataflash_SendByte(Endpoint_Read_Byte());
147 Dataflash_SendByte(Endpoint_Read_Byte());
148 Dataflash_SendByte(Endpoint_Read_Byte());
149 Dataflash_SendByte(Endpoint_Read_Byte());
150 Dataflash_SendByte(Endpoint_Read_Byte());
151 Dataflash_SendByte(Endpoint_Read_Byte());
152
153 /* Increment the dataflash page 16 byte block counter */
154 CurrDFPageByteDiv16++;
155
156 /* Increment the block 16 byte block counter */
157 BytesInBlockDiv16++;
158
159 /* Check if the current command is being aborted by the host */
160 if (MSInterfaceInfo->State.IsMassStoreReset)
161 return;
162 }
163
164 /* Decrement the blocks remaining counter and reset the sub block counter */
165 TotalBlocks--;
166 }
167
168 /* Write the dataflash buffer contents back to the dataflash page */
169 Dataflash_WaitWhileBusy();
170 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2TOMAINMEMWITHERASE : DF_CMD_BUFF1TOMAINMEMWITHERASE);
171 Dataflash_SendAddressBytes(CurrDFPage, 0x00);
172 Dataflash_WaitWhileBusy();
173
174 /* If the endpoint is empty, clear it ready for the next packet from the host */
175 if (!(Endpoint_IsReadWriteAllowed()))
176 Endpoint_ClearOUT();
177
178 /* Deselect all dataflash chips */
179 Dataflash_DeselectChip();
180 }
181
182 /** Reads blocks (OS blocks, not Dataflash pages) from the storage medium, the board dataflash IC(s), into
183 * the pre-selected data IN endpoint. This routine reads in Dataflash page sized blocks from the Dataflash
184 * and writes them in OS sized blocks to the endpoint.
185 *
186 * \param[in] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
187 * \param[in] BlockAddress Data block starting address for the read sequence
188 * \param[in] TotalBlocks Number of blocks of data to read
189 */
190 void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
191 {
192 uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
193 uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
194 uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
195
196 /* Select the correct starting Dataflash IC for the block requested */
197 Dataflash_SelectChipFromPage(CurrDFPage);
198
199 /* Send the dataflash main memory page read command */
200 Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
201 Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte);
202 Dataflash_SendByte(0x00);
203 Dataflash_SendByte(0x00);
204 Dataflash_SendByte(0x00);
205 Dataflash_SendByte(0x00);
206
207 /* Wait until endpoint is ready before continuing */
208 while (!(Endpoint_IsReadWriteAllowed()))
209 {
210 if (USB_DeviceState == DEVICE_STATE_Unattached)
211 return;
212 }
213
214 while (TotalBlocks)
215 {
216 uint8_t BytesInBlockDiv16 = 0;
217
218 /* Write an endpoint packet sized data block to the dataflash */
219 while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
220 {
221 /* Check if the endpoint is currently full */
222 if (!(Endpoint_IsReadWriteAllowed()))
223 {
224 /* Clear the endpoint bank to send its contents to the host */
225 Endpoint_ClearIN();
226
227 /* Wait until the endpoint is ready for more data */
228 while (!(Endpoint_IsReadWriteAllowed()))
229 {
230 if (USB_DeviceState == DEVICE_STATE_Unattached)
231 return;
232 }
233 }
234
235 /* Check if end of dataflash page reached */
236 if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
237 {
238 /* Reset the dataflash buffer counter, increment the page counter */
239 CurrDFPageByteDiv16 = 0;
240 CurrDFPage++;
241
242 /* Select the next dataflash chip based on the new dataflash page index */
243 Dataflash_SelectChipFromPage(CurrDFPage);
244
245 /* Send the dataflash main memory page read command */
246 Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
247 Dataflash_SendAddressBytes(CurrDFPage, 0);
248 Dataflash_SendByte(0x00);
249 Dataflash_SendByte(0x00);
250 Dataflash_SendByte(0x00);
251 Dataflash_SendByte(0x00);
252 }
253
254 /* Read one 16-byte chunk of data from the dataflash */
255 Endpoint_Write_Byte(Dataflash_ReceiveByte());
256 Endpoint_Write_Byte(Dataflash_ReceiveByte());
257 Endpoint_Write_Byte(Dataflash_ReceiveByte());
258 Endpoint_Write_Byte(Dataflash_ReceiveByte());
259 Endpoint_Write_Byte(Dataflash_ReceiveByte());
260 Endpoint_Write_Byte(Dataflash_ReceiveByte());
261 Endpoint_Write_Byte(Dataflash_ReceiveByte());
262 Endpoint_Write_Byte(Dataflash_ReceiveByte());
263 Endpoint_Write_Byte(Dataflash_ReceiveByte());
264 Endpoint_Write_Byte(Dataflash_ReceiveByte());
265 Endpoint_Write_Byte(Dataflash_ReceiveByte());
266 Endpoint_Write_Byte(Dataflash_ReceiveByte());
267 Endpoint_Write_Byte(Dataflash_ReceiveByte());
268 Endpoint_Write_Byte(Dataflash_ReceiveByte());
269 Endpoint_Write_Byte(Dataflash_ReceiveByte());
270 Endpoint_Write_Byte(Dataflash_ReceiveByte());
271
272 /* Increment the dataflash page 16 byte block counter */
273 CurrDFPageByteDiv16++;
274
275 /* Increment the block 16 byte block counter */
276 BytesInBlockDiv16++;
277
278 /* Check if the current command is being aborted by the host */
279 if (MSInterfaceInfo->State.IsMassStoreReset)
280 return;
281 }
282
283 /* Decrement the blocks remaining counter */
284 TotalBlocks--;
285 }
286
287 /* If the endpoint is full, send its contents to the host */
288 if (!(Endpoint_IsReadWriteAllowed()))
289 Endpoint_ClearIN();
290
291 /* Deselect all dataflash chips */
292 Dataflash_DeselectChip();
293 }
294
295 /** Writes blocks (OS blocks, not Dataflash pages) to the storage medium, the board dataflash IC(s), from
296 * the a given RAM buffer. This routine reads in OS sized blocks from the buffer and writes them to the
297 * dataflash in Dataflash page sized blocks. This can be linked to FAT libraries to write files to the
298 * dataflash.
299 *
300 * \param[in] BlockAddress Data block starting address for the write sequence
301 * \param[in] TotalBlocks Number of blocks of data to write
302 * \param[in] BufferPtr Pointer to the data source RAM buffer
303 */
304 void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t TotalBlocks, uint8_t* BufferPtr)
305 {
306 uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
307 uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
308 uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
309 bool UsingSecondBuffer = false;
310
311 /* Select the correct starting Dataflash IC for the block requested */
312 Dataflash_SelectChipFromPage(CurrDFPage);
313
314 #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
315 /* Copy selected dataflash's current page contents to the dataflash buffer */
316 Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1);
317 Dataflash_SendAddressBytes(CurrDFPage, 0);
318 Dataflash_WaitWhileBusy();
319 #endif
320
321 /* Send the dataflash buffer write command */
322 Dataflash_SendByte(DF_CMD_BUFF1WRITE);
323 Dataflash_SendAddressBytes(0, CurrDFPageByte);
324
325 while (TotalBlocks)
326 {
327 uint8_t BytesInBlockDiv16 = 0;
328
329 /* Write an endpoint packet sized data block to the dataflash */
330 while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
331 {
332 /* Check if end of dataflash page reached */
333 if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
334 {
335 /* Write the dataflash buffer contents back to the dataflash page */
336 Dataflash_WaitWhileBusy();
337 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2TOMAINMEMWITHERASE : DF_CMD_BUFF1TOMAINMEMWITHERASE);
338 Dataflash_SendAddressBytes(CurrDFPage, 0);
339
340 /* Reset the dataflash buffer counter, increment the page counter */
341 CurrDFPageByteDiv16 = 0;
342 CurrDFPage++;
343
344 /* Once all the dataflash ICs have had their first buffers filled, switch buffers to maintain throughput */
345 if (Dataflash_GetSelectedChip() == DATAFLASH_CHIP_MASK(DATAFLASH_TOTALCHIPS))
346 UsingSecondBuffer = !(UsingSecondBuffer);
347
348 /* Select the next dataflash chip based on the new dataflash page index */
349 Dataflash_SelectChipFromPage(CurrDFPage);
350
351 #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
352 /* If less than one dataflash page remaining, copy over the existing page to preserve trailing data */
353 if ((TotalBlocks * (VIRTUAL_MEMORY_BLOCK_SIZE >> 4)) < (DATAFLASH_PAGE_SIZE >> 4))
354 {
355 /* Copy selected dataflash's current page contents to the dataflash buffer */
356 Dataflash_WaitWhileBusy();
357 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_MAINMEMTOBUFF2 : DF_CMD_MAINMEMTOBUFF1);
358 Dataflash_SendAddressBytes(CurrDFPage, 0);
359 Dataflash_WaitWhileBusy();
360 }
361 #endif
362
363 /* Send the dataflash buffer write command */
364 Dataflash_ToggleSelectedChipCS();
365 Dataflash_SendByte(DF_CMD_BUFF1WRITE);
366 Dataflash_SendAddressBytes(0, 0);
367 }
368
369 /* Write one 16-byte chunk of data to the dataflash */
370 for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
371 Dataflash_SendByte(*(BufferPtr++));
372
373 /* Increment the dataflash page 16 byte block counter */
374 CurrDFPageByteDiv16++;
375
376 /* Increment the block 16 byte block counter */
377 BytesInBlockDiv16++;
378 }
379
380 /* Decrement the blocks remaining counter and reset the sub block counter */
381 TotalBlocks--;
382 }
383
384 /* Write the dataflash buffer contents back to the dataflash page */
385 Dataflash_WaitWhileBusy();
386 Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2TOMAINMEMWITHERASE : DF_CMD_BUFF1TOMAINMEMWITHERASE);
387 Dataflash_SendAddressBytes(CurrDFPage, 0x00);
388 Dataflash_WaitWhileBusy();
389
390 /* Deselect all dataflash chips */
391 Dataflash_DeselectChip();
392 }
393
394 /** Reads blocks (OS blocks, not Dataflash pages) from the storage medium, the board dataflash IC(s), into
395 * the a preallocated RAM buffer. This routine reads in Dataflash page sized blocks from the Dataflash
396 * and writes them in OS sized blocks to the given buffer. This can be linked to FAT libraries to read
397 * the files stored on the dataflash.
398 *
399 * \param[in] BlockAddress Data block starting address for the read sequence
400 * \param[in] TotalBlocks Number of blocks of data to read
401 * \param[out] BufferPtr Pointer to the data destination RAM buffer
402 */
403 void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t TotalBlocks, uint8_t* BufferPtr)
404 {
405 uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
406 uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
407 uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
408
409 /* Select the correct starting Dataflash IC for the block requested */
410 Dataflash_SelectChipFromPage(CurrDFPage);
411
412 /* Send the dataflash main memory page read command */
413 Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
414 Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte);
415 Dataflash_SendByte(0x00);
416 Dataflash_SendByte(0x00);
417 Dataflash_SendByte(0x00);
418 Dataflash_SendByte(0x00);
419
420 while (TotalBlocks)
421 {
422 uint8_t BytesInBlockDiv16 = 0;
423
424 /* Write an endpoint packet sized data block to the dataflash */
425 while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
426 {
427 /* Check if end of dataflash page reached */
428 if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
429 {
430 /* Reset the dataflash buffer counter, increment the page counter */
431 CurrDFPageByteDiv16 = 0;
432 CurrDFPage++;
433
434 /* Select the next dataflash chip based on the new dataflash page index */
435 Dataflash_SelectChipFromPage(CurrDFPage);
436
437 /* Send the dataflash main memory page read command */
438 Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
439 Dataflash_SendAddressBytes(CurrDFPage, 0);
440 Dataflash_SendByte(0x00);
441 Dataflash_SendByte(0x00);
442 Dataflash_SendByte(0x00);
443 Dataflash_SendByte(0x00);
444 }
445
446 /* Read one 16-byte chunk of data from the dataflash */
447 for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
448 *(BufferPtr++) = Dataflash_ReceiveByte();
449
450 /* Increment the dataflash page 16 byte block counter */
451 CurrDFPageByteDiv16++;
452
453 /* Increment the block 16 byte block counter */
454 BytesInBlockDiv16++;
455 }
456
457 /* Decrement the blocks remaining counter */
458 TotalBlocks--;
459 }
460
461 /* Deselect all dataflash chips */
462 Dataflash_DeselectChip();
463 }
464
465 /** Disables the dataflash memory write protection bits on the board Dataflash ICs, if enabled. */
466 void DataflashManager_ResetDataflashProtections(void)
467 {
468 /* Select first dataflash chip, send the read status register command */
469 Dataflash_SelectChip(DATAFLASH_CHIP1);
470 Dataflash_SendByte(DF_CMD_GETSTATUS);
471
472 /* Check if sector protection is enabled */
473 if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
474 {
475 Dataflash_ToggleSelectedChipCS();
476
477 /* Send the commands to disable sector protection */
478 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[0]);
479 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[1]);
480 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
481 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
482 }
483
484 /* Select second dataflash chip (if present on selected board), send read status register command */
485 #if (DATAFLASH_TOTALCHIPS == 2)
486 Dataflash_SelectChip(DATAFLASH_CHIP2);
487 Dataflash_SendByte(DF_CMD_GETSTATUS);
488
489 /* Check if sector protection is enabled */
490 if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
491 {
492 Dataflash_ToggleSelectedChipCS();
493
494 /* Send the commands to disable sector protection */
495 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[0]);
496 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[1]);
497 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
498 Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
499 }
500 #endif
501
502 /* Deselect current dataflash chip */
503 Dataflash_DeselectChip();
504 }