Skip to content

Commit

Permalink
nrfx 1.8.6 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nika-nordic committed Dec 10, 2020
1 parent bc1fb91 commit d68126c
Show file tree
Hide file tree
Showing 75 changed files with 8,184 additions and 6,700 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
All notable changes to this project are documented in this file.

## [1.8.6] - 2020-08-31
### Added
- Implemented workaround for anomaly 223 in the USBD driver.

### Changed
- Updated MDK to version 8.35.0.

## [1.8.5] - 2020-07-09
### Added
- Implemented workaround for anomaly 211 in the USBD driver.
Expand Down
217 changes: 139 additions & 78 deletions drivers/src/nrfx_usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ static uint32_t m_ep_dma_waiting;
*/
static bool m_dma_pending;

/**
* @brief First time enabling after reset. Used in nRF52 errata 223.
*/
static bool m_first_enable = true;

/**
* @brief The structure that would hold transfer configuration to every endpoint
*
Expand Down Expand Up @@ -1452,6 +1457,126 @@ static void usbd_dmareq_process(void)
}
}
}

/**
* @brief Wait for a specified eventcause and clear it afterwards.
*/
static inline void usbd_eventcause_wait_and_clear(nrf_usbd_eventcause_mask_t eventcause)
{
while (0 == (eventcause & nrf_usbd_eventcause_get()))
{
/* Empty loop */
}
nrf_usbd_eventcause_clear(eventcause);
}

/**
* @brief Begin errata 171.
*/
static inline void usbd_errata_171_begin(void)
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;
}
NRFX_CRITICAL_SECTION_EXIT();
}

/**
* @brief End errata 171.
*/
static inline void usbd_errata_171_end(void)
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006EC14)) = 0x00000000;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006EC14)) = 0x00000000;
}
NRFX_CRITICAL_SECTION_EXIT();
}

/**
* @brief Begin erratas 187 and 211.
*/
static inline void usbd_errata_187_211_begin(void)
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006ED14)) = 0x00000003;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006ED14)) = 0x00000003;
}
NRFX_CRITICAL_SECTION_EXIT();
}

/**
* @brief End erratas 187 and 211.
*/
static inline void usbd_errata_187_211_end(void)
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
}
NRFX_CRITICAL_SECTION_EXIT();
}

/**
* @brief Enable USBD peripheral.
*/
static void usbd_enable(void)
{
if (nrfx_usbd_errata_187())
{
usbd_errata_187_211_begin();
}

if (nrfx_usbd_errata_171())
{
usbd_errata_171_begin();
}

/* Enable the peripheral */
nrf_usbd_enable();

/* Waiting for peripheral to enable, this should take a few us */
usbd_eventcause_wait_and_clear(NRF_USBD_EVENTCAUSE_READY_MASK);

if (nrfx_usbd_errata_171())
{
usbd_errata_171_end();
}

if (nrfx_usbd_errata_187())
{
usbd_errata_187_211_end();
}
}
/** @} */

/**
Expand Down Expand Up @@ -1583,66 +1708,24 @@ void nrfx_usbd_enable(void)
/* Prepare for READY event receiving */
nrf_usbd_eventcause_clear(NRF_USBD_EVENTCAUSE_READY_MASK);

#if NRFX_USBD_USE_WORKAROUND_FOR_ANOMALY_211
if (nrfx_usbd_errata_187() || nrfx_usbd_errata_211())
#else
if (nrfx_usbd_errata_187())
#endif
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006ED14)) = 0x00000003;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006ED14)) = 0x00000003;
}
NRFX_CRITICAL_SECTION_EXIT();
}
usbd_enable();

if (nrfx_usbd_errata_171())
if (nrfx_usbd_errata_223() && m_first_enable)
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;
}
NRFX_CRITICAL_SECTION_EXIT();
}
nrf_usbd_disable();

/* Enable the peripheral */
nrf_usbd_enable();
/* Waiting for peripheral to enable, this should take a few us */
while (0 == (NRF_USBD_EVENTCAUSE_READY_MASK & nrf_usbd_eventcause_get()))
{
/* Empty loop */
usbd_enable();

m_first_enable = false;
}
nrf_usbd_eventcause_clear(NRF_USBD_EVENTCAUSE_READY_MASK);

if (nrfx_usbd_errata_171())
#if NRFX_USBD_USE_WORKAROUND_FOR_ANOMALY_211
if (nrfx_usbd_errata_187() || nrfx_usbd_errata_211())
#else
if (nrfx_usbd_errata_187())
#endif
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006EC14)) = 0x00000000;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006EC14)) = 0x00000000;
}

NRFX_CRITICAL_SECTION_EXIT();
usbd_errata_187_211_begin();
}

if (nrfx_usbd_errata_166())
Expand Down Expand Up @@ -1677,18 +1760,7 @@ void nrfx_usbd_enable(void)
if (nrfx_usbd_errata_187())
#endif
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
}
NRFX_CRITICAL_SECTION_EXIT();
usbd_errata_187_211_end();
}
}

Expand All @@ -1708,18 +1780,7 @@ void nrfx_usbd_disable(void)
#if NRFX_USBD_USE_WORKAROUND_FOR_ANOMALY_211
if (nrfx_usbd_errata_211())
{
NRFX_CRITICAL_SECTION_ENTER();
if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)
{
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
}
else
{
*((volatile uint32_t *)(0x4006ED14)) = 0x00000000;
}
NRFX_CRITICAL_SECTION_EXIT();
usbd_errata_187_211_end();
}
#endif
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/src/nrfx_usbd_errata.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ static inline bool nrfx_usbd_errata_211(void)
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_211();
}

/* Errata: Unexpected behavior after reset. **/
static inline bool nrfx_usbd_errata_223(void)
{
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_223();
}

#endif // NRFX_USBD_ERRATA_H__
4 changes: 3 additions & 1 deletion mdk/arm_startup_nrf52805.s
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD CCM_AAR_IRQHandler
DCD WDT_IRQHandler
DCD RTC1_IRQHandler
DCD 0 ; Reserved
DCD QDEC_IRQHandler
DCD 0 ; Reserved
DCD SWI0_EGU0_IRQHandler
DCD SWI1_EGU1_IRQHandler
Expand Down Expand Up @@ -281,6 +281,7 @@ Default_Handler PROC
EXPORT CCM_AAR_IRQHandler [WEAK]
EXPORT WDT_IRQHandler [WEAK]
EXPORT RTC1_IRQHandler [WEAK]
EXPORT QDEC_IRQHandler [WEAK]
EXPORT SWI0_EGU0_IRQHandler [WEAK]
EXPORT SWI1_EGU1_IRQHandler [WEAK]
EXPORT SWI2_IRQHandler [WEAK]
Expand All @@ -304,6 +305,7 @@ ECB_IRQHandler
CCM_AAR_IRQHandler
WDT_IRQHandler
RTC1_IRQHandler
QDEC_IRQHandler
SWI0_EGU0_IRQHandler
SWI1_EGU1_IRQHandler
SWI2_IRQHandler
Expand Down
Loading

0 comments on commit d68126c

Please sign in to comment.