mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
catch all nrfx versions with an old API
This commit is contained in:
parent
2567fe3fd8
commit
c535a4d42b
@ -56,11 +56,25 @@
|
|||||||
#include "mcu/mcu.h"
|
#include "mcu/mcu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1000*MDK_MAJOR_VERSION + MDK_MINOR_VERSION <= 8040
|
// Unfortunately there are API differences between nrfx<2.0.0 and nrfx>=2.0.0
|
||||||
// Nordic actually has generated a mess here: nrfx==1.9.0 has MDK 8.40.3 while nrfx==2.0.0 has MDK 8.29.0
|
// Nordic actually has generated a mess here: nrfx==1.9.0 has MDK 8.40.3 while nrfx==2.0.0 has MDK 8.29.0.
|
||||||
// Unfortunately there are API differences between nrfx<2.0.0 and nrfx>=2.0.0. Hoping that everyone uses
|
// See the below statement to catch all nrfx versions with an old API.
|
||||||
// nRF Connect SDK keeps the libraries up to date.
|
#define _MDK_VERSION 10000*MDK_MAJOR_VERSION + 100*MDK_MINOR_VERSION + MDK_MICRO_VERSION
|
||||||
#define OLD_NORDIC_SDK
|
#if _MDK_VERSION <= 82701
|
||||||
|
// nrfx <= 1.8.1
|
||||||
|
#define NORDIC_SDK_OLD_API
|
||||||
|
#elif _MDK_VERSION == 83201
|
||||||
|
// nrfx 1.8.2 / 1.8.4
|
||||||
|
#define NORDIC_SDK_OLD_API
|
||||||
|
#elif _MDK_VERSION == 83203
|
||||||
|
// nrfx 1.8.5
|
||||||
|
#define NORDIC_SDK_OLD_API
|
||||||
|
#elif _MDK_VERSION == 83500
|
||||||
|
// nrfx 1.8.6
|
||||||
|
#define NORDIC_SDK_OLD_API
|
||||||
|
#elif _MDK_VERSION == 84003
|
||||||
|
// nrfx 1.9.0
|
||||||
|
#define NORDIC_SDK_OLD_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
@ -244,7 +258,7 @@ void dcd_init (uint8_t rhport)
|
|||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
#if defined(SOFTDEVICE_PRESENT) && defined(OLD_NORDIC_SDK)
|
#if defined(SOFTDEVICE_PRESENT) && defined(NORDIC_SDK_OLD_API)
|
||||||
if (sd_nvic_EnableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
if (sd_nvic_EnableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ(USBD_IRQn);
|
NVIC_EnableIRQ(USBD_IRQn);
|
||||||
@ -257,7 +271,7 @@ void dcd_int_enable(uint8_t rhport)
|
|||||||
void dcd_int_disable(uint8_t rhport)
|
void dcd_int_disable(uint8_t rhport)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
#if defined(SOFTDEVICE_PRESENT) && defined(OLD_NORDIC_SDK)
|
#if defined(SOFTDEVICE_PRESENT) && defined(NORDIC_SDK_OLD_API)
|
||||||
if (sd_nvic_DisableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
if (sd_nvic_DisableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
||||||
{
|
{
|
||||||
NVIC_DisableIRQ(USBD_IRQn);
|
NVIC_DisableIRQ(USBD_IRQn);
|
||||||
@ -921,7 +935,7 @@ static bool hfclk_running(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OLD_NORDIC_SDK
|
#ifdef NORDIC_SDK_OLD_API
|
||||||
return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
||||||
#else
|
#else
|
||||||
return nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
return nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY);
|
||||||
@ -946,7 +960,7 @@ static void hfclk_enable(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OLD_NORDIC_SDK
|
#ifdef NORDIC_SDK_OLD_API
|
||||||
nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
|
nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
|
||||||
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART);
|
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART);
|
||||||
#else
|
#else
|
||||||
@ -971,7 +985,7 @@ static void hfclk_disable(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OLD_NORDIC_SDK
|
#ifdef NORDIC_SDK_OLD_API
|
||||||
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP);
|
nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP);
|
||||||
#else
|
#else
|
||||||
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
|
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
|
||||||
@ -1118,7 +1132,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
|||||||
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk;
|
NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk;
|
||||||
|
|
||||||
// Enable interrupt, priorities should be set by application
|
// Enable interrupt, priorities should be set by application
|
||||||
#if defined(SOFTDEVICE_PRESENT) && defined(OLD_NORDIC_SDK)
|
#if defined(SOFTDEVICE_PRESENT) && defined(NORDIC_SDK_OLD_API)
|
||||||
if (sd_nvic_ClearPendingIRQ(USBD_IRQn) != NRF_SUCCESS)
|
if (sd_nvic_ClearPendingIRQ(USBD_IRQn) != NRF_SUCCESS)
|
||||||
{
|
{
|
||||||
NVIC_ClearPendingIRQ(USBD_IRQn);
|
NVIC_ClearPendingIRQ(USBD_IRQn);
|
||||||
@ -1131,7 +1145,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
|||||||
// to handle interrupts.
|
// to handle interrupts.
|
||||||
if (tud_inited())
|
if (tud_inited())
|
||||||
{
|
{
|
||||||
#if defined(SOFTDEVICE_PRESENT) && defined(OLD_NORDIC_SDK)
|
#if defined(SOFTDEVICE_PRESENT) && defined(NORDIC_SDK_OLD_API)
|
||||||
if (sd_nvic_EnableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
if (sd_nvic_EnableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ(USBD_IRQn);
|
NVIC_EnableIRQ(USBD_IRQn);
|
||||||
@ -1159,7 +1173,7 @@ void tusb_hal_nrf_power_event (uint32_t event)
|
|||||||
__ISB(); __DSB(); // for sync
|
__ISB(); __DSB(); // for sync
|
||||||
|
|
||||||
// Disable Interrupt
|
// Disable Interrupt
|
||||||
#if defined(SOFTDEVICE_PRESENT) && defined(OLD_NORDIC_SDK)
|
#if defined(SOFTDEVICE_PRESENT) && defined(NORDIC_SDK_OLD_API)
|
||||||
if (sd_nvic_DisableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
if (sd_nvic_DisableIRQ(USBD_IRQn) != NRF_SUCCESS)
|
||||||
{
|
{
|
||||||
NVIC_DisableIRQ(USBD_IRQn);
|
NVIC_DisableIRQ(USBD_IRQn);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user