diff --git a/examples/device/nrf52840/segger/nrf52840.emProject b/examples/device/nrf52840/segger/nrf52840.emProject index e9fb8d5f5..8775d1bca 100644 --- a/examples/device/nrf52840/segger/nrf52840.emProject +++ b/examples/device/nrf52840/segger/nrf52840.emProject @@ -82,7 +82,6 @@ - diff --git a/examples/device/nrf52840_freertos/segger/nrf5x_freertos.emProject b/examples/device/nrf52840_freertos/segger/nrf5x_freertos.emProject index dd9edb8dd..ccc1960e4 100644 --- a/examples/device/nrf52840_freertos/segger/nrf5x_freertos.emProject +++ b/examples/device/nrf52840_freertos/segger/nrf5x_freertos.emProject @@ -77,7 +77,7 @@ - + diff --git a/hw/bsp/pca10056/board_pca10056.c b/hw/bsp/pca10056/board_pca10056.c index 74ae961a4..6e80a8eb0 100644 --- a/hw/bsp/pca10056/board_pca10056.c +++ b/hw/bsp/pca10056/board_pca10056.c @@ -38,9 +38,9 @@ #include "bsp/board.h" #include "nrf_gpio.h" - #include "nrfx_power.h" #include "nrfx_qspi.h" +#include "tusb.h" /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM @@ -76,9 +76,12 @@ uint32_t tusb_hal_millis(void) /*------------------------------------------------------------------*/ /* BOARD API *------------------------------------------------------------------*/ -#define QSPI_STD_CMD_RSTEN 0x66 -#define QSPI_STD_CMD_RST 0x99 -#define QSPI_STD_CMD_WRSR 0x01 +enum { + QSPI_CMD_RSTEN = 0x66, + QSPI_CMD_RST = 0x99, + QSPI_CMD_WRSR = 0x01, + QSPI_CMD_READID = 0x90 +}; extern void qspi_flash_complete (void); @@ -147,24 +150,41 @@ void board_init(void) .length = 0, .io2_level = true, .io3_level = true, - .wipwait = true, - .wren = true + .wipwait = false, + .wren = false }; // Send reset enable - cinstr_cfg.opcode = QSPI_STD_CMD_RSTEN; + cinstr_cfg.opcode = QSPI_CMD_RSTEN; cinstr_cfg.length = NRF_QSPI_CINSTR_LEN_1B; nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, NULL); // Send reset command - cinstr_cfg.opcode = QSPI_STD_CMD_RST; + cinstr_cfg.opcode = QSPI_CMD_RST; cinstr_cfg.length = NRF_QSPI_CINSTR_LEN_1B; nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, NULL); + NRFX_DELAY_US(100); // wait for flash reset + + // Send (Read ID + 3 dummy bytes) + Receive 2 bytes of Manufacture + Device ID + uint8_t dummy[6] = { 0 }; + uint8_t id_resp[6] = { 0 }; + cinstr_cfg.opcode = QSPI_CMD_READID; + cinstr_cfg.length = 6; + + // Bug with -nrf_qspi_cinstrdata_get() didn't combine data. + // https://devzone.nordicsemi.com/f/nordic-q-a/38540/bug-nrf_qspi_cinstrdata_get-didn-t-collect-data-from-both-cinstrdat1-and-cinstrdat0 + nrfx_qspi_cinstr_xfer(&cinstr_cfg, dummy, id_resp); + + // Due to the bug, we collect data manually + uint8_t dev_id = (uint8_t) NRF_QSPI->CINSTRDAT1; + uint8_t mfgr_id = (uint8_t) ( NRF_QSPI->CINSTRDAT0 >> 24 ); + // Switch to qspi mode uint8_t sr_quad_en = 0x40; - cinstr_cfg.opcode = QSPI_STD_CMD_WRSR; + cinstr_cfg.opcode = QSPI_CMD_WRSR; cinstr_cfg.length = NRF_QSPI_CINSTR_LEN_2B; + cinstr_cfg.wipwait = cinstr_cfg.wren = true; nrfx_qspi_cinstr_xfer(&cinstr_cfg, &sr_quad_en, NULL); #endif diff --git a/hw/bsp/pca10056/board_pca10056.h b/hw/bsp/pca10056/board_pca10056.h index bb9949f61..d51fae22b 100644 --- a/hw/bsp/pca10056/board_pca10056.h +++ b/hw/bsp/pca10056/board_pca10056.h @@ -49,7 +49,7 @@ // Flash type used for MSC example #define BOARD_MSC_FLASH_QSPI -#define BOARD_MSC_FLASH_SIZE (16*1024*1024) +#define BOARD_MSC_FLASH_SIZE (8*1024*1024) //#define BOARD_MSC_FLASH_RAM // #define BOARD_MSC_FLASH_SIZE (8*1024) // 8KB is the smallest size that windows allow to mount diff --git a/hw/mcu/nordic/nrfx b/hw/mcu/nordic/nrfx index 096e770ee..67710e47c 160000 --- a/hw/mcu/nordic/nrfx +++ b/hw/mcu/nordic/nrfx @@ -1 +1 @@ -Subproject commit 096e770ee41e5ad92a2137aa6502cb04d5745e5c +Subproject commit 67710e47c7313cc56a15748e485079831ee6a3af diff --git a/hw/mcu/nordic/nrfx_glue.h b/hw/mcu/nordic/nrfx_glue.h index 301937366..cdf49b4ab 100644 --- a/hw/mcu/nordic/nrfx_glue.h +++ b/hw/mcu/nordic/nrfx_glue.h @@ -183,7 +183,8 @@ static inline bool _NRFX_IRQ_IS_PENDING(IRQn_Type irq_number) * * @param us_time Number of microseconds to wait. */ -#define NRFX_DELAY_US(us_time) +#include +#define NRFX_DELAY_US(us_time) nrfx_coredep_delay_us(us_time) //------------------------------------------------------------------------------ diff --git a/src/portable/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c index fe33825e9..4ce512746 100644 --- a/src/portable/nordic/nrf5x/hal_nrf5x.c +++ b/src/portable/nordic/nrf5x/hal_nrf5x.c @@ -255,7 +255,7 @@ void tusb_hal_nrf_power_event (uint32_t event) __DSB(); } - nrf_usbd_isosplit_set(NRF_USBD_ISOSPLIT_Half); + nrf_usbd_isosplit_set(USBD_ISOSPLIT_SPLIT_HalfIN); // Enable interrupt. SOF is used as CDC auto flush NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_USBEVENT_Msk | USBD_INTEN_EPDATA_Msk |