nRF52: Add hooks for missing SPI register callbacks

This implements the missing callback hooks nrf52_spi0/1/2/3register
that are usually used with mmcsd for card detection.

This also stubs out the missing spi trigger function which is not
used on this platform.

The card detect was tested with the nRF52-feather board and a
modified KeyBoard FeatherWing.

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
This commit is contained in:
Brennan Ashton 2020-09-17 22:57:45 -07:00 committed by Xiang Xiao
parent a9830254cf
commit 1473c6848f
2 changed files with 97 additions and 0 deletions

View File

@ -175,6 +175,14 @@ static const struct spi_ops_s g_spi0ops =
.sendlock = nrf52_spi_sendblock,
.recvblock = nrf52_spi_recvblock
# endif
#ifdef CONFIG_SPI_TRIGGER
.trigger = nrf52_spi_trigger,
#endif
#ifdef CONFIG_SPI_CALLBACK
.registercallback = nrf52_spi0register, /* Provided externally */
#else
.registercallback = 0, /* Not implemented */
#endif
};
static struct nrf52_spidev_s g_spi0dev =
@ -220,6 +228,14 @@ static const struct spi_ops_s g_spi1ops =
.sendlock = nrf52_spi_sendblock,
.recvblock = nrf52_spi_recvblock
# endif
#ifdef CONFIG_SPI_TRIGGER
.trigger = nrf52_spi_trigger,
#endif
#ifdef CONFIG_SPI_CALLBACK
.registercallback = nrf52_spi1register, /* Provided externally */
#else
.registercallback = 0, /* Not implemented */
#endif
};
static struct nrf52_spidev_s g_spi1dev =
@ -265,6 +281,14 @@ static const struct spi_ops_s g_spi2ops =
.sendlock = nrf52_spi_sendblock,
.recvblock = nrf52_spi_recvblock
# endif
#ifdef CONFIG_SPI_TRIGGER
.trigger = nrf52_spi_trigger,
#endif
#ifdef CONFIG_SPI_CALLBACK
.registercallback = nrf52_spi2register, /* Provided externally */
#else
.registercallback = 0, /* Not implemented */
#endif
};
static struct nrf52_spidev_s g_spi2dev =
@ -310,6 +334,14 @@ static const struct spi_ops_s g_spi3ops =
.sendlock = nrf52_spi_sendblock,
.recvblock = nrf52_spi_recvblock
# endif
#ifdef CONFIG_SPI_TRIGGER
.trigger = nrf52_spi_trigger,
#endif
#ifdef CONFIG_SPI_CALLBACK
.registercallback = nrf52_spi3register, /* Provided externally */
#else
.registercallback = 0, /* Not implemented */
#endif
};
static struct nrf52_spidev_s g_spi3dev =
@ -1029,6 +1061,29 @@ static void nrf52_spi_recvblock(FAR struct spi_dev_s *dev,
}
#endif /* CONFIG_SPI_EXCHANGE */
/****************************************************************************
* Name: nrf52_spi_trigger
*
* Description:
* Trigger a previously configured DMA transfer.
*
* Input Parameters:
* dev - Device-specific state data
*
* Returned Value:
* OK - Trigger was fired
* -ENOSYS - Trigger not fired due to lack of DMA or low level support
* -EIO - Trigger not fired because not previously primed
*
****************************************************************************/
#ifdef CONFIG_SPI_TRIGGER
static int nrf52_spi_trigger(FAR struct spi_dev_s *dev)
{
return -ENOSYS;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -123,4 +123,46 @@ uint8_t nrf52_spi3status(FAR struct spi_dev_s *dev, uint32_t devid);
int nrf52_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
#endif
/****************************************************************************
* Name: nrf52_spi0/1/2/3register
*
* Description:
* If the board supports a card detect callback to inform the SPI-based
* MMC/SD driver when an SD card is inserted or removed, then
* CONFIG_SPI_CALLBACK should be defined and the following function(s) must
* be implemented. These functions implements the registercallback method
* of the SPI interface (see include/nuttx/spi/spi.h for details)
*
* Input Parameters:
* dev - Device-specific state data
* callback - The function to call on the media change
* arg - A caller provided value to return with the callback
*
* Returned Value:
* 0 on success; negated errno on failure.
*
****************************************************************************/
#ifdef CONFIG_SPI_CALLBACK
#ifdef CONFIG_NRF52_SPI0_MASTER
int nrf52_spi0register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
FAR void *arg);
#endif
#ifdef CONFIG_NRF52_SPI1_MASTER
int nrf52_spi1register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
FAR void *arg);
#endif
#ifdef CONFIG_NRF52_SPI2_MASTER
int nrf52_spi2register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
FAR void *arg);
#endif
#ifdef CONFIG_NRF52_SPI3_MASTER
int nrf52_spi3register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
FAR void *arg);
#endif
#endif
#endif /* __ARCH_ARM_SRC_NRF52_NRF52_SPI_H */