You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by bt...@apache.org on 2021/01/17 05:04:52 UTC

[incubator-nuttx] branch master updated (efe236b -> 93ef2e7)

This is an automated email from the ASF dual-hosted git repository.

btashton pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from efe236b  drivers/syslog: Prepend Process ID to syslog message
     new c526f01  nrf52: fix build for PWM without multichan enabled
     new 5d44631  nrf52: fix SPI3 irq macro naming
     new ebe596b  nrf52: enable and fix build for SPI BITORDER
     new e1b3374  nrf52 spi: build fixes and a missing register setting (polarity)
     new 6f3f1c0  nrf52 i2c: disable peripheral while configuring
     new 2fcfd63  nrf52: fix build without serial
     new 93ef2e7  nrf52 GPIO: set GPIO drive setting and missing input buffer configuration

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/Kconfig                   |  1 +
 arch/arm/include/nrf52/nrf52_irq.h |  2 +-
 arch/arm/src/nrf52/nrf52_gpio.c    | 83 +++++++++++++++++++++++++++++++++++++-
 arch/arm/src/nrf52/nrf52_i2c.c     | 10 +++--
 arch/arm/src/nrf52/nrf52_lowputc.c | 52 ++++++++++--------------
 arch/arm/src/nrf52/nrf52_pwm.c     |  2 +-
 arch/arm/src/nrf52/nrf52_spi.c     | 11 +++--
 7 files changed, 120 insertions(+), 41 deletions(-)


[incubator-nuttx] 05/07: nrf52 i2c: disable peripheral while configuring

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 6f3f1c07fbd48a71133b6e5df64679f34c69a5e5
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:36:45 2021 -0300

    nrf52 i2c: disable peripheral while configuring
---
 arch/arm/src/nrf52/nrf52_i2c.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/src/nrf52/nrf52_i2c.c b/arch/arm/src/nrf52/nrf52_i2c.c
index e8c7bad..eb55b8b 100644
--- a/arch/arm/src/nrf52/nrf52_i2c.c
+++ b/arch/arm/src/nrf52/nrf52_i2c.c
@@ -568,6 +568,10 @@ static int nrf52_i2c_init(FAR struct nrf52_i2c_priv_s *priv)
   int pin         = 0;
   int port        = 0;
 
+  /* Disable TWI interface */
+
+  nrf52_i2c_putreg(priv, NRF52_TWIM_ENABLE_OFFSET, TWIM_ENABLE_DIS);
+
   /* Configure SCL and SDA pins */
 
   nrf52_gpio_config(priv->scl_pin);
@@ -593,7 +597,7 @@ static int nrf52_i2c_init(FAR struct nrf52_i2c_priv_s *priv)
 
   /* Enable TWI interface */
 
-  nrf52_i2c_putreg(priv, NRF52_TWIS_ENABLE_OFFSET, TWIM_ENABLE_EN);
+  nrf52_i2c_putreg(priv, NRF52_TWIM_ENABLE_OFFSET, TWIM_ENABLE_EN);
 
 #ifndef CONFIG_I2C_POLLED
   /* Enable I2C interrupts */
