From e2f795067acede0b93de8f7f27edb6aaa76eda57 Mon Sep 17 00:00:00 2001 From: Jerzy Kasenberg Date: Tue, 11 May 2021 08:53:33 +0200 Subject: [PATCH 1/2] Allow build for NRF5340 MCU Errata code referred to NRF_USBD_BASE. This definition is not present in NRF5340 but both NRF52 and NRF53 do have NRF_USBD which maps to NRF_USBD_BASE for NRF52 and to NRF_USBD_S_BASE for NRF5340. This just make build possible for NRF5340. --- src/portable/nordic/nrf5x/dcd_nrf5x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 6b8095a0..3bb9bd37 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -924,8 +924,8 @@ void tusb_hal_nrf_power_event (uint32_t event) if ( nrfx_usbd_errata_166() ) { - *((volatile uint32_t *) (NRF_USBD_BASE + 0x800)) = 0x7E3; - *((volatile uint32_t *) (NRF_USBD_BASE + 0x804)) = 0x40; + *((volatile uint32_t *) ((uint8_t *) (NRF_USBD) + 0x800)) = 0x7E3; + *((volatile uint32_t *) ((uint8_t *) (NRF_USBD) + 0x804)) = 0x40; __ISB(); __DSB(); } From 9233269a2c97c9ca980276a288b1b225cb4d3825 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 11 May 2021 18:38:23 +0700 Subject: [PATCH 2/2] only apply errata walkaround for nrf52 --- src/portable/nordic/nrf5x/dcd_nrf5x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 3bb9bd37..977ec6cd 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -833,9 +833,8 @@ void tusb_hal_nrf_power_event (uint32_t event) NRF_USBD->EVENTCAUSE = USBD_EVENTCAUSE_READY_Msk; __ISB(); __DSB(); // for sync - /* Enable the peripheral */ +#ifdef NRF52_SERIES // ERRATA 171, 187, 166 - if ( nrfx_usbd_errata_187() ) { // CRITICAL_REGION_ENTER(); @@ -867,7 +866,9 @@ void tusb_hal_nrf_power_event (uint32_t event) } // CRITICAL_REGION_EXIT(); } +#endif + /* Enable the peripheral */ NRF_USBD->ENABLE = 1; __ISB(); __DSB(); // for sync @@ -889,6 +890,7 @@ void tusb_hal_nrf_power_event (uint32_t event) NRF_USBD->EVENTCAUSE = USBD_EVENTCAUSE_READY_Msk; __ISB(); __DSB(); // for sync +#ifdef NRF52_SERIES if ( nrfx_usbd_errata_171() ) { // CRITICAL_REGION_ENTER(); @@ -924,11 +926,12 @@ void tusb_hal_nrf_power_event (uint32_t event) if ( nrfx_usbd_errata_166() ) { - *((volatile uint32_t *) ((uint8_t *) (NRF_USBD) + 0x800)) = 0x7E3; - *((volatile uint32_t *) ((uint8_t *) (NRF_USBD) + 0x804)) = 0x40; + *((volatile uint32_t *) (NRF_USBD_BASE + 0x800)) = 0x7E3; + *((volatile uint32_t *) (NRF_USBD_BASE + 0x804)) = 0x40; __ISB(); __DSB(); } +#endif // ISO buffer Lower half for IN, upper half for OUT NRF_USBD->ISOSPLIT = USBD_ISOSPLIT_SPLIT_HalfIN;