You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/05/22 14:09:29 UTC

[GitHub] mlaz closed pull request #1106: [WIP] NRF52810 Support

mlaz closed pull request #1106: [WIP] NRF52810 Support
URL: https://github.com/apache/mynewt-core/pull/1106
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/mcu/nordic/include/nrfx_glue.h b/hw/mcu/nordic/include/nrfx_glue.h
index 5a1f57be5c..2f51256364 100644
--- a/hw/mcu/nordic/include/nrfx_glue.h
+++ b/hw/mcu/nordic/include/nrfx_glue.h
@@ -84,7 +84,7 @@ extern "C" {
  * @retval true  If the IRQ is enabled.
  * @retval false Otherwise.
  */
-#define NRFX_IRQ_IS_ENABLED(irq_number) (NVIC_GetEnableIRQ(irq_number) == 1);
+#define NRFX_IRQ_IS_ENABLED(irq_number) (NVIC_GetEnableIRQ(irq_number) == 1)
 
 /**
  * @brief Macro for disabling a specific IRQ.
diff --git a/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h b/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
index 1dc47e429a..b635eaf917 100644
--- a/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
+++ b/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
@@ -22,11 +22,7 @@
 
 #include "os/mynewt.h"
 
-#ifdef NRF52840_XXAA
-#include "nrf52840.h"
-#else
-#include "nrf52.h"
-#endif
+#include "nrf.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/hw/mcu/nordic/nrf52xxx/pkg.yml b/hw/mcu/nordic/nrf52xxx/pkg.yml
index 30e1cd543e..945a261d74 100644
--- a/hw/mcu/nordic/nrf52xxx/pkg.yml
+++ b/hw/mcu/nordic/nrf52xxx/pkg.yml
@@ -29,3 +29,9 @@ pkg.deps:
     - hw/mcu/nordic
     - hw/cmsis-core 
     - hw/hal 
+
+# NRF52810 doesn't support SPI/I2C (Use SPIM/I2CM instead)
+pkg.ign_files.BSP_NRF52810:
+    - "hal_spi.c"
+    - "hal_i2c.c"
+
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_flash.c b/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
index 50a837369d..50edd54d14 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_flash.c
@@ -51,6 +51,14 @@ const struct hal_flash nrf52k_flash_dev = {
     .hf_sector_cnt = 256,	/* XXX read from factory info? */
     .hf_align = 1
 };
+#elif defined(NRF52810_XXAA)
+const struct hal_flash nrf52k_flash_dev = {
+    .hf_itf = &nrf52k_flash_funcs,
+    .hf_base_addr = 0x00000000,
+    .hf_size = 192 * 1024,  /* XXX read from factory info? */
+    .hf_sector_cnt = 48,   /* XXX read from factory info? */
+    .hf_align = 1
+};
 #elif defined(NRF52832_XXAA)
 const struct hal_flash nrf52k_flash_dev = {
     .hf_itf = &nrf52k_flash_funcs,
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c b/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
index 6cf3bbe9f4..c8ad5245e7 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
@@ -32,6 +32,35 @@
  *
  */
 
+/*
+ * GPIO pin mapping
+ *
+ * The logical GPIO pin numbers (0 to N) are mapped to ports in the following
+ * manner:
+ *  pins 0 - 31: Port 0
+ *  pins 32 - 48: Port 1.
+ *
+ *  The nrf52832 has only one port with 32 pins. The nrf52840 has 48 pins and
+ *  uses two ports.
+ *
+ *  NOTE: in order to save code space, there is no checking done to see if the
+ *  user specifies a pin that is not used by the processor. If an invalid pin
+ *  number is used unexpected and/or erroneous behavior will result.
+ */
+#if defined(NRF52832_XXAA) || defined(NRF52810_XXAA)
+#define HAL_GPIO_INDEX(pin)     (pin)
+#define HAL_GPIO_PORT(pin)      (NRF_P0)
+#define HAL_GPIO_MASK(pin)      (1 << pin)
+#define HAL_GPIOTE_PIN_MASK     GPIOTE_CONFIG_PSEL_Msk
+#endif
+
+#ifdef NRF52840_XXAA
+#define HAL_GPIO_INDEX(pin)     ((pin) & 0x1F)
+#define HAL_GPIO_PORT(pin)      ((pin) > 31 ? NRF_P1 : NRF_P0)
+#define HAL_GPIO_MASK(pin)      (1 << HAL_GPIO_INDEX(pin))
+#define HAL_GPIOTE_PIN_MASK     (0x3FUL << GPIOTE_CONFIG_PSEL_Pos)
+#endif
+
 /* GPIO interrupts */
 #define HAL_GPIO_MAX_IRQ        8
 
diff --git a/hw/mcu/nordic/pkg.yml b/hw/mcu/nordic/pkg.yml
index ad445b5d63..111e5408aa 100644
--- a/hw/mcu/nordic/pkg.yml
+++ b/hw/mcu/nordic/pkg.yml
@@ -32,6 +32,10 @@ pkg.ign_files.BSP_NRF52:
     - "nrfx_power.c"
     - "nrfx_power_clock.c"
 
+pkg.ign_files.BSP_NRF52810:
+    - "nrfx_power.c"
+    - "nrfx_power_clock.c"
+
 pkg.ign_files.BSP_NRF52840:
     - "nrfx_power.c"
     - "nrfx_power_clock.c"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services