summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-08-30 16:04:18 +0700
committerhathach <[email protected]>2023-08-30 16:04:18 +0700
commit1ab488eb06ef4cb8ad9c0cff91e6b0caf76f73c4 (patch)
treec0716094ba72c4ff47510bb08de779ae3c0786fa /hw
parent2a814a99af32bf084cbb730d97e3c9cb31a3fa85 (diff)
call xfer_complete_isr() when result is not successful (stalled or failed)
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/nrf/boards/pca10095/board.h9
-rw-r--r--hw/bsp/nrf/family.c7
-rw-r--r--hw/bsp/nrf/nrfx_config.h2
3 files changed, 15 insertions, 3 deletions
diff --git a/hw/bsp/nrf/boards/pca10095/board.h b/hw/bsp/nrf/boards/pca10095/board.h
index fd3c63d6a..b9d3a19dc 100644
--- a/hw/bsp/nrf/boards/pca10095/board.h
+++ b/hw/bsp/nrf/boards/pca10095/board.h
@@ -31,6 +31,8 @@
extern "C" {
#endif
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
// LED
#define LED_PIN 28
#define LED_STATE_ON 0
@@ -43,6 +45,13 @@
#define UART_RX_PIN 32
#define UART_TX_PIN 33
+// SPI for USB host shield
+#define MAX3421E_SCK_PIN _PINNUM(1, 15)
+#define MAX3421E_MOSI_PIN _PINNUM(1, 13)
+#define MAX3421E_MISO_PIN _PINNUM(1, 14)
+#define MAX3421E_CS_PIN _PINNUM(1, 12)
+#define MAX3241E_INTR_PIN _PINNUM(1, 11)
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c
index 083efc235..2b4260083 100644
--- a/hw/bsp/nrf/family.c
+++ b/hw/bsp/nrf/family.c
@@ -34,6 +34,7 @@
#pragma GCC diagnostic ignored "-Wcast-align"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wundef"
+#pragma GCC diagnostic ignored "-Wredundant-decls"
#endif
#include "nrfx.h"
@@ -94,7 +95,7 @@ TU_ATTR_UNUSED static void power_event_handler(nrfx_power_usb_evt_t event) {
//------------- Host using MAX2341E -------------//
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
-static nrfx_spim_t _spi = NRFX_SPIM_INSTANCE(0);
+static nrfx_spim_t _spi = NRFX_SPIM_INSTANCE(1);
void max3421e_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if ( !(pin == MAX3241E_INTR_PIN && action == NRF_GPIOTE_POLARITY_HITOLO) ) return;
@@ -222,7 +223,8 @@ void board_init(void) {
#endif
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
- // MAX3421 need 3.3v signal
+ // MAX3421 need 3.3v signal (may not be needed)
+ #if defined(UICR_REGOUT0_VOUT_Msk) && 0
if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != UICR_REGOUT0_VOUT_3V3) {
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
@@ -234,6 +236,7 @@ void board_init(void) {
NVIC_SystemReset();
}
+ #endif
// manually manage CS
nrf_gpio_cfg_output(MAX3421E_CS_PIN);
diff --git a/hw/bsp/nrf/nrfx_config.h b/hw/bsp/nrf/nrfx_config.h
index e3d0ea91b..95ef33ce4 100644
--- a/hw/bsp/nrf/nrfx_config.h
+++ b/hw/bsp/nrf/nrfx_config.h
@@ -11,7 +11,7 @@
#define NRFX_UARTE0_ENABLED 1
#define NRFX_SPIM_ENABLED 1
-#define NRFX_SPIM0_ENABLED 1
+#define NRFX_SPIM1_ENABLED 1 // use SPI1 since nrf5340 share uart with spi
#define NRFX_PRS_ENABLED 0
#define NRFX_USBREG_ENABLED 1