@@ -66,14 +66,14 @@ enum spif_default_instructions {
66
66
SPIF_PP = 0x02 , // Page Program data
67
67
SPIF_READ = 0x03 , // Read data
68
68
SPIF_SE = 0x20 , // 4KB Sector Erase
69
- SPIF_SFDP = 0x5a , // Read SFDP
69
+ SPIF_SFDP = 0x5A , // Read SFDP
70
70
SPIF_WRSR = 0x01 , // Write Status/Configuration Register
71
71
SPIF_WRDI = 0x04 , // Write Disable
72
72
SPIF_RDSR = 0x05 , // Read Status Register
73
73
SPIF_WREN = 0x06 , // Write Enable
74
74
SPIF_RSTEN = 0x66 , // Reset Enable
75
75
SPIF_RST = 0x99 , // Reset
76
- SPIF_RDID = 0x9f , // Read Manufacturer and JDEC Device ID
76
+ SPIF_RDID = 0x9F , // Read Manufacturer and JDEC Device ID
77
77
SPIF_ULBPR = 0x98 , // Clears all write-protection bits in the Block-Protection register,
78
78
SPIF_4BEN = 0xB7 , // Enable 4-byte address mode
79
79
SPIF_4BDIS = 0xE9 , // Disable 4-byte address mode
@@ -91,7 +91,6 @@ SPIFBlockDevice::SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinNa
91
91
_spi(mosi, miso, sclk, csel, use_gpio_ssel), _prog_instruction(0 ), _erase_instruction(0 ),
92
92
_page_size_bytes(0 ), _init_ref_count(0 ), _is_initialized(false )
93
93
{
94
- _address_size = SPIF_ADDR_SIZE_3_BYTES;
95
94
// Initial SFDP read tables are read with 8 dummy cycles
96
95
// Default Bus Setup 1_1_1 with 0 dummy and mode cycles
97
96
_read_dummy_and_mode_cycles = 8 ;
@@ -128,6 +127,8 @@ int SPIFBlockDevice::init()
128
127
goto exit_point;
129
128
}
130
129
130
+ _address_size = SPIF_ADDR_SIZE_3_BYTES; // Set to 3-bytes since SFDP always use only A23 ~ A0
131
+
131
132
// Soft Reset
132
133
if (-1 == _reset_flash_mem ()) {
133
134
tr_error (" init - Unable to initialize flash memory, tests failed" );
@@ -143,7 +144,7 @@ int SPIFBlockDevice::init()
143
144
goto exit_point;
144
145
}
145
146
146
- // Synchronize Device
147
+ // Synchronize Device
147
148
if (false == _is_mem_ready ()) {
148
149
tr_error (" init - _is_mem_ready Failed" );
149
150
status = SPIF_BD_ERROR_READY_FAILED;
@@ -650,7 +651,7 @@ int SPIFBlockDevice::_reset_flash_mem()
650
651
int status = 0 ;
651
652
char status_value[2 ] = {0 };
652
653
tr_info (" _reset_flash_mem:" );
653
- // Read the Status Register from device
654
+ // Read the Status Register from device
654
655
if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL , 0 , status_value, 1 )) {
655
656
// store received values in status_value
656
657
tr_debug (" Reading Status Register Success: value = 0x%x" , (int )status_value[0 ]);
@@ -660,7 +661,7 @@ int SPIFBlockDevice::_reset_flash_mem()
660
661
}
661
662
662
663
if (0 == status) {
663
- // Send Reset Enable
664
+ // Send Reset Enable
664
665
if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RSTEN, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
665
666
// store received values in status_value
666
667
tr_debug (" Sending RSTEN Success" );
@@ -670,7 +671,7 @@ int SPIFBlockDevice::_reset_flash_mem()
670
671
}
671
672
672
673
if (0 == status) {
673
- // Send Reset
674
+ // Send Reset
674
675
if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RST, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
675
676
// store received values in status_value
676
677
tr_debug (" Sending RST Success" );
@@ -698,7 +699,7 @@ bool SPIFBlockDevice::_is_mem_ready()
698
699
do {
699
700
rtos::ThisThread::sleep_for (1ms);
700
701
retries++;
701
- // Read the Status Register from device
702
+ // Read the Status Register from device
702
703
if (SPIF_BD_ERROR_OK != _spi_send_general_command (SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL , 0 , status_value,
703
704
1 )) { // store received values in status_value
704
705
tr_error (" Reading Status Register failed" );
@@ -750,7 +751,7 @@ int SPIFBlockDevice::_handle_vendor_quirks()
750
751
uint8_t vendor_device_ids[4 ];
751
752
size_t data_length = 3 ;
752
753
753
- /* Read Manufacturer ID (1byte), and Device ID (2bytes)*/
754
+ // Read Manufacturer ID (1byte), and Device ID (2bytes)
754
755
spif_bd_error spi_status = _spi_send_general_command (SPIF_RDID, SPI_NO_ADDRESS_COMMAND, NULL , 0 ,
755
756
(char *)vendor_device_ids,
756
757
data_length);
@@ -763,7 +764,7 @@ int SPIFBlockDevice::_handle_vendor_quirks()
763
764
tr_debug (" Vendor device ID = 0x%x 0x%x 0x%x" , vendor_device_ids[0 ], vendor_device_ids[1 ], vendor_device_ids[2 ]);
764
765
765
766
switch (vendor_device_ids[0 ]) {
766
- case 0xbf :
767
+ case 0xBF :
767
768
// SST devices come preset with block protection
768
769
// enabled for some regions, issue global protection unlock to clear
769
770
_set_write_enable ();
0 commit comments