@@ -66,14 +66,14 @@ enum spif_default_instructions {
6666 SPIF_PP = 0x02 , // Page Program data
6767 SPIF_READ = 0x03 , // Read data
6868 SPIF_SE = 0x20 , // 4KB Sector Erase
69- SPIF_SFDP = 0x5a , // Read SFDP
69+ SPIF_SFDP = 0x5A , // Read SFDP
7070 SPIF_WRSR = 0x01 , // Write Status/Configuration Register
7171 SPIF_WRDI = 0x04 , // Write Disable
7272 SPIF_RDSR = 0x05 , // Read Status Register
7373 SPIF_WREN = 0x06 , // Write Enable
7474 SPIF_RSTEN = 0x66 , // Reset Enable
7575 SPIF_RST = 0x99 , // Reset
76- SPIF_RDID = 0x9f , // Read Manufacturer and JDEC Device ID
76+ SPIF_RDID = 0x9F , // Read Manufacturer and JDEC Device ID
7777 SPIF_ULBPR = 0x98 , // Clears all write-protection bits in the Block-Protection register,
7878 SPIF_4BEN = 0xB7 , // Enable 4-byte address mode
7979 SPIF_4BDIS = 0xE9 , // Disable 4-byte address mode
@@ -91,7 +91,6 @@ SPIFBlockDevice::SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinNa
9191 _spi(mosi, miso, sclk, csel, use_gpio_ssel), _prog_instruction(0 ), _erase_instruction(0 ),
9292 _page_size_bytes(0 ), _init_ref_count(0 ), _is_initialized(false )
9393{
94- _address_size = SPIF_ADDR_SIZE_3_BYTES;
9594 // Initial SFDP read tables are read with 8 dummy cycles
9695 // Default Bus Setup 1_1_1 with 0 dummy and mode cycles
9796 _read_dummy_and_mode_cycles = 8 ;
@@ -128,6 +127,8 @@ int SPIFBlockDevice::init()
128127 goto exit_point;
129128 }
130129
130+ _address_size = SPIF_ADDR_SIZE_3_BYTES; // Set to 3-bytes since SFDP always use only A23 ~ A0
131+
131132 // Soft Reset
132133 if (-1 == _reset_flash_mem ()) {
133134 tr_error (" init - Unable to initialize flash memory, tests failed" );
@@ -143,7 +144,7 @@ int SPIFBlockDevice::init()
143144 goto exit_point;
144145 }
145146
146- // Synchronize Device
147+ // Synchronize Device
147148 if (false == _is_mem_ready ()) {
148149 tr_error (" init - _is_mem_ready Failed" );
149150 status = SPIF_BD_ERROR_READY_FAILED;
@@ -650,7 +651,7 @@ int SPIFBlockDevice::_reset_flash_mem()
650651 int status = 0 ;
651652 char status_value[2 ] = {0 };
652653 tr_info (" _reset_flash_mem:" );
653- // Read the Status Register from device
654+ // Read the Status Register from device
654655 if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL , 0 , status_value, 1 )) {
655656 // store received values in status_value
656657 tr_debug (" Reading Status Register Success: value = 0x%x" , (int )status_value[0 ]);
@@ -660,7 +661,7 @@ int SPIFBlockDevice::_reset_flash_mem()
660661 }
661662
662663 if (0 == status) {
663- // Send Reset Enable
664+ // Send Reset Enable
664665 if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RSTEN, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
665666 // store received values in status_value
666667 tr_debug (" Sending RSTEN Success" );
@@ -670,7 +671,7 @@ int SPIFBlockDevice::_reset_flash_mem()
670671 }
671672
672673 if (0 == status) {
673- // Send Reset
674+ // Send Reset
674675 if (SPIF_BD_ERROR_OK == _spi_send_general_command (SPIF_RST, SPI_NO_ADDRESS_COMMAND, NULL , 0 , NULL , 0 )) {
675676 // store received values in status_value
676677 tr_debug (" Sending RST Success" );
@@ -698,7 +699,7 @@ bool SPIFBlockDevice::_is_mem_ready()
698699 do {
699700 rtos::ThisThread::sleep_for (1ms);
700701 retries++;
701- // Read the Status Register from device
702+ // Read the Status Register from device
702703 if (SPIF_BD_ERROR_OK != _spi_send_general_command (SPIF_RDSR, SPI_NO_ADDRESS_COMMAND, NULL , 0 , status_value,
703704 1 )) { // store received values in status_value
704705 tr_error (" Reading Status Register failed" );
@@ -750,7 +751,7 @@ int SPIFBlockDevice::_handle_vendor_quirks()
750751 uint8_t vendor_device_ids[4 ];
751752 size_t data_length = 3 ;
752753
753- /* Read Manufacturer ID (1byte), and Device ID (2bytes)*/
754+ // Read Manufacturer ID (1byte), and Device ID (2bytes)
754755 spif_bd_error spi_status = _spi_send_general_command (SPIF_RDID, SPI_NO_ADDRESS_COMMAND, NULL , 0 ,
755756 (char *)vendor_device_ids,
756757 data_length);
@@ -763,7 +764,7 @@ int SPIFBlockDevice::_handle_vendor_quirks()
763764 tr_debug (" Vendor device ID = 0x%x 0x%x 0x%x" , vendor_device_ids[0 ], vendor_device_ids[1 ], vendor_device_ids[2 ]);
764765
765766 switch (vendor_device_ids[0 ]) {
766- case 0xbf :
767+ case 0xBF :
767768 // SST devices come preset with block protection
768769 // enabled for some regions, issue global protection unlock to clear
769770 _set_write_enable ();
0 commit comments