@@ -11,20 +11,34 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi{spi} {
1111}
1212
1313void SpiNorFlash::Init () {
14- auto id = ReadIdentificaion ();
15- NRF_LOG_INFO (" [SPI FLASH] Manufacturer : %d, Memory type : %d, memory density : %d" , id .manufacturer , id .type , id .density );
14+ device_id = ReadIdentificaion ();
15+ NRF_LOG_INFO (" [SPI FLASH] Manufacturer : %d, Memory type : %d, memory density : %d" , device_id .manufacturer , device_id .type , device_id .density );
1616}
1717
1818void SpiNorFlash::Uninit () {
1919
2020}
2121
2222void SpiNorFlash::Sleep () {
23-
23+ auto cmd = static_cast <uint8_t >(Commands::DeepPowerDown);
24+ spi.Write (&cmd, sizeof (uint8_t ));
25+ NRF_LOG_INFO (" [FLASH] Sleep" )
2426}
2527
2628void SpiNorFlash::Wakeup () {
27-
29+ // send Commands::ReleaseFromDeepPowerDown then 3 dummy bytes before reading Device ID
30+ static constexpr uint8_t cmdSize = 4 ;
31+ uint8_t cmd[cmdSize] = {static_cast <uint8_t >(Commands::ReleaseFromDeepPowerDown), 0x01 , 0x02 , 0x03 };
32+ uint8_t id = 0 ;
33+ spi.Read (reinterpret_cast <uint8_t *>(&cmd), cmdSize, &id, 1 );
34+ auto devId = device_id = ReadIdentificaion ();
35+ if (devId.type != device_id.type ) {
36+ NRF_LOG_INFO (" [SpiNorFlash] ID on Wakeup: Failed" );
37+ }
38+ else {
39+ NRF_LOG_INFO (" [SpiNorFlash] ID on Wakeup: %d" , id);
40+ }
41+ NRF_LOG_INFO (" [FLASH] Wakeup" )
2842}
2943
3044SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion () {
0 commit comments