drivers/spi/spi_bitbang: Add private data on spi_bitbang
Add private data for spi_bitbang low-level driver to add an instance specific private data. And add spi_destroy_bitbang() to clean up a driver instance.
This commit is contained in:
parent
e542ef9175
commit
307839ab6d
@ -217,7 +217,7 @@ static struct spi_dev_s *sam_mmcsd_spiinitialize(void)
|
||||
|
||||
/* Create the SPI driver instance */
|
||||
|
||||
return spi_create_bitbang(&g_spiops);
|
||||
return spi_create_bitbang(&g_spiops, NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -313,7 +313,7 @@ static struct spi_dev_s *sam_tsc_spiinitialize(void)
|
||||
|
||||
/* Create the SPI driver instance */
|
||||
|
||||
return spi_create_bitbang(&g_spiops);
|
||||
return spi_create_bitbang(&g_spiops, NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -515,7 +515,8 @@ static int spi_cmddata(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct spi_dev_s *spi_create_bitbang(FAR const struct
|
||||
spi_bitbang_ops_s *low)
|
||||
spi_bitbang_ops_s *low,
|
||||
FAR void *low_priv)
|
||||
{
|
||||
FAR struct spi_bitbang_s *priv;
|
||||
|
||||
@ -535,6 +536,7 @@ FAR struct spi_dev_s *spi_create_bitbang(FAR const struct
|
||||
|
||||
priv->dev.ops = &g_spiops;
|
||||
priv->low = low;
|
||||
priv->priv = low_priv;
|
||||
#ifdef CONFIG_SPI_BITBANG_VARWIDTH
|
||||
priv->nbits = 8;
|
||||
#endif
|
||||
@ -551,4 +553,10 @@ FAR struct spi_dev_s *spi_create_bitbang(FAR const struct
|
||||
return &priv->dev;
|
||||
}
|
||||
|
||||
void spi_destroy_bitbang(FAR struct spi_dev_s *dev)
|
||||
{
|
||||
DEBUGASSERT(dev);
|
||||
kmm_free(dev);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SPI_BITBANG */
|
||||
|
@ -88,6 +88,7 @@ struct spi_bitbang_s
|
||||
uint32_t holdtime; /* SCK hold time to achieve requested frequency */
|
||||
bitexchange_t exchange; /* The select bit exchange function */
|
||||
mutex_t lock; /* Supports mutually exclusive access to SPI */
|
||||
FAR void *priv; /* Private data for instance specific */
|
||||
#ifdef CONFIG_SPI_BITBANG_VARWIDTH
|
||||
uint8_t nbits; /* Number of bits in the transfer */
|
||||
#endif
|
||||
@ -118,6 +119,7 @@ extern "C"
|
||||
*
|
||||
* Input Parameters:
|
||||
* low - Low-level, platform specific device operations.
|
||||
* low_priv - Low-level private data, platform specific data.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success a non-NULL, initialized SPI driver instance is returned.
|
||||
@ -125,7 +127,21 @@ extern "C"
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct spi_dev_s *spi_create_bitbang(
|
||||
FAR const struct spi_bitbang_ops_s *low);
|
||||
FAR const struct spi_bitbang_ops_s *low,
|
||||
FAR void *low_priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spi_destroy_bitbang
|
||||
*
|
||||
* Description:
|
||||
* Destroy an instance of the SPI bit-bang driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - device instance, target driver to destroy.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void spi_destroy_bitbang(FAR struct spi_dev_s *dev);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
Loading…
Reference in New Issue
Block a user