@@ -61,6 +61,7 @@ enum opcode {
61
61
DATAFLASH_OP_PROGRAM_DIRECT = 0x02 , // Program through Buffer 1 without Built-In Erase
62
62
DATAFLASH_OP_PROGRAM_DIRECT_WITH_ERASE = 0x82 ,
63
63
DATAFLASH_OP_ERASE_BLOCK = 0x50 ,
64
+ DATAFLASH_OP_ERASE_PAGE = 0x81 ,
64
65
};
65
66
66
67
/* non-exhaustive command list */
@@ -447,17 +448,17 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size)
447
448
/* disable write protection */
448
449
_write_enable (true );
449
450
450
- /* erase one block at a time until the full size has been erased */
451
+ /* erase one page at a time until the full size has been erased */
451
452
uint32_t erased = 0 ;
452
453
while (erased < size) {
453
454
454
- /* set block erase opcode */
455
- uint32_t command = DATAFLASH_OP_ERASE_BLOCK ;
455
+ /* set page erase opcode */
456
+ uint32_t command = DATAFLASH_OP_ERASE_PAGE ;
456
457
457
458
/* translate address */
458
459
uint32_t address = _translate_address (addr);
459
460
460
- /* set block address */
461
+ /* set page address */
461
462
command = (command << 8 ) | ((address >> 16 ) & 0xFF );
462
463
command = (command << 8 ) | ((address >> 8 ) & 0xFF );
463
464
command = (command << 8 ) | (address & 0xFF );
@@ -474,8 +475,8 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size)
474
475
}
475
476
476
477
/* update loop variables */
477
- addr += _block_size ;
478
- erased += _block_size ;
478
+ addr += _page_size ;
479
+ erased += _page_size ;
479
480
}
480
481
481
482
/* enable write protection */
@@ -503,17 +504,17 @@ bd_size_t DataFlashBlockDevice::get_program_size() const
503
504
bd_size_t DataFlashBlockDevice::get_erase_size () const
504
505
{
505
506
_mutex.lock ();
506
- DEBUG_PRINTF (" erase size: %" PRIX16 " \r\n " , _block_size );
507
- bd_size_t block_size = _block_size ;
507
+ DEBUG_PRINTF (" erase size: %" PRIX16 " \r\n " , _page_size );
508
+ bd_size_t block_size = _page_size ;
508
509
_mutex.unlock ();
509
510
return block_size;
510
511
}
511
512
512
513
bd_size_t DataFlashBlockDevice::get_erase_size (bd_addr_t addr) const
513
514
{
514
515
_mutex.lock ();
515
- DEBUG_PRINTF (" erase size: %" PRIX16 " \r\n " , _block_size );
516
- bd_size_t block_size = _block_size ;
516
+ DEBUG_PRINTF (" erase size: %" PRIX16 " \r\n " , _page_size );
517
+ bd_size_t block_size = _page_size ;
517
518
_mutex.unlock ();
518
519
return block_size;
519
520
}
0 commit comments