summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-09-25 12:57:46 +0700
committerhathach <[email protected]>2018-09-25 12:57:46 +0700
commita660fb0cfc8641d5645d1cdea76027266b278388 (patch)
tree07ff532813da1a32c0b92a683cb2427325cc930d
parent3b79ba845185893f6ce4b55ac40d529b7798982e (diff)
clean up, update nrfx to 1.3.0
-rw-r--r--examples/device/nrf52840/segger/nrf52840.emProject1
-rw-r--r--examples/device/nrf52840_freertos/segger/nrf5x_freertos.emProject2
-rw-r--r--hw/bsp/pca10056/board_pca10056.c38
-rw-r--r--hw/bsp/pca10056/board_pca10056.h2
m---------hw/mcu/nordic/nrfx0
-rw-r--r--hw/mcu/nordic/nrfx_glue.h3
-rw-r--r--src/portable/nordic/nrf5x/hal_nrf5x.c2
7 files changed, 34 insertions, 14 deletions
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 @@
</folder>
<folder Name="src">
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c" />
- <file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power_clock.c" />
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_qspi.c" />
</folder>
</folder>
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 @@
<folder Name="include" />
<folder Name="src">
<file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c" />
- <file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_power_clock.c" />
+ <file file_name="../../../../hw/mcu/nordic/nrfx/drivers/src/nrfx_qspi.c" />
</folder>
</folder>
<folder Name="hal" />
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
-Subproject 096e770ee41e5ad92a2137aa6502cb04d5745e5
+Subproject 67710e47c7313cc56a15748e485079831ee6a3a
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 <soc/nrfx_coredep.h>
+#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 |