clean up, update nrfx to 1.3.0

This commit is contained in:
hathach 2018-09-25 12:57:46 +07:00
parent 3b79ba8451
commit a660fb0cfc
7 changed files with 35 additions and 15 deletions

View File

@ -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>

View File

@ -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" />

View File

@ -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

View File

@ -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

@ -1 +1 @@
Subproject commit 096e770ee41e5ad92a2137aa6502cb04d5745e5c
Subproject commit 67710e47c7313cc56a15748e485079831ee6a3af

View File

@ -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)
//------------------------------------------------------------------------------

View File

@ -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 |