You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/11/10 06:57:42 UTC

[GitHub] [incubator-nuttx] raiden00pl commented on a change in pull request #2270: nRF52 SPI improvements

raiden00pl commented on a change in pull request #2270:
URL: https://github.com/apache/incubator-nuttx/pull/2270#discussion_r520331956



##########
File path: arch/arm/src/nrf52/nrf52_spi.c
##########
@@ -404,6 +425,71 @@ static int nrf52_spi_isr(int irq, FAR void *context, FAR void *arg)
 }
 #endif
 
+/****************************************************************************
+ * Name: nrf52_spi_init
+ *
+ * Description:
+ *   Configure SPI
+ *
+ ****************************************************************************/
+
+static int nrf52_spi_init(FAR struct nrf52_spidev_s *priv)
+{
+  /* Disable SPI */
+
+  nrf52_spi_putreg(priv, NRF52_SPIM_ENABLE_OFFSET, SPIM_ENABLE_DIS);
+
+  /* Configure SPI pins */
+
+  nrf52_spi_gpioinit(priv);
+
+  /* NOTE: Chip select pin must be configured by board-specific logic */
+
+#ifdef CONFIG_NRF52_SPI_MASTER_INTERRUPTS
+  /* Enable interrupts for RX and TX done */
+
+  nrf52_spi_putreg(priv, NRF52_SPIM_INTENSET_OFFSET, SPIM_INT_END);
+#endif
+
+  /* Enable SPI */
+
+  nrf52_spi_putreg(priv, NRF52_SPIM_ENABLE_OFFSET, SPIM_ENABLE_EN);
+
+  return OK;
+}
+
+#ifdef CONFIG_PM
+/****************************************************************************
+ * Name: nrf52_spi_deinit
+ *
+ * Description:
+ *   Configure SPI
+ *
+ ****************************************************************************/
+
+static int nrf52_spi_deinit(FAR struct nrf52_spidev_s *priv)
+{
+  /* Disable SPI */
+
+  nrf52_spi_putreg(priv, NRF52_SPIM_ENABLE_OFFSET, SPIM_ENABLE_DIS);
+
+  /* Apply workaround for errata 89 (replace dummy read by barrier to avoid

Review comment:
       As I can see in errata, this only applies to nrf52832. We should not use a workaround for other chips if it is not needed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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