2828 *
2929 */
3030
31- #include <FreeRTOS.h>
32- #include "task.h"
31+ // #include <FreeRTOS.h>
32+ // #include "task.h"
3333
3434#include <common/init.h>
3535#include <lib/printk.h>
@@ -120,13 +120,16 @@ void __not_in_flash_func(flash_write_enable)()
120120void __not_in_flash_func (flash_wait_done )()
121121{
122122 uint8_t status ;
123+ uint32_t timeout = 200 ; /* 200ms */
123124 do {
124125 cs_select (FLASH_CS_PIN );
125126 uint8_t buf [2 ] = {FLASH_CMD_STATUS , 0 };
126127 spi_write_read_blocking (FLASH_SPI_IFCE , buf , buf , 2 );
127128 cs_deselect (FLASH_CS_PIN );
128129 status = buf [1 ];
129- } while (status & FLASH_STATUS_BUSY_MASK );
130+ if (timeout -- > 0 )
131+ sleep_ms (1 );
132+ } while (timeout && (status & FLASH_STATUS_BUSY_MASK ));
130133}
131134
132135// static void flash_transfer(uint8_t *src, uint8_t *dst, int size, uint8_t cs_pin)
@@ -243,6 +246,7 @@ const struct spi_nor_controller_ops rpi_spi_controller_ops = {
243246
244247static SUBSYS_INITCALL (rpi_spi_init )
245248{
249+ printk ("%s, initializing rpi spi nor interface ...\n" , __func__ );
246250 /* HAL init */
247251 spi_init (FLASH_SPI_IFCE , 12000000 );
248252 gpio_set_function (FLASH_SCK_PIN , GPIO_FUNC_SPI );
@@ -305,21 +309,21 @@ static SUBSYS_INITCALL(rpi_spi_init)
305309// register_nor_controller_ops(&rpi_spi_controller_ops);
306310// }
307311
308- void winbond_flash_test ()
309- {
310- /* match device */
311- // winbond_flash_read_id();
312- rpi_spi_erase (NULL , 0 );
313- vTaskDelay (150 );
314-
315- u8 test_data [1 ] = {0x59 };
316- u8 read_buf [1 ];
317- /* write a byte to address */
318- rpi_spi_write (NULL , 0x10 , 1 , test_data );
319-
320- vTaskDelay (20 );
321-
322- // /* read a byte from address */
323- rpi_spi_read (NULL , 0x10 , 1 , read_buf );
324- printf ("read : 0x%02x\n" , read_buf [0 ]);
325- }
312+ // void winbond_flash_test()
313+ // {
314+ // /* match device */
315+ // // winbond_flash_read_id();
316+ // rpi_spi_erase(NULL, 0);
317+ // vTaskDelay(150);
318+
319+ // u8 test_data[1] = {0x59};
320+ // u8 read_buf[1];
321+ // /* write a byte to address */
322+ // rpi_spi_write(NULL, 0x10, 1, test_data);
323+
324+ // vTaskDelay(20);
325+
326+ // // /* read a byte from address */
327+ // rpi_spi_read(NULL, 0x10, 1, read_buf);
328+ // printf("read : 0x%02x\n", read_buf[0]);
329+ // }
0 commit comments