update dcd nrf5x to be indepent from nrf_usbd.h

fix build error with nrfx 2.0
This commit is contained in:
hathach 2019-11-11 00:01:12 +07:00
parent 2f19b9c100
commit 4008f0d1e6
3 changed files with 37 additions and 21 deletions

View File

@ -84,10 +84,12 @@ void board_init(void)
.pselcts = NRF_UARTE_PSEL_DISCONNECTED,
.pselrts = NRF_UARTE_PSEL_DISCONNECTED,
.p_context = NULL,
.hwfc = NRF_UARTE_HWFC_DISABLED,
.parity = NRF_UARTE_PARITY_EXCLUDED,
.baudrate = NRF_UARTE_BAUDRATE_115200, // CFG_BOARD_UART_BAUDRATE
.interrupt_priority = 7
.interrupt_priority = 7,
.hal_cfg = {
.hwfc = NRF_UARTE_HWFC_DISABLED,
.parity = NRF_UARTE_PARITY_EXCLUDED,
}
};
nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler);

View File

@ -1,10 +1,18 @@
#ifndef NRFX_CONFIG_H__
#define NRFX_CONFIG_H__
#define NRFX_POWER_ENABLED 1
#define NRFX_POWER_CONFIG_IRQ_PRIORITY 7
#define NRFX_POWER_ENABLED 1
#define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7
#define NRFX_CLOCK_ENABLED 0
#define NRFX_UARTE_ENABLED 1
#define NRFX_UARTE0_ENABLED 1
#define NRFX_UARTE1_ENABLED 0
#define NRFX_UARTE2_ENABLED 0
#define NRFX_UARTE3_ENABLED 0
#define NRFX_PRS_ENABLED 0
#endif // NRFX_CONFIG_H__

View File

@ -31,7 +31,6 @@
#include "nrf.h"
#include "nrf_clock.h"
#include "nrf_power.h"
#include "nrf_usbd.h"
#include "nrfx_usbd_errata.h"
#ifdef SOFTDEVICE_PRESENT
@ -498,7 +497,8 @@ void USBD_IRQHandler(void)
if ( int_status & (USBD_INTEN_EPDATA_Msk | USBD_INTEN_EP0DATADONE_Msk) )
{
uint32_t data_status = NRF_USBD->EPDATASTATUS;
nrf_usbd_epdatastatus_clear(data_status);
NRF_USBD->EPDATASTATUS = data_status;
__ISB(); __DSB();
// EP0DATADONE is set with either Control Out on IN Data
// Since EPDATASTATUS cannot be used to determine whether it is control OUT or IN.
@ -572,7 +572,7 @@ static bool hfclk_running(void)
}
#endif
return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
return nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY);
}
static void hfclk_enable(void)
@ -588,8 +588,8 @@ static void hfclk_enable(void)
}
#endif
nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART);
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART);
}
static void hfclk_disable(void)
@ -602,7 +602,7 @@ static void hfclk_disable(void)
}
#endif
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP);
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
}
// Power & Clock Peripheral on nRF5x to manage USB
@ -630,7 +630,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
if ( !NRF_USBD->ENABLE )
{
/* Prepare for READY event receiving */
nrf_usbd_eventcause_clear(NRF_USBD_EVENTCAUSE_READY_MASK);
NRF_USBD->EVENTCAUSE = USBD_EVENTCAUSE_READY_Msk;
__ISB(); __DSB(); // for sync
/* Enable the peripheral */
// ERRATA 171, 187, 166
@ -667,7 +668,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
// CRITICAL_REGION_EXIT();
}
nrf_usbd_enable();
NRF_USBD->ENABLE = 1;
__ISB(); __DSB(); // for sync
// Enable HFCLK
hfclk_enable();
@ -678,8 +680,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
/* Waiting for USBD peripheral enabled */
while ( !(USBD_EVENTCAUSE_READY_Msk & NRF_USBD->EVENTCAUSE) ) { }
nrf_usbd_eventcause_clear(USBD_EVENTCAUSE_READY_Msk);
nrf_usbd_event_clear(USBD_EVENTCAUSE_READY_Msk);
NRF_USBD->EVENTCAUSE = USBD_EVENTCAUSE_READY_Msk;
__ISB(); __DSB(); // for sync
if ( nrfx_usbd_errata_171() )
{
@ -719,11 +721,11 @@ void tusb_hal_nrf_power_event (uint32_t event)
*((volatile uint32_t *) (NRF_USBD_BASE + 0x800)) = 0x7E3;
*((volatile uint32_t *) (NRF_USBD_BASE + 0x804)) = 0x40;
__ISB();
__DSB();
__ISB(); __DSB();
}
nrf_usbd_isosplit_set(USBD_ISOSPLIT_SPLIT_HalfIN);
// ISO buffer Lower half for IN, upper half for OUT
NRF_USBD->ISOSPLIT = USBD_ISOSPLIT_SPLIT_HalfIN;
// Enable interrupt
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_EPDATA_Msk |
@ -737,7 +739,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
while ( !hfclk_running() ) { }
// Enable pull up
nrf_usbd_pullup_enable();
NRF_USBD->USBPULLUP = 1;
__ISB(); __DSB(); // for sync
break;
case USB_EVT_REMOVED:
@ -746,7 +749,8 @@ void tusb_hal_nrf_power_event (uint32_t event)
// Abort all transfers
// Disable pull up
nrf_usbd_pullup_disable();
NRF_USBD->USBPULLUP = 0;
__ISB(); __DSB(); // for sync
// Disable Interrupt
NVIC_DisableIRQ(USBD_IRQn);
@ -754,7 +758,9 @@ void tusb_hal_nrf_power_event (uint32_t event)
// disable all interrupt
NRF_USBD->INTENCLR = NRF_USBD->INTEN;
nrf_usbd_disable();
NRF_USBD->ENABLE = 0;
__ISB(); __DSB(); // for sync
hfclk_disable();
dcd_event_bus_signal(0, DCD_EVENT_UNPLUGGED, true);