@@ -60,8 +60,8 @@ bool spi_flash_read_command(uint8_t command, uint8_t* response, uint32_t length)
6060 .wipwait = false,
6161 .wren = false
6262 };
63- nrfx_qspi_cinstr_xfer (& cinstr_cfg , NULL , response );
64- return true;
63+ return nrfx_qspi_cinstr_xfer (& cinstr_cfg , NULL , response ) == NRFX_SUCCESS ;
64+
6565}
6666
6767bool spi_flash_write_command (uint8_t command , uint8_t * data , uint32_t length ) {
@@ -73,8 +73,7 @@ bool spi_flash_write_command(uint8_t command, uint8_t* data, uint32_t length) {
7373 .wipwait = false,
7474 .wren = false // We do this manually.
7575 };
76- nrfx_qspi_cinstr_xfer (& cinstr_cfg , data , NULL );
77- return true;
76+ return nrfx_qspi_cinstr_xfer (& cinstr_cfg , data , NULL ) == NRFX_SUCCESS ;
7877}
7978
8079bool spi_flash_sector_command (uint8_t command , uint32_t address ) {
@@ -146,15 +145,14 @@ void spi_flash_init_device(const external_flash_device* device) {
146145 }
147146
148147 // Speed up as much as we can.
149- uint8_t sckfreq = 0 ;
148+ // Start at 16 MHz and go down.
149+ // At 32 MHz GD25Q16C doesn't work reliably on Feather 52840, even though it should work up to 104 MHz.
150+ // sckfreq = 0 is 32 Mhz
151+ // sckfreq = 1 is 16 MHz, etc.
152+ uint8_t sckfreq = 1 ;
150153 while (32000000 / (sckfreq + 1 ) > device -> max_clock_speed_mhz * 1000000 && sckfreq < 16 ) {
151154 sckfreq += 1 ;
152155 }
153- // No more than 16 MHz. At 32 MHz GD25Q16C doesn't work reliably on Feather 52840, even though
154- // it should work up to 104 MHz.
155- // sckfreq = 0 is 32 Mhz
156- // sckfreq = 1 is 16 MHz, etc.
157- sckfreq = MAX (1 , sckfreq );
158156 NRF_QSPI -> IFCONFIG1 &= ~QSPI_IFCONFIG1_SCKFREQ_Msk ;
159157 NRF_QSPI -> IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKFREQ_Pos ;
160158}
0 commit comments