summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-07-10 22:08:03 +0700
committerhathach <[email protected]>2018-07-10 22:08:03 +0700
commita0849fee9f4b268ccc9798c70c654a835f8e20c8 (patch)
treeb012a6c2616ad3d7235d38b647db79b67daa75ec /src
parentf5652a0146606151c83f7af25f9779718a65f097 (diff)
add nrf errata check temporarily part of hal_nrf
Diffstat (limited to 'src')
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c1
-rw-r--r--src/portable/nordic/nrf5x/hal_nrf5x.c45
2 files changed, 44 insertions, 2 deletions
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 468dd7d56..db424f650 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -42,7 +42,6 @@
#include "nrf_power.h"
#include "nrf_usbd.h"
#include "nrf_clock.h"
-#include "nrf_drv_usbd_errata.h"
#include "device/dcd.h"
#include "device/usbd_pvt.h" // to use defer function helper
diff --git a/src/portable/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c
index 68e19a42c..c1d8f0318 100644
--- a/src/portable/nordic/nrf5x/hal_nrf5x.c
+++ b/src/portable/nordic/nrf5x/hal_nrf5x.c
@@ -42,7 +42,6 @@
#include "nrf_gpio.h"
#include "nrf_clock.h"
#include "nrf_usbd.h"
-#include "nrf_drv_usbd_errata.h"
#ifdef SOFTDEVICE_PRESENT
#include "nrf_sdm.h"
@@ -70,6 +69,50 @@ enum {
*------------------------------------------------------------------*/
void tusb_hal_nrf_power_event(uint32_t event);
+
+/*------------------------------------------------------------------*/
+/* Errata check from nrf_drv_usbd_errata.h
+ *------------------------------------------------------------------*/
+
+/**
+ * @brief Internal auxiliary function to check if the program is running on NRF52840 chip
+ * @retval true It is NRF52480 chip
+ * @retval false It is other chip
+ */
+static inline bool nrf_drv_usbd_errata_type_52840(void)
+{
+ return ((((*(uint32_t *)0xF0000FE0) & 0xFF) == 0x08) &&
+ (((*(uint32_t *)0xF0000FE4) & 0x0F) == 0x0));
+}
+
+/**
+ * @brief Internal auxiliary function to check if the program is running on first final product of
+ * NRF52840 chip
+ * @retval true It is NRF52480 chip and it is first final product
+ * @retval false It is other chip
+ */
+static inline bool nrf_drv_usbd_errata_type_52840_fp1(void)
+{
+ return ( nrf_drv_usbd_errata_type_52840() &&
+ ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x20 ) &&
+ ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) );
+}
+
+static inline bool nrf_drv_usbd_errata_166(void)
+{
+ return true;
+}
+
+static inline bool nrf_drv_usbd_errata_171(void)
+{
+ return true;
+}
+
+static inline bool nrf_drv_usbd_errata_187(void)
+{
+ return nrf_drv_usbd_errata_type_52840_fp1();
+}
+
/*------------------------------------------------------------------*/
/* HFCLK helper
*------------------------------------------------------------------*/