@@ -671,9 +675,9 @@ static int nrf52_i2c_sem_destroy(FAR struct nrf52_i2c_priv_s *priv)
 
 static int nrf52_i2c_deinit(FAR struct nrf52_i2c_priv_s *priv)
 {
-  /* Enable TWI interface */
+  /* Disable TWI interface */
 
-  nrf52_i2c_putreg(priv, TWIM_ENABLE_DIS, NRF52_TWIS_ENABLE_OFFSET);
+  nrf52_i2c_putreg(priv, NRF52_TWIM_ENABLE_OFFSET, TWIM_ENABLE_DIS);
 
   /* Unconfigure GPIO pins */
 


[incubator-nuttx] 07/07: nrf52 GPIO: set GPIO drive setting and missing input buffer configuration

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 93ef2e71748e8ad16d33d18fdca2ba55d9eaf0a5
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:33:02 2021 -0300

    nrf52 GPIO: set GPIO drive setting and missing input buffer configuration
---
 arch/arm/src/nrf52/nrf52_gpio.c | 83 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/arch/arm/src/nrf52/nrf52_gpio.c b/arch/arm/src/nrf52/nrf52_gpio.c
index 6f5625c..83e70b0 100644
--- a/arch/arm/src/nrf52/nrf52_gpio.c
+++ b/arch/arm/src/nrf52/nrf52_gpio.c
@@ -100,6 +100,11 @@ static inline void nrf52_gpio_input(unsigned int port, unsigned int pin)
   /* Configure the pin as an input */
 
   putreg32(1U << pin, offset);
+
+  /* Enable input buffer */
+
+  offset = nrf52_gpio_regget(port, NRF52_GPIO_PIN_CNF_OFFSET(pin));
+  modifyreg32(offset, GPIO_CNF_INPUT, 0);
 }
 
 /****************************************************************************
@@ -115,6 +120,11 @@ static inline void nrf52_gpio_output(nrf52_pinset_t cfgset,
 {
   uint32_t offset;
 
+  /* Disable input buffer */
+
+  offset = nrf52_gpio_regget(port, NRF52_GPIO_PIN_CNF_OFFSET(pin));
+  modifyreg32(offset, 0, GPIO_CNF_INPUT);
+
   offset = nrf52_gpio_regget(port, NRF52_GPIO_DIRSET_OFFSET);
 
   nrf52_gpio_write(cfgset, ((cfgset & GPIO_VALUE) != GPIO_VALUE_ZERO));
@@ -193,6 +203,59 @@ static inline void nrf52_gpio_sense(nrf52_pinset_t cfgset,
 }
 
 /****************************************************************************
+ * Name: nrf52_gpio_drive
+ *
+ * Description:
+ *   Set DRIVE configuration for a pin
+ *
+ ****************************************************************************/
+
+static inline void nrf52_gpio_drive(nrf52_pinset_t cfgset,
+                                    unsigned int port, unsigned int pin)
+{
+  uint32_t drive;
+  uint32_t regval;
+  uint32_t offset;
+
+  drive = cfgset & GPIO_DRIVE_MASK;
+
+  offset = nrf52_gpio_regget(port, NRF52_GPIO_PIN_CNF_OFFSET(pin));
+  regval = getreg32(offset);
+
+  regval &= ~GPIO_CNF_DRIVE_MASK;
+
+  switch (drive)
+    {
+      case GPIO_DRIVE_S0S1:
+        regval |= GPIO_CNF_DRIVE_S0S1;
+        break;
+      case GPIO_DRIVE_S0H1:
+        regval |= GPIO_CNF_DRIVE_S0H1;
+        break;
+      case GPIO_DRIVE_S0D1:
+        regval |= GPIO_CNF_DRIVE_S0D1;
+        break;
+      case GPIO_DRIVE_H0D1:
+        regval |= GPIO_CNF_DRIVE_H0D1;
+        break;
+      case GPIO_DRIVE_H0H1:
+        regval |= GPIO_CNF_DRIVE_H0H1;
+        break;
+      case GPIO_DRIVE_H0S1:
+        regval |= GPIO_CNF_DRIVE_H0S1;
+        break;
+      case GPIO_DRIVE_D0H1:
+        regval |= GPIO_CNF_DRIVE_D0H1;
+        break;
+      case GPIO_DRIVE_D0S1:
+        regval |= GPIO_CNF_DRIVE_D0S1;
+        break;
+    }
+
+  putreg32(regval, offset);
+}
+
+/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -208,6 +271,8 @@ int nrf52_gpio_config(nrf52_pinset_t cfgset)
 {
   unsigned int port;
   unsigned int pin;
+  irqstate_t flags;
+  int ret = OK;
 
   /* Verify that this hardware supports the select GPIO port */
 
@@ -220,6 +285,8 @@ int nrf52_gpio_config(nrf52_pinset_t cfgset)
 
       pin = GPIO_PIN_DECODE(cfgset);
 
+      flags = spin_lock_irqsave();
+
       /* First, configure the port as a generic input so that we have a
        * known starting point and consistent behavior during the re-
        * configuration.
@@ -231,6 +298,12 @@ int nrf52_gpio_config(nrf52_pinset_t cfgset)
 
       nrf52_gpio_mode(cfgset, port, pin);
 
+      /* Set the drive bits (needed also for input pins
+       * for some peripherals).
+       */
+
+      nrf52_gpio_drive(cfgset, port, pin);
+
       /* Handle according to pin function */
 
       switch (cfgset & GPIO_FUNC_MASK)
@@ -244,11 +317,17 @@ int nrf52_gpio_config(nrf52_pinset_t cfgset)
           break;
 
         default:
-          return -EINVAL;
+          ret = -EINVAL;
         }
+
+      spin_unlock_irqrestore(flags);
+    }
+  else
+    {
+      ret = -EINVAL;
     }
 
-  return OK;
+  return ret;
 }
 
 /****************************************************************************


[incubator-nuttx] 06/07: nrf52: fix build without serial

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2fcfd63f8eb3471301f8e431a5d59a2d914d8661
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:22:21 2021 -0300

    nrf52: fix build without serial
---
 arch/arm/src/nrf52/nrf52_lowputc.c | 52 ++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/arch/arm/src/nrf52/nrf52_lowputc.c b/arch/arm/src/nrf52/nrf52_lowputc.c
index 6d64add..c8a02d9 100644
--- a/arch/arm/src/nrf52/nrf52_lowputc.c
+++ b/arch/arm/src/nrf52/nrf52_lowputc.c
@@ -235,13 +235,11 @@ static void nrf52_setbaud(uintptr_t base, const struct uart_config_s *config)
 
   putreg32(br, base + NRF52_UART_BAUDRATE_OFFSET);
 }
-#endif
 
 /****************************************************************************
  * Name: nrf52_setparity
  ****************************************************************************/
 
-#ifdef HAVE_UART_DEVICE
 static void nrf52_setparity(uintptr_t base,
                             const struct uart_config_s *config)
 {
@@ -264,7 +262,6 @@ static void nrf52_setparity(uintptr_t base,
 
   putreg32(regval, base + NRF52_UART_CONFIG_OFFSET);
 }
-#endif
 
 /****************************************************************************
  * Name: nrf52_setstops
@@ -295,7 +292,6 @@ static void nrf52_setstops(uintptr_t base,
  * Name: nrf52_sethwflow
  ****************************************************************************/
 
-#ifdef HAVE_UART_DEVICE
 static void nrf52_sethwflow(uintptr_t base,
                             const struct uart_config_s *config)
 {
@@ -381,7 +377,6 @@ void nrf52_usart_configure(uintptr_t base,
 
   putreg32(NRF52_UART_ENABLE_ENABLE, base + NRF52_UART_ENABLE_OFFSET);
 }
-#endif
 
 /****************************************************************************
  * Name: nrf52_usart_disable
@@ -392,7 +387,6 @@ void nrf52_usart_configure(uintptr_t base,
  *
  ****************************************************************************/
 
-#ifdef HAVE_UART_DEVICE
 void nrf52_usart_disable(uintptr_t base, const struct uart_config_s *config)
 {
   /* Disable interrupts */
@@ -416,29 +410,6 @@ void nrf52_usart_disable(uintptr_t base, const struct uart_config_s *config)
   putreg32(UART_PSELTXD_RESET, base + NRF52_UART_PSELTXD_OFFSET);
   putreg32(UART_PSELRXD_RESET, base + NRF52_UART_PSELRXD_OFFSET);
 }
-#endif
-
-/****************************************************************************
- * Name: arm_lowputc
- *
- * Description:
- *   Output one byte on the serial console
- *
- ****************************************************************************/
-
-void arm_lowputc(char ch)
-{
-#ifdef HAVE_UART_CONSOLE
-  putreg32(1, CONSOLE_BASE + NRF52_UART_TASKS_STARTTX_OFFSET);
-  putreg32(0, CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET);
-  putreg32(ch, CONSOLE_BASE + NRF52_UART_TXD_OFFSET);
-  while (getreg32(CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET) == 0)
-    {
-    }
-
-  putreg32(1, CONSOLE_BASE + NRF52_UART_TASKS_STOPTX_OFFSET);
-#endif
-}
 
 /****************************************************************************
  * Name: nrf52_usart_setformat
@@ -448,7 +419,6 @@ void arm_lowputc(char ch)
  *
  ****************************************************************************/
 
-#ifdef HAVE_UART_DEVICE
 void nrf52_usart_setformat(uintptr_t base,
                            FAR const struct uart_config_s *config)
 {
@@ -471,3 +441,25 @@ void nrf52_usart_setformat(uintptr_t base,
   nrf52_sethwflow(base, config);
 }
 #endif
+
+/****************************************************************************
+ * Name: arm_lowputc
+ *
+ * Description:
+ *   Output one byte on the serial console
+ *
+ ****************************************************************************/
+
+void arm_lowputc(char ch)
+{
+#ifdef HAVE_UART_CONSOLE
+  putreg32(1, CONSOLE_BASE + NRF52_UART_TASKS_STARTTX_OFFSET);
+  putreg32(0, CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET);
+  putreg32(ch, CONSOLE_BASE + NRF52_UART_TXD_OFFSET);
+  while (getreg32(CONSOLE_BASE + NRF52_UART_EVENTS_TXDRDY_OFFSET) == 0)
+    {
+    }
+
+  putreg32(1, CONSOLE_BASE + NRF52_UART_TASKS_STOPTX_OFFSET);
+#endif
+}


[incubator-nuttx] 02/07: nrf52: fix SPI3 irq macro naming

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5d4463121fcdc49d766a9b0740594e16d54b74ef
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:24:54 2021 -0300

    nrf52: fix SPI3 irq macro naming
---
 arch/arm/include/nrf52/nrf52_irq.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/nrf52/nrf52_irq.h b/arch/arm/include/nrf52/nrf52_irq.h
index c99b761..3fbf7dd 100644
--- a/arch/arm/include/nrf52/nrf52_irq.h
+++ b/arch/arm/include/nrf52/nrf52_irq.h
@@ -99,7 +99,7 @@
 #  define NRF52_IRQ_PWM3        (NRF52_IRQ_EXTINT+45)  /* Pulse Width Modulation Unit 3 */
 #endif
 #ifdef CONFIG_NRF52_HAVE_SPI3_MASTER
-#  define NRF52_IRQ_SPIM3       (NRF52_IRQ_EXTINT+47)  /* SPI Master 3 */
+#  define NRF52_IRQ_SPI3        (NRF52_IRQ_EXTINT+47)  /* SPI Master 3 */
 #endif
 
 #if defined(CONFIG_ARCH_CHIP_NRF52832)


[incubator-nuttx] 01/07: nrf52: fix build for PWM without multichan enabled

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit c526f01ba71bea1852b62987b5db4e52ab2dd350
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:24:32 2021 -0300

    nrf52: fix build for PWM without multichan enabled
---
 arch/arm/src/nrf52/nrf52_pwm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/src/nrf52/nrf52_pwm.c b/arch/arm/src/nrf52/nrf52_pwm.c
index 3503eca..982fcba 100644
--- a/arch/arm/src/nrf52/nrf52_pwm.c
+++ b/arch/arm/src/nrf52/nrf52_pwm.c
@@ -586,7 +586,7 @@ static int nrf52_pwm_start(FAR struct pwm_lowerhalf_s *dev,
 
 #else
       ret = nrf52_pwm_duty(dev,
-                           (priv->channels[0].channel - 1),
+                           (info->channels[0].channel - 1),
                            info->duty);
 #endif /* CONFIG_PWM_MULTICHAN */
 


[incubator-nuttx] 04/07: nrf52 spi: build fixes and a missing register setting (polarity)

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e1b3374bced02d3561e530f44d1c012f1786b568
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:31:08 2021 -0300

    nrf52 spi: build fixes and a missing register setting (polarity)
---
 arch/arm/src/nrf52/nrf52_spi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/src/nrf52/nrf52_spi.c b/arch/arm/src/nrf52/nrf52_spi.c
index c956de2..7e85414 100644
--- a/arch/arm/src/nrf52/nrf52_spi.c
+++ b/arch/arm/src/nrf52/nrf52_spi.c
@@ -854,6 +854,8 @@ static void nrf52_spi_setmode(FAR struct spi_dev_s *dev,
             }
         }
 
+      nrf52_spi_putreg(priv, NRF52_SPIM_CONFIG_OFFSET, regval);
+
       /* According to manual we have to set SCK pin output
        * value the same as CPOL value
        */
@@ -1155,7 +1157,7 @@ static void nrf52_spi_exchange(FAR struct spi_dev_s *dev,
       if (nrf52_spi_getreg(priv, NRF52_SPIM_TXDAMOUNT_OFFSET) !=
           transfer_size)
         {
-          spierr("Incomplete transfer wrote %" PRId32 " expected %d\n",
+          spierr("Incomplete transfer wrote %" PRId32 " expected %zu\n",
                  regval, nwords);
         }
 
@@ -1291,13 +1293,13 @@ static int nrf52_spi_pm_prepare(FAR struct pm_callback_s *cb, int domain,
       active |= nrf52_spi_getreg(&g_spi0dev, SPIM_EVENTS_STARTED);
 #endif
 #ifdef CONFIG_NRF52_SPI1_MASTER
-      active |= nrf52_spi_getreg(&g_spi0dev, SPIM_EVENTS_STARTED);
+      active |= nrf52_spi_getreg(&g_spi1dev, SPIM_EVENTS_STARTED);
 #endif
 #ifdef CONFIG_NRF52_SPI2_MASTER
-      active |= nrf52_spi_getreg(&g_spi0dev, SPIM_EVENTS_STARTED);
+      active |= nrf52_spi_getreg(&g_spi2dev, SPIM_EVENTS_STARTED);
 #endif
 #ifdef CONFIG_NRF52_SPI3_MASTER
-      active |= nrf52_spi_getreg(&g_spi0dev, SPIM_EVENTS_STARTED);
+      active |= nrf52_spi_getreg(&g_spi3dev, SPIM_EVENTS_STARTED);
 #endif
 
       if (active)


[incubator-nuttx] 03/07: nrf52: enable and fix build for SPI BITORDER

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ebe596bcd1d4a39f12e330d15972ce036a3e3e18
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:27:27 2021 -0300

    nrf52: enable and fix build for SPI BITORDER
---
 arch/arm/Kconfig               | 1 +
 arch/arm/src/nrf52/nrf52_spi.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index eae7a46..dc49f39 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -211,6 +211,7 @@ config ARCH_CHIP_NRF52
 	select ARCH_HAVE_TICKLESS
 	#select ARCH_HAVE_MPU
 	#select ARM_HAVE_MPU_UNIFIED
+	select ARCH_HAVE_SPI_BITORDER
 	select ARCH_HAVE_FPU
 	select ARCH_HAVE_PWM_MULTICHAN
 	select ARCH_HAVE_SERIAL_TERMIOS
diff --git a/arch/arm/src/nrf52/nrf52_spi.c b/arch/arm/src/nrf52/nrf52_spi.c
index 84eee94..c956de2 100644
--- a/arch/arm/src/nrf52/nrf52_spi.c
+++ b/arch/arm/src/nrf52/nrf52_spi.c
@@ -920,6 +920,7 @@ static int nrf52_spi_hwfeatures(FAR struct spi_dev_s *dev,
   FAR struct nrf52_spidev_s *priv = (FAR struct nrf52_spidev_s *)dev;
   uint32_t setbits = 0;
   uint32_t clrbits = 0;
+  uint32_t regval;
 
   spiinfo("features=%08x\n", features);