v01d commented on a change in pull request #2270: URL: https://github.com/apache/incubator-nuttx/pull/2270#discussion_r520627992
########## 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: Right, thanks, I tend to forget about other chips sometimes. ---------------------------------------------------------------- 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: us...@infra.apache.org