Remove CONFIG_SPI_OWNBUS: Now it is not just a good idea, it is the law

This commit is contained in:
Gregory Nutt
2016-01-23 18:54:36 -06:00
parent f6e49caba8
commit 7edf921c5e
36 changed files with 32 additions and 756 deletions
+1 -1
Submodule arch updated: 244343293f...32ca4e6150
+1 -1
Submodule configs updated: 66325b8ab4...dd88ee499c
+2 -18
View File
@@ -170,7 +170,6 @@ static void pga11x_configure(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void pga11x_lock(FAR struct spi_dev_s *spi) static void pga11x_lock(FAR struct spi_dev_s *spi)
{ {
spivdbg("Locking\n"); spivdbg("Locking\n");
@@ -193,9 +192,6 @@ static void pga11x_lock(FAR struct spi_dev_s *spi)
pga11x_configure(spi); pga11x_configure(spi);
} }
#else
# define pga11x_lock(spi)
#endif
/**************************************************************************** /****************************************************************************
* Name: pga11x_unlock * Name: pga11x_unlock
@@ -208,16 +204,12 @@ static void pga11x_lock(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void pga11x_unlock(FAR struct spi_dev_s *spi) static inline void pga11x_unlock(FAR struct spi_dev_s *spi)
{ {
spivdbg("Unlocking\n"); spivdbg("Unlocking\n");
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#else
# define pga11x_unlock(spi)
#endif
/**************************************************************************** /****************************************************************************
* Name: pga11x_send16 * Name: pga11x_send16
@@ -361,16 +353,8 @@ PGA11X_HANDLE pga11x_initialize(FAR struct spi_dev_s *spi)
{ {
spivdbg("Entry\n"); spivdbg("Entry\n");
/* Configure the SPI us for the device. Do this now only if the PGA11X is /* No Special state is required, just return the SPI driver instance as
* the only device on the bus. * the handle. This gives us a place to extend functionality in the
*/
#ifdef CONFIG_SPI_OWNBUS
pga11x_configure(spi);
#endif
/* No other special state is required, just return the SPI driver instance
* as the handle. This gives us a place to extend functionality in the
* future if neccessary. * future if neccessary.
*/ */
+2 -53
View File
@@ -94,15 +94,8 @@
****************************************************************************/ ****************************************************************************/
/* Low-level SPI helpers */ /* Low-level SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi);
# define ads7843e_lock(spi)
# define ads7843e_unlock(spi)
#else
# define ads7843e_configspi(spi);
static void ads7843e_lock(FAR struct spi_dev_s *spi); static void ads7843e_lock(FAR struct spi_dev_s *spi);
static void ads7843e_unlock(FAR struct spi_dev_s *spi); static void ads7843e_unlock(FAR struct spi_dev_s *spi);
#endif
static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd); static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd);
@@ -180,7 +173,6 @@ static struct ads7843e_dev_s *g_ads7843elist;
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void ads7843e_lock(FAR struct spi_dev_s *spi) static void ads7843e_lock(FAR struct spi_dev_s *spi)
{ {
/* Lock the SPI bus because there are multiple devices competing for the /* Lock the SPI bus because there are multiple devices competing for the
@@ -201,15 +193,13 @@ static void ads7843e_lock(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false); SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: ads7843e_unlock * Function: ads7843e_unlock
* *
* Description: * Description:
* If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS * Un-lock the SPI bus after each transfer, possibly losing the current
* undefined) then we need to un-lock the SPI bus for each transfer, * configuration if we are sharing the bus with other devices.
* possibly losing the current configuration.
* *
* Parameters: * Parameters:
* spi - Reference to the SPI driver structure * spi - Reference to the SPI driver structure
@@ -221,49 +211,12 @@ static void ads7843e_lock(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void ads7843e_unlock(FAR struct spi_dev_s *spi) static void ads7843e_unlock(FAR struct spi_dev_s *spi)
{ {
/* Relinquish the SPI bus. */ /* Relinquish the SPI bus. */
(void)SPI_LOCK(spi, false); (void)SPI_LOCK(spi, false);
} }
#endif
/****************************************************************************
* Function: ads7843e_configspi
*
* Description:
* Configure the SPI for use with the ADS7843E. This function should be
* called once during touchscreen initialization to configure the SPI
* bus. Note that if CONFIG_SPI_OWNBUS is not defined, then this function
* does nothing.
*
* Parameters:
* spi - Reference to the SPI driver structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi)
{
/* Configure SPI for the ADS7843. But only if we own the SPI bus.
* Otherwise, don't bother because it might change.
*/
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE);
SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
}
#endif
/**************************************************************************** /****************************************************************************
* Name: ads7843e_sendcmd * Name: ads7843e_sendcmd
@@ -1254,10 +1207,6 @@ int ads7843e_register(FAR struct spi_dev_s *spi,
ads7843e_lock(spi); ads7843e_lock(spi);
/* Configure the SPI interface */
ads7843e_configspi(spi);
/* Enable the PEN IRQ */ /* Enable the PEN IRQ */
ads7843e_sendcmd(priv, ADS7843_CMD_ENABPENIRQ); ads7843e_sendcmd(priv, ADS7843_CMD_ENABPENIRQ);
+3 -52
View File
@@ -88,16 +88,8 @@
****************************************************************************/ ****************************************************************************/
/* Low-level SPI helpers */ /* Low-level SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void max11802_configspi(FAR struct spi_dev_s *spi);
# define max11802_lock(spi)
# define max11802_unlock(spi)
#else
# define max11802_configspi(spi);
static void max11802_lock(FAR struct spi_dev_s *spi); static void max11802_lock(FAR struct spi_dev_s *spi);
static void max11802_unlock(FAR struct spi_dev_s *spi); static void max11802_unlock(FAR struct spi_dev_s *spi);
#endif
static uint16_t max11802_sendcmd(FAR struct max11802_dev_s *priv, static uint16_t max11802_sendcmd(FAR struct max11802_dev_s *priv,
uint8_t cmd, int *tags); uint8_t cmd, int *tags);
@@ -181,7 +173,6 @@ static struct max11802_dev_s *g_max11802list;
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void max11802_lock(FAR struct spi_dev_s *spi) static void max11802_lock(FAR struct spi_dev_s *spi)
{ {
/* Lock the SPI bus because there are multiple devices competing for the /* Lock the SPI bus because there are multiple devices competing for the
@@ -200,15 +191,13 @@ static void max11802_lock(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_MAX11802_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_MAX11802_FREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: max11802_unlock * Function: max11802_unlock
* *
* Description: * Description:
* If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS * Un-lock the SPI bus after each transfer, possibly losing the current
* undefined) then we need to un-lock the SPI bus for each transfer, * configuration if we are sharing the SPI bus with other devices
* possibly losing the current configuration.
* *
* Parameters: * Parameters:
* spi - Reference to the SPI driver structure * spi - Reference to the SPI driver structure
@@ -220,47 +209,12 @@ static void max11802_lock(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void max11802_unlock(FAR struct spi_dev_s *spi) static void max11802_unlock(FAR struct spi_dev_s *spi)
{ {
/* Relinquish the SPI bus. */ /* Relinquish the SPI bus. */
(void)SPI_LOCK(spi, false); (void)SPI_LOCK(spi, false);
} }
#endif
/****************************************************************************
* Function: max11802_configspi
*
* Description:
* Configure the SPI for use with the MAX11802. This function should be
* called once during touchscreen initialization to configure the SPI
* bus. Note that if CONFIG_SPI_OWNBUS is not defined, then this function
* does nothing.
*
* Parameters:
* spi - Reference to the SPI driver structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void max11802_configspi(FAR struct spi_dev_s *spi)
{
/* Configure SPI for the MAX11802. But only if we own the SPI bus.
* Otherwise, don't bother because it might change.
*/
SPI_SETMODE(spi, CONFIG_MAX11802_SPIMODE);
SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_MAX11802_FREQUENCY);
}
#endif
/**************************************************************************** /****************************************************************************
* Name: max11802_sendcmd * Name: max11802_sendcmd
@@ -1256,11 +1210,8 @@ int max11802_register(FAR struct spi_dev_s *spi,
max11802_lock(spi); max11802_lock(spi);
/* Configure the SPI interface */
max11802_configspi(spi);
/* Configure MAX11802 registers */ /* Configure MAX11802 registers */
SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true); SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
(void)SPI_SEND(priv->spi, MAX11802_CMD_MODE_WR); (void)SPI_SEND(priv->spi, MAX11802_CMD_MODE_WR);
(void)SPI_SEND(priv->spi, MAX11802_MODE); (void)SPI_SEND(priv->spi, MAX11802_MODE);
+6 -69
View File
@@ -150,14 +150,8 @@ struct memlcd_dev_s
/* Low-level spi helpers */ /* Low-level spi helpers */
static inline void memlcd_configspi(FAR struct spi_dev_s *spi);
#ifdef CONFIG_SPI_OWNBUS
static inline void memlcd_select(FAR struct spi_dev_s *spi);
static inline void memlcd_deselect(FAR struct spi_dev_s *spi);
#else
static void memlcd_select(FAR struct spi_dev_s *spi); static void memlcd_select(FAR struct spi_dev_s *spi);
static void memlcd_deselect(FAR struct spi_dev_s *spi); static void memlcd_deselect(FAR struct spi_dev_s *spi);
#endif
/* lcd data transfer methods */ /* lcd data transfer methods */
@@ -266,48 +260,6 @@ static inline int __test_bit(int nr, const volatile uint8_t * addr)
return 1 & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE - 1))); return 1 & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE - 1)));
} }
/****************************************************************************
* Name: memlcd_configspi
*
* Description:
* Configure the SPI for use with the Sharp Memory LCD
*
* Input Parameters:
* spi - Reference to the SPI driver structure
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/
static inline void memlcd_configspi(FAR struct spi_dev_s *spi)
{
#ifdef CONFIG_MEMLCD_SPI_FREQUENCY
lcddbg("Mode: %d Bits: %d Frequency: %d\n",
MEMLCD_SPI_MODE, MEMLCD_SPI_BITS, CONFIG_MEMLCD_SPI_FREQUENCY);
#else
lcddbg("Mode: %d Bits: %d Frequency: %d\n",
MEMLCD_SPI_MODE, MEMLCD_SPI_BITS, MEMLCD_SPI_FREQUENCY);
#endif
/* Configure SPI for the Memory LCD. But only if we own the SPI bus.
* Otherwise, don't bother because it might change.
*/
#ifdef CONFIG_SPI_OWNBUS
SPI_SETMODE(spi, MEMLCD_SPI_MODE);
SPI_SETBITS(spi, MEMLCD_SPI_BITS);
(void)SPI_HWFEATURES(spi, 0);
# ifdef CONFIG_MEMLCD_SPI_FREQUENCY
(void)SPI_SETFREQUENCY(spi, CONFIG_MEMLCD_SPI_FREQUENCY);
# else
(void)SPI_SETFREQUENCY(spi, MEMLCD_SPI_FREQUENCY);
# endif
#endif
}
/**************************************************************************** /****************************************************************************
* Name: memlcd_select * Name: memlcd_select
* *
@@ -324,25 +276,19 @@ static inline void memlcd_configspi(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void memlcd_select(FAR struct spi_dev_s *spi)
{
/* we own the spi bus, so just select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
}
#else
static void memlcd_select(FAR struct spi_dev_s *spi) static void memlcd_select(FAR struct spi_dev_s *spi)
{ {
/* Select memlcd (locking the SPI bus in case there are multiple /* Select memlcd (locking the SPI bus in case there are multiple
* devices competing for the SPI bus * devices competing for the SPI bus
*/ */
SPI_LOCK(spi, true); SPI_LOCK(spi, true);
SPI_SELECT(spi, SPIDEV_DISPLAY, true); SPI_SELECT(spi, SPIDEV_DISPLAY, true);
/* Now make sure that the SPI bus is configured for the memlcd (it /* Now make sure that the SPI bus is configured for the memlcd (it
* might have gotten configured for a different device while unlocked) * might have gotten configured for a different device while unlocked)
*/ */
SPI_SETMODE(spi, MEMLCD_SPI_MODE); SPI_SETMODE(spi, MEMLCD_SPI_MODE);
SPI_SETBITS(spi, MEMLCD_SPI_BITS); SPI_SETBITS(spi, MEMLCD_SPI_BITS);
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
@@ -352,7 +298,6 @@ static void memlcd_select(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, MEMLCD_SPI_FREQUENCY); (void)SPI_SETFREQUENCY(spi, MEMLCD_SPI_FREQUENCY);
# endif # endif
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: memlcd_deselect * Name: memlcd_deselect
@@ -370,20 +315,13 @@ static void memlcd_select(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void memlcd_deselect(FAR struct spi_dev_s *spi)
{
/* we own the spi bus, so just de-select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
}
#else
static void memlcd_deselect(FAR struct spi_dev_s *spi) static void memlcd_deselect(FAR struct spi_dev_s *spi)
{ {
/* de-select memlcd and relinquish the spi bus. */ /* De-select memlcd and relinquish the spi bus. */
SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_SELECT(spi, SPIDEV_DISPLAY, false);
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: memlcd_clear * Name: memlcd_clear
@@ -765,11 +703,10 @@ FAR struct lcd_dev_s *memlcd_initialize(FAR struct spi_dev_s *spi,
DEBUGASSERT(spi && priv && devno == 0); DEBUGASSERT(spi && priv && devno == 0);
/* register board specific functions */ /* Register board specific functions */
mlcd->priv = priv;
mlcd->priv = priv;
mlcd->spi = spi; mlcd->spi = spi;
memlcd_configspi(spi);
mlcd->priv->attachirq(memlcd_extcominisr); mlcd->priv->attachirq(memlcd_extcominisr);
+2 -61
View File
@@ -338,14 +338,8 @@ struct nokia_dev_s
/* SPI support */ /* SPI support */
static inline void nokia_configspi(FAR struct spi_dev_s *spi);
#ifdef CONFIG_SPI_OWNBUS
static inline void nokia_select(FAR struct spi_dev_s *spi);
static inline void nokia_deselect(FAR struct spi_dev_s *spi);
#else
static void nokia_select(FAR struct spi_dev_s *spi); static void nokia_select(FAR struct spi_dev_s *spi);
static void nokia_deselect(FAR struct spi_dev_s *spi); static void nokia_deselect(FAR struct spi_dev_s *spi);
#endif
static void nokia_sndcmd(FAR struct spi_dev_s *spi, const uint8_t cmd); static void nokia_sndcmd(FAR struct spi_dev_s *spi, const uint8_t cmd);
static void nokia_cmdarray(FAR struct spi_dev_s *spi, int len, const uint8_t *cmddata); static void nokia_cmdarray(FAR struct spi_dev_s *spi, int len, const uint8_t *cmddata);
static void nokia_clrram(FAR struct spi_dev_s *spi); static void nokia_clrram(FAR struct spi_dev_s *spi);
@@ -650,39 +644,6 @@ static const uint8_t g_setcon[] =
* Private Functions * Private Functions
**************************************************************************************/ **************************************************************************************/
/**************************************************************************************
* Function: nokia_configspi
*
* Description:
* Configure the SPI for use with the Nokia 6100
*
* Parameters:
* spi - Reference to the SPI driver structure
*
* Returned Value:
* None
*
* Assumptions:
*
**************************************************************************************/
static inline void nokia_configspi(FAR struct spi_dev_s *spi)
{
lcddbg("Mode: %d Bits: %d Frequency: %d\n",
CONFIG_NOKIA6100_SPIMODE, CONFIG_NOKIA6100_WORDWIDTH, CONFIG_NOKIA6100_FREQUENCY);
/* Configure SPI for the Nokia 6100. But only if we own the SPI bus. Otherwise, don't
* bother because it might change.
*/
#ifdef CONFIG_SPI_OWNBUS
SPI_SETMODE(spi, CONFIG_NOKIA6100_SPIMODE);
SPI_SETBITS(spi, CONFIG_NOKIA6100_WORDWIDTH);
(void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY)
#endif
}
/************************************************************************************** /**************************************************************************************
* Function: nokia_select * Function: nokia_select
* *
@@ -699,15 +660,6 @@ static inline void nokia_configspi(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void nokia_select(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just select the chip */
lcddbg("SELECTED\n");
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
}
#else
static void nokia_select(FAR struct spi_dev_s *spi) static void nokia_select(FAR struct spi_dev_s *spi)
{ {
/* Select Nokia 6100 chip (locking the SPI bus in case there are multiple /* Select Nokia 6100 chip (locking the SPI bus in case there are multiple
@@ -727,7 +679,6 @@ static void nokia_select(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Function: nokia_deselect * Function: nokia_deselect
@@ -745,15 +696,6 @@ static void nokia_select(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void nokia_deselect(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just de-select the chip */
lcddbg("DE-SELECTED\n");
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
}
#else
static void nokia_deselect(FAR struct spi_dev_s *spi) static void nokia_deselect(FAR struct spi_dev_s *spi)
{ {
/* De-select Nokia 6100 chip and relinquish the SPI bus. */ /* De-select Nokia 6100 chip and relinquish the SPI bus. */
@@ -762,7 +704,6 @@ static void nokia_deselect(FAR struct spi_dev_s *spi)
SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_SELECT(spi, SPIDEV_DISPLAY, false);
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: nokia_sndcmd * Name: nokia_sndcmd
@@ -1218,9 +1159,8 @@ FAR struct lcd_dev_s *nokia_lcdinitialize(FAR struct spi_dev_s *spi, unsigned in
priv->spi = spi; /* Save the SPI instance */ priv->spi = spi; /* Save the SPI instance */
priv->contrast = NOKIA_DEFAULT_CONTRAST; /* Initial contrast setting */ priv->contrast = NOKIA_DEFAULT_CONTRAST; /* Initial contrast setting */
/* Configure and enable the LCD controller */ /* Enable the LCD controller */
nokia_configspi(spi);
if (nokia_initialize(priv) == OK) if (nokia_initialize(priv) == OK)
{ {
/* Turn on the backlight */ /* Turn on the backlight */
@@ -1228,5 +1168,6 @@ FAR struct lcd_dev_s *nokia_lcdinitialize(FAR struct spi_dev_s *spi, unsigned in
nokia_backlight(CONFIG_NOKIA6100_BLINIT); nokia_backlight(CONFIG_NOKIA6100_BLINIT);
return &priv->dev; return &priv->dev;
} }
return NULL; return NULL;
} }
-25
View File
@@ -206,13 +206,8 @@ struct rit_dev_s
/* Low-level SPI helpers */ /* Low-level SPI helpers */
static inline void rit_configspi(FAR struct spi_dev_s *spi); static inline void rit_configspi(FAR struct spi_dev_s *spi);
#ifdef CONFIG_SPI_OWNBUS
static inline void rit_select(FAR struct spi_dev_s *spi);
static inline void rit_deselect(FAR struct spi_dev_s *spi);
#else
static void rit_select(FAR struct spi_dev_s *spi); static void rit_select(FAR struct spi_dev_s *spi);
static void rit_deselect(FAR struct spi_dev_s *spi); static void rit_deselect(FAR struct spi_dev_s *spi);
#endif
static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer, static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer,
size_t buflen, bool cmd); size_t buflen, bool cmd);
static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table); static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table);
@@ -457,14 +452,12 @@ static inline void rit_configspi(FAR struct spi_dev_s *spi)
* bother because it might change. * bother because it might change.
*/ */
#ifdef CONFIG_SPI_OWNBUS
SPI_SETMODE(spi, CONFIG_P14201_SPIMODE); SPI_SETMODE(spi, CONFIG_P14201_SPIMODE);
SPI_SETBITS(spi, 8); SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
#ifdef CONFIG_P14201_FREQUENCY #ifdef CONFIG_P14201_FREQUENCY
(void)SPI_SETFREQUENCY(spi, CONFIG_P14201_FREQUENCY) (void)SPI_SETFREQUENCY(spi, CONFIG_P14201_FREQUENCY)
#endif #endif
#endif
} }
/************************************************************************************** /**************************************************************************************
@@ -483,14 +476,6 @@ static inline void rit_configspi(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void rit_select(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
}
#else
static void rit_select(FAR struct spi_dev_s *spi) static void rit_select(FAR struct spi_dev_s *spi)
{ {
/* Select P14201 chip (locking the SPI bus in case there are multiple /* Select P14201 chip (locking the SPI bus in case there are multiple
@@ -511,7 +496,6 @@ static void rit_select(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, CONFIG_P14201_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_P14201_FREQUENCY);
#endif #endif
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: rit_deselect * Name: rit_deselect
@@ -529,14 +513,6 @@ static void rit_select(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void rit_deselect(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just de-select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
}
#else
static void rit_deselect(FAR struct spi_dev_s *spi) static void rit_deselect(FAR struct spi_dev_s *spi)
{ {
/* De-select P14201 chip and relinquish the SPI bus. */ /* De-select P14201 chip and relinquish the SPI bus. */
@@ -544,7 +520,6 @@ static void rit_deselect(FAR struct spi_dev_s *spi)
SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_SELECT(spi, SPIDEV_DISPLAY, false);
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: rit_sndbytes * Name: rit_sndbytes
-3
View File
@@ -258,10 +258,7 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len)
#ifdef CONFIG_LCD_SSD1306_SPI #ifdef CONFIG_LCD_SSD1306_SPI
void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs); void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs);
void ssd1306_cmddata(FAR struct ssd1306_dev_s *priv, bool cmd); void ssd1306_cmddata(FAR struct ssd1306_dev_s *priv, bool cmd);
#ifndef CONFIG_SPI_OWNBUS
static inline void ssd1306_configspi(FAR struct spi_dev_s *spi) static inline void ssd1306_configspi(FAR struct spi_dev_s *spi)
#endif
#else #else
# define ssd1306_select(priv, cs) # define ssd1306_select(priv, cs)
-14
View File
@@ -818,23 +818,9 @@ FAR struct lcd_dev_s *ssd1306_initialize(FAR struct i2c_dev_s *dev, unsigned int
#ifdef CONFIG_LCD_SSD1306_SPI #ifdef CONFIG_LCD_SSD1306_SPI
priv->spi = dev; priv->spi = dev;
/* If this SPI bus is not shared, then we can config it now.
* If it is shared, then other device could change our config,
* then just configure before sending data.
*/
# ifdef CONFIG_SPI_OWNBUS
/* Configure SPI */
SPI_SETMODE(priv->spi, CONFIG_SSD1306_SPIMODE);
SPI_SETBITS(priv->spi, 8);
(void)SPI_HWFEATURES(priv->spi, 0);
(void)SPI_SETFREQUENCY(priv->spi, CONFIG_SSD1306_FREQUENCY);
# else
/* Configure the SPI */ /* Configure the SPI */
ssd1306_configspi(priv->spi); ssd1306_configspi(priv->spi);
# endif
#else #else
/* Remember the I2C configuration */ /* Remember the I2C configuration */
-6
View File
@@ -61,7 +61,6 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void ssd1306_configspi(FAR struct spi_dev_s *spi) static inline void ssd1306_configspi(FAR struct spi_dev_s *spi)
{ {
lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n", lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n",
@@ -74,7 +73,6 @@ static inline void ssd1306_configspi(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_SSD1306_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1306_FREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -124,7 +122,6 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len)
void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs) void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs)
{ {
#ifndef CONFIG_SPI_OWNBUS
/* If we are selecting the device */ /* If we are selecting the device */
if (cs == true) if (cs == true)
@@ -134,13 +131,11 @@ void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs)
(void)SPI_LOCK(priv->spi, true); (void)SPI_LOCK(priv->spi, true);
ssd1306_configspi(priv->spi); ssd1306_configspi(priv->spi);
} }
#endif
/* Select/deselect SPI device */ /* Select/deselect SPI device */
SPI_SELECT(priv->spi, SPIDEV_DISPLAY, cs); SPI_SELECT(priv->spi, SPIDEV_DISPLAY, cs);
#ifndef CONFIG_SPI_OWNBUS
/* If we are deselecting the device */ /* If we are deselecting the device */
if (cs == false) if (cs == false)
@@ -149,7 +144,6 @@ void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs)
(void)SPI_LOCK(priv->spi, false); (void)SPI_LOCK(priv->spi, false);
} }
#endif
} }
/**************************************************************************** /****************************************************************************
-15
View File
@@ -507,12 +507,10 @@ static void ssd1351_select(FAR struct ssd1351_dev_s *priv)
* have gotten configured for a different device while unlocked) * have gotten configured for a different device while unlocked)
*/ */
#ifndef CONFIG_SPI_OWNBUS
SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE); SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE);
SPI_SETBITS(spi, SSD1351_SPIBITS); SPI_SETBITS(spi, SSD1351_SPIBITS);
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ); (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ);
#endif
} }
#endif #endif
@@ -1189,19 +1187,6 @@ FAR struct lcd_dev_s *ssd1351_initialize(FAR struct spi_dev_s *spi,
#endif #endif
priv->power = LCD_FULL_OFF; priv->power = LCD_FULL_OFF;
/* Configure the SPI bus if we own it. Otherwise, don't bother because
* it might change.
*/
#if defined(CONFIG_SSD1351_SPI3WIRE) || defined(CONFIG_SSD1351_SPI4WIRE)
#ifdef CONFIG_SPI_OWNBUS
SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE);
SPI_SETBITS(spi, SSD1351_SPIBITS);
(void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ);
#endif
#endif
/* Configure the device */ /* Configure the device */
ssd1351_hwinitialize(priv); ssd1351_hwinitialize(priv);
-23
View File
@@ -246,13 +246,8 @@ struct st7567_dev_s
/* SPI helpers */ /* SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void st7567_select(FAR struct spi_dev_s *spi);
static inline void st7567_deselect(FAR struct spi_dev_s *spi);
#else
static void st7567_select(FAR struct spi_dev_s *spi); static void st7567_select(FAR struct spi_dev_s *spi);
static void st7567_deselect(FAR struct spi_dev_s *spi); static void st7567_deselect(FAR struct spi_dev_s *spi);
#endif
/* LCD Data Transfer Methods */ /* LCD Data Transfer Methods */
@@ -371,14 +366,6 @@ static struct st7567_dev_s g_st7567dev =
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void st7567_select(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
}
#else
static void st7567_select(FAR struct spi_dev_s *spi) static void st7567_select(FAR struct spi_dev_s *spi)
{ {
/* Select ST7567 chip (locking the SPI bus in case there are multiple /* Select ST7567 chip (locking the SPI bus in case there are multiple
@@ -399,7 +386,6 @@ static void st7567_select(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, CONFIG_ST7567_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_ST7567_FREQUENCY);
#endif #endif
} }
#endif
/************************************************************************************** /**************************************************************************************
* Function: st7567_deselect * Function: st7567_deselect
@@ -417,14 +403,6 @@ static void st7567_select(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void st7567_deselect(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just de-select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
}
#else
static void st7567_deselect(FAR struct spi_dev_s *spi) static void st7567_deselect(FAR struct spi_dev_s *spi)
{ {
/* De-select ST7567 chip and relinquish the SPI bus. */ /* De-select ST7567 chip and relinquish the SPI bus. */
@@ -432,7 +410,6 @@ static void st7567_deselect(FAR struct spi_dev_s *spi)
SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_SELECT(spi, SPIDEV_DISPLAY, false);
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: st7567_putrun * Name: st7567_putrun
-48
View File
@@ -301,15 +301,8 @@ struct ug2864ambag01_dev_s
/* Low-level SPI helpers */ /* Low-level SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi);
# define ug2864ambag01_lock(spi)
# define ug2864ambag01_unlock(spi)
#else
# define ug2864ambag01_configspi(spi)
static void ug2864ambag01_lock(FAR struct spi_dev_s *spi); static void ug2864ambag01_lock(FAR struct spi_dev_s *spi);
static void ug2864ambag01_unlock(FAR struct spi_dev_s *spi); static void ug2864ambag01_unlock(FAR struct spi_dev_s *spi);
#endif
/* LCD Data Transfer Methods */ /* LCD Data Transfer Methods */
@@ -408,39 +401,6 @@ static struct ug2864ambag01_dev_s g_oleddev =
* Private Functions * Private Functions
**************************************************************************************/ **************************************************************************************/
/**************************************************************************************
* Name: ug2864ambag01_configspi
*
* Description:
* Configure the SPI for use with the UG-2864AMBAG01
*
* Input Parameters:
* spi - Reference to the SPI driver structure
*
* Returned Value:
* None
*
* Assumptions:
*
**************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi)
{
lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n",
CONFIG_UG2864AMBAG01_SPIMODE, CONFIG_UG2864AMBAG01_FREQUENCY);
/* Configure SPI for the UG-2864AMBAG01. But only if we own the SPI bus. Otherwise,
* don't bother because it might change.
*/
SPI_SETMODE(spi, CONFIG_UG2864AMBAG01_SPIMODE);
SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY);
}
#endif
/************************************************************************************** /**************************************************************************************
* Name: ug2864ambag01_lock * Name: ug2864ambag01_lock
* *
@@ -457,7 +417,6 @@ static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi)
{ {
/* Lock the SPI bus if there are multiple devices competing for the SPI bus. */ /* Lock the SPI bus if there are multiple devices competing for the SPI bus. */
@@ -473,7 +432,6 @@ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: ug2864ambag01_unlock * Name: ug2864ambag01_unlock
@@ -491,14 +449,12 @@ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi) static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi)
{ {
/* De-select UG-2864AMBAG01 chip and relinquish the SPI bus. */ /* De-select UG-2864AMBAG01 chip and relinquish the SPI bus. */
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: ug2864ambag01_putrun * Name: ug2864ambag01_putrun
@@ -1080,10 +1036,6 @@ FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, unsign
priv->spi = spi; priv->spi = spi;
/* Configure the SPI */
ug2864ambag01_configspi(spi);
/* Lock and select device */ /* Lock and select device */
ug2864ambag01_lock(priv->spi); ug2864ambag01_lock(priv->spi);
-23
View File
@@ -261,13 +261,8 @@ struct ug_dev_s
/* SPI helpers */ /* SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void ug_select(FAR struct spi_dev_s *spi);
static inline void ug_deselect(FAR struct spi_dev_s *spi);
#else
static void ug_select(FAR struct spi_dev_s *spi); static void ug_select(FAR struct spi_dev_s *spi);
static void ug_deselect(FAR struct spi_dev_s *spi); static void ug_deselect(FAR struct spi_dev_s *spi);
#endif
/* LCD Data Transfer Methods */ /* LCD Data Transfer Methods */
@@ -415,14 +410,6 @@ static inline FAR const char *ug_powerstring(uint8_t power)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void ug_select(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, true);
}
#else
static void ug_select(FAR struct spi_dev_s *spi) static void ug_select(FAR struct spi_dev_s *spi)
{ {
/* Select UG-9664HSWAG01 chip (locking the SPI bus in case there are multiple /* Select UG-9664HSWAG01 chip (locking the SPI bus in case there are multiple
@@ -443,7 +430,6 @@ static void ug_select(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, CONFIG_UG9664HSWAG01_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_UG9664HSWAG01_FREQUENCY);
#endif #endif
} }
#endif
/************************************************************************************** /**************************************************************************************
* Function: ug_deselect * Function: ug_deselect
@@ -461,14 +447,6 @@ static void ug_select(FAR struct spi_dev_s *spi)
* *
**************************************************************************************/ **************************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void ug_deselect(FAR struct spi_dev_s *spi)
{
/* We own the SPI bus, so just de-select the chip */
SPI_SELECT(spi, SPIDEV_DISPLAY, false);
}
#else
static void ug_deselect(FAR struct spi_dev_s *spi) static void ug_deselect(FAR struct spi_dev_s *spi)
{ {
/* De-select UG-9664HSWAG01 chip and relinquish the SPI bus. */ /* De-select UG-9664HSWAG01 chip and relinquish the SPI bus. */
@@ -476,7 +454,6 @@ static void ug_deselect(FAR struct spi_dev_s *spi)
SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_SELECT(spi, SPIDEV_DISPLAY, false);
SPI_LOCK(spi, false); SPI_LOCK(spi, false);
} }
#endif
/************************************************************************************** /**************************************************************************************
* Name: ug_putrun * Name: ug_putrun
+1 -40
View File
@@ -158,9 +158,7 @@ struct mmcsd_slot_s
uint32_t twrite; /* Card write time */ uint32_t twrite; /* Card write time */
uint32_t ocr; /* Last 4 bytes of OCR (R3) */ uint32_t ocr; /* Last 4 bytes of OCR (R3) */
uint32_t r7; /* Last 4 bytes of R7 */ uint32_t r7; /* Last 4 bytes of R7 */
#ifndef CONFIG_SPI_OWNBUS
uint32_t spispeed; /* Speed to use for SPI in data mode */ uint32_t spispeed; /* Speed to use for SPI in data mode */
#endif
}; };
struct mmcsd_cmdinfo_s struct mmcsd_cmdinfo_s
@@ -181,12 +179,6 @@ static void mmcsd_semgive(FAR struct mmcsd_slot_s *slot);
/* Card SPI interface *******************************************************/ /* Card SPI interface *******************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void mmcsd_spiinit(FAR struct mmcsd_slot_s *slot);
#else
# define mmcsd_spiinit(slot)
#endif
static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot); static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot);
static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot,
const struct mmcsd_cmdinfo_s *cmd, uint32_t arg); const struct mmcsd_cmdinfo_s *cmd, uint32_t arg);
@@ -358,7 +350,6 @@ static void mmcsd_semtake(FAR struct mmcsd_slot_s *slot)
{ {
/* Get exclusive access to the SPI bus (if necessary) */ /* Get exclusive access to the SPI bus (if necessary) */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(slot->spi, true); (void)SPI_LOCK(slot->spi, true);
/* Set the frequency, bit width and mode, as some other driver could have /* Set the frequency, bit width and mode, as some other driver could have
@@ -369,7 +360,6 @@ static void mmcsd_semtake(FAR struct mmcsd_slot_s *slot)
SPI_SETBITS(slot->spi, 8); SPI_SETBITS(slot->spi, 8);
(void)SPI_HWFEATURES(slot->spi, 0); (void)SPI_HWFEATURES(slot->spi, 0);
(void)SPI_SETFREQUENCY(slot->spi, slot->spispeed); (void)SPI_SETFREQUENCY(slot->spi, slot->spispeed);
#endif
/* Get exclusive access to the MMC/SD device (possibly unnecessary if /* Get exclusive access to the MMC/SD device (possibly unnecessary if
* SPI_LOCK is also implemented as a semaphore). * SPI_LOCK is also implemented as a semaphore).
@@ -397,7 +387,6 @@ static void mmcsd_semgive(FAR struct mmcsd_slot_s *slot)
/* Relinquish the lock on the SPI bus */ /* Relinquish the lock on the SPI bus */
#ifndef CONFIG_SPI_OWNBUS
/* The card may need up to 8 SCLK cycles to sample the CS status /* The card may need up to 8 SCLK cycles to sample the CS status
* and release the MISO line. * and release the MISO line.
*/ */
@@ -407,29 +396,8 @@ static void mmcsd_semgive(FAR struct mmcsd_slot_s *slot)
/* Relinquish exclusive access to the SPI bus */ /* Relinquish exclusive access to the SPI bus */
(void)SPI_LOCK(slot->spi, false); (void)SPI_LOCK(slot->spi, false);
#endif
} }
/****************************************************************************
* Name: mmcsd_spiinit
*
* Description:
* Set SPI mode and data width.
*
* Assumptions:
* MMC/SD card already selected
*
****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void mmcsd_spiinit(FAR struct mmcsd_slot_s *slot)
{
SPI_SETMODE(slot->spi, CONFIG_MMCSD_SPIMODE);
SPI_SETBITS(slot->spi, 8);
(void)SPI_HWFEATURES(slot->spi, 0);
}
#endif
/**************************************************************************** /****************************************************************************
* Name: mmcsd_waitready * Name: mmcsd_waitready
* *
@@ -738,9 +706,7 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd)
/* Set the actual SPI frequency as close as possible to the max frequency */ /* Set the actual SPI frequency as close as possible to the max frequency */
#ifndef CONFIG_SPI_OWNBUS
slot->spispeed = frequency; slot->spispeed = frequency;
#endif
frequency = SPI_SETFREQUENCY(spi, frequency); frequency = SPI_SETFREQUENCY(spi, frequency);
/* Now determine the delay to access data */ /* Now determine the delay to access data */
@@ -1607,9 +1573,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
/* Clock Freq. Identification Mode < 400kHz */ /* Clock Freq. Identification Mode < 400kHz */
#ifndef CONFIG_SPI_OWNBUS
slot->spispeed = MMCSD_IDMODE_CLOCK; slot->spispeed = MMCSD_IDMODE_CLOCK;
#endif
(void)SPI_SETFREQUENCY(spi, MMCSD_IDMODE_CLOCK); (void)SPI_SETFREQUENCY(spi, MMCSD_IDMODE_CLOCK);
/* Set the maximum access time out */ /* Set the maximum access time out */
@@ -1974,17 +1938,14 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi)
/* Bind the SPI port to the slot */ /* Bind the SPI port to the slot */
slot->spi = spi; slot->spi = spi;
#ifndef CONFIG_SPI_OWNBUS
slot->spispeed = MMCSD_IDMODE_CLOCK; slot->spispeed = MMCSD_IDMODE_CLOCK;
#endif
/* Get exclusive access to the SPI bus and make sure that SPI is properly /* Get exclusive access to the SPI bus and make sure that SPI is properly
* configured for the MMC/SD card * configured for the MMC/SD card
*/ */
mmcsd_semtake(slot); mmcsd_semtake(slot);
mmcsd_spiinit(slot);
/* Initialize for the media in the slot (if any) */ /* Initialize for the media in the slot (if any) */
-29
View File
@@ -256,34 +256,6 @@ static void at25_waitwritecomplete(struct at25_dev_s *priv)
{ {
uint8_t status; uint8_t status;
/* Are we the only device on the bus? */
#ifdef CONFIG_SPI_OWNBUS
/* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */
(void)SPI_SEND(priv->dev, AT25_RDSR);
/* Loop as long as the memory is busy with a write cycle */
do
{
/* Send a dummy byte to generate the clock needed to shift out the status */
status = SPI_SEND(priv->dev, AT25_DUMMY);
}
while ((status & AT25_SR_BUSY) != 0);
/* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
#else
/* Loop as long as the memory is busy with a write cycle */ /* Loop as long as the memory is busy with a write cycle */
do do
@@ -317,7 +289,6 @@ static void at25_waitwritecomplete(struct at25_dev_s *priv)
} }
} }
while ((status & AT25_SR_BUSY) != 0); while ((status & AT25_SR_BUSY) != 0);
#endif
if (status & AT25_SR_EPE) if (status & AT25_SR_EPE)
{ {
-29
View File
@@ -418,34 +418,6 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv)
{ {
uint8_t status; uint8_t status;
/* Are we the only device on the bus? */
#ifdef CONFIG_SPI_OWNBUS
/* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */
(void)SPI_SEND(priv->dev, M25P_RDSR);
/* Loop as long as the memory is busy with a write cycle */
do
{
/* Send a dummy byte to generate the clock needed to shift out the status */
status = SPI_SEND(priv->dev, M25P_DUMMY);
}
while ((status & M25P_SR_WIP) != 0);
/* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
#else
/* Loop as long as the memory is busy with a write cycle */ /* Loop as long as the memory is busy with a write cycle */
do do
@@ -479,7 +451,6 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv)
} }
} }
while ((status & M25P_SR_WIP) != 0); while ((status & M25P_SR_WIP) != 0);
#endif
fvdbg("Complete\n"); fvdbg("Complete\n");
} }
-29
View File
@@ -396,34 +396,6 @@ static uint8_t sst25_waitwritecomplete(struct sst25_dev_s *priv)
{ {
uint8_t status; uint8_t status;
/* Are we the only device on the bus? */
#ifdef CONFIG_SPI_OWNBUS
/* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */
(void)SPI_SEND(priv->dev, SST25_RDSR);
/* Loop as long as the memory is busy with a write cycle */
do
{
/* Send a dummy byte to generate the clock needed to shift out the status */
status = SPI_SEND(priv->dev, SST25_DUMMY);
}
while ((status & SST25_SR_BUSY) != 0);
/* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
#else
/* Loop as long as the memory is busy with a write cycle */ /* Loop as long as the memory is busy with a write cycle */
do do
@@ -459,7 +431,6 @@ static uint8_t sst25_waitwritecomplete(struct sst25_dev_s *priv)
#endif #endif
} }
while ((status & SST25_SR_BUSY) != 0); while ((status & SST25_SR_BUSY) != 0);
#endif
return status; return status;
} }
+2 -30
View File
@@ -315,36 +315,10 @@ static void sst25xx_waitwritecomplete(struct sst25xx_dev_s *priv)
#if 0 #if 0
if (!priv->lastwaswrite) if (!priv->lastwaswrite)
return;
#endif
/* Are we the only device on the bus? */
#ifdef CONFIG_SPI_OWNBUS
/* Select this FLASH part */
SPI_SELECT(priv->dev, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */
(void)SPI_SEND(priv->dev, SST25_RDSR);
/* Loop as long as the memory is busy with a write cycle */
do
{ {
/* Send a dummy byte to generate the clock needed to shift out the status */ return;
status = SPI_SEND(priv->dev, SST25_DUMMY);
} }
while ((status & SST25_SR_WIP) != 0); #endif
/* Deselect the FLASH */
SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
#else
/* Loop as long as the memory is busy with a write cycle */ /* Loop as long as the memory is busy with a write cycle */
@@ -380,8 +354,6 @@ static void sst25xx_waitwritecomplete(struct sst25xx_dev_s *priv)
} }
while ((status & SST25_SR_WIP) != 0); while ((status & SST25_SR_WIP) != 0);
#endif
priv->lastwaswrite = false; priv->lastwaswrite = false;
fvdbg("Complete\n"); fvdbg("Complete\n");
-29
View File
@@ -472,34 +472,6 @@ static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv)
{ {
uint8_t status; uint8_t status;
/* Are we the only device on the bus? */
#ifdef CONFIG_SPI_OWNBUS
/* Select this FLASH part */
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
/* Send "Read Status Register (RDSR)" command */
(void)SPI_SEND(priv->spi, W25_RDSR);
/* Loop as long as the memory is busy with a write cycle */
do
{
/* Send a dummy byte to generate the clock needed to shift out the status */
status = SPI_SEND(priv->spi, W25_DUMMY);
}
while ((status & W25_SR_BUSY) != 0);
/* Deselect the FLASH */
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
#else
/* Loop as long as the memory is busy with a write cycle */ /* Loop as long as the memory is busy with a write cycle */
do do
@@ -535,7 +507,6 @@ static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv)
#endif #endif
} }
while ((status & W25_SR_BUSY) != 0); while ((status & W25_SR_BUSY) != 0);
#endif
return status; return status;
} }
+1 -15
View File
@@ -270,15 +270,9 @@ static struct enc_driver_s g_enc28j60[CONFIG_ENC28J60_NINTERFACES];
/* Low-level SPI helpers */ /* Low-level SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void enc_configspi(FAR struct spi_dev_s *spi); static inline void enc_configspi(FAR struct spi_dev_s *spi);
# define enc_lock(priv);
# define enc_unlock(priv);
#else
# define enc_configspi(spi)
static void enc_lock(FAR struct enc_driver_s *priv); static void enc_lock(FAR struct enc_driver_s *priv);
static inline void enc_unlock(FAR struct enc_driver_s *priv); static inline void enc_unlock(FAR struct enc_driver_s *priv);
#endif
/* SPI control register access */ /* SPI control register access */
@@ -372,19 +366,15 @@ static int enc_reset(FAR struct enc_driver_s *priv);
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void enc_configspi(FAR struct spi_dev_s *spi) static inline void enc_configspi(FAR struct spi_dev_s *spi)
{ {
/* Configure SPI for the ENC28J60. But only if we own the SPI bus. /* Configure SPI for the ENC28J60. */
* Otherwise, don't bother because it might change.
*/
SPI_SETMODE(spi, CONFIG_ENC28J60_SPIMODE); SPI_SETMODE(spi, CONFIG_ENC28J60_SPIMODE);
SPI_SETBITS(spi, 8); SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_ENC28J60_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_ENC28J60_FREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: enc_lock * Function: enc_lock
@@ -402,7 +392,6 @@ static inline void enc_configspi(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void enc_lock(FAR struct enc_driver_s *priv) static void enc_lock(FAR struct enc_driver_s *priv)
{ {
/* Lock the SPI bus in case there are multiple devices competing for the SPI /* Lock the SPI bus in case there are multiple devices competing for the SPI
@@ -420,7 +409,6 @@ static void enc_lock(FAR struct enc_driver_s *priv)
(void)SPI_HWFEATURES(priv->spi, 0); (void)SPI_HWFEATURES(priv->spi, 0);
(void)SPI_SETFREQUENCY(priv->spi, CONFIG_ENC28J60_FREQUENCY); (void)SPI_SETFREQUENCY(priv->spi, CONFIG_ENC28J60_FREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: enc_unlock * Function: enc_unlock
@@ -438,14 +426,12 @@ static void enc_lock(FAR struct enc_driver_s *priv)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void enc_unlock(FAR struct enc_driver_s *priv) static inline void enc_unlock(FAR struct enc_driver_s *priv)
{ {
/* Relinquish the lock on the bus. */ /* Relinquish the lock on the bus. */
SPI_LOCK(priv->spi, false); SPI_LOCK(priv->spi, false);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: enc_rdgreg2 * Function: enc_rdgreg2
+1 -15
View File
@@ -285,15 +285,9 @@ static struct enc_driver_s g_encx24j600[CONFIG_ENCX24J600_NINTERFACES];
/* Low-level SPI helpers */ /* Low-level SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void enc_configspi(FAR struct spi_dev_s *spi); static inline void enc_configspi(FAR struct spi_dev_s *spi);
# define enc_lock(priv);
# define enc_unlock(priv);
#else
# define enc_configspi(spi)
static void enc_lock(FAR struct enc_driver_s *priv); static void enc_lock(FAR struct enc_driver_s *priv);
static inline void enc_unlock(FAR struct enc_driver_s *priv); static inline void enc_unlock(FAR struct enc_driver_s *priv);
#endif
/* SPI control register access */ /* SPI control register access */
@@ -395,19 +389,15 @@ static int enc_reset(FAR struct enc_driver_s *priv);
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void enc_configspi(FAR struct spi_dev_s *spi) static inline void enc_configspi(FAR struct spi_dev_s *spi)
{ {
/* Configure SPI for the ENCX24J600. But only if we own the SPI bus. /* Configure SPI for the ENCX24J600. */
* Otherwise, don't bother because it might change.
*/
SPI_SETMODE(spi, CONFIG_ENCX24J600_SPIMODE); SPI_SETMODE(spi, CONFIG_ENCX24J600_SPIMODE);
SPI_SETBITS(spi, 8); SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_ENCX24J600_FREQUENCY); (void)SPI_SETFREQUENCY(spi, CONFIG_ENCX24J600_FREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: enc_lock * Function: enc_lock
@@ -425,7 +415,6 @@ static inline void enc_configspi(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void enc_lock(FAR struct enc_driver_s *priv) static void enc_lock(FAR struct enc_driver_s *priv)
{ {
/* Lock the SPI bus in case there are multiple devices competing for the SPI /* Lock the SPI bus in case there are multiple devices competing for the SPI
@@ -443,7 +432,6 @@ static void enc_lock(FAR struct enc_driver_s *priv)
(void)SPI_HWFEATURES(priv->spi, 0); (void)SPI_HWFEATURES(priv->spi, 0);
(void)SPI_SETFREQUENCY(priv->spi, CONFIG_ENCX24J600_FREQUENCY); (void)SPI_SETFREQUENCY(priv->spi, CONFIG_ENCX24J600_FREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: enc_unlock * Function: enc_unlock
@@ -461,14 +449,12 @@ static void enc_lock(FAR struct enc_driver_s *priv)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void enc_unlock(FAR struct enc_driver_s *priv) static inline void enc_unlock(FAR struct enc_driver_s *priv)
{ {
/* Relinquish the lock on the bus. */ /* Relinquish the lock on the bus. */
SPI_LOCK(priv->spi, false); SPI_LOCK(priv->spi, false);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: enc_cmd * Function: enc_cmd
-14
View File
@@ -409,20 +409,6 @@ ADXL345_HANDLE adxl345_instantiate(FAR struct i2c_dev_s *dev,
#ifdef CONFIG_ADXL345_SPI #ifdef CONFIG_ADXL345_SPI
priv->spi = dev; priv->spi = dev;
/* If this SPI bus is not shared, then we can config it now.
* If it is shared, then other device could change our config,
* then just configure before sending data.
*/
#ifdef CONFIG_SPI_OWNBUS
/* Configure SPI for the ADXL345 */
SPI_SETMODE(priv->spi, SPIDEV_MODE3);
SPI_SETBITS(priv->spi, 8);
(void)SPI_HWFEATURES(priv->spi, 0);
(void)SPI_SETFREQUENCY(priv->spi, ADXL345_SPI_MAXFREQUENCY);
#endif
#else #else
priv->i2c = dev; priv->i2c = dev;
+1 -14
View File
@@ -64,7 +64,6 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void adxl345_configspi(FAR struct spi_dev_s *spi) static inline void adxl345_configspi(FAR struct spi_dev_s *spi)
{ {
/* Configure SPI for the ADXL345 */ /* Configure SPI for the ADXL345 */
@@ -74,7 +73,6 @@ static inline void adxl345_configspi(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, ADXL345_SPI_MAXFREQUENCY); (void)SPI_SETFREQUENCY(spi, ADXL345_SPI_MAXFREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -94,10 +92,8 @@ uint8_t adxl345_getreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr)
/* If SPI bus is shared then lock and configure it */ /* If SPI bus is shared then lock and configure it */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, true); (void)SPI_LOCK(priv->spi, true);
adxl345_configspi(priv->spi); adxl345_configspi(priv->spi);
#endif
/* Select the ADXL345 */ /* Select the ADXL345 */
@@ -114,9 +110,7 @@ uint8_t adxl345_getreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr)
/* Unlock bus */ /* Unlock bus */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, false); (void)SPI_LOCK(priv->spi, false);
#endif
#ifdef CONFIG_ADXL345_REGDEBUG #ifdef CONFIG_ADXL345_REGDEBUG
dbg("%02x->%02x\n", regaddr, regval); dbg("%02x->%02x\n", regaddr, regval);
@@ -141,10 +135,8 @@ void adxl345_putreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr,
/* If SPI bus is shared then lock and configure it */ /* If SPI bus is shared then lock and configure it */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, true); (void)SPI_LOCK(priv->spi, true);
adxl345_configspi(priv->spi); adxl345_configspi(priv->spi);
#endif
/* Select the ADXL345 */ /* Select the ADXL345 */
@@ -160,9 +152,8 @@ void adxl345_putreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr,
SPI_SELECT(priv->spi, SPIDEV_ACCELEROMETER, false); SPI_SELECT(priv->spi, SPIDEV_ACCELEROMETER, false);
/* Unlock bus */ /* Unlock bus */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, false); (void)SPI_LOCK(priv->spi, false);
#endif
} }
/**************************************************************************** /****************************************************************************
@@ -179,10 +170,8 @@ uint16_t adxl345_getreg16(FAR struct adxl345_dev_s *priv, uint8_t regaddr)
/* If SPI bus is shared then lock and configure it */ /* If SPI bus is shared then lock and configure it */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, true); (void)SPI_LOCK(priv->spi, true);
adxl345_configspi(priv->spi); adxl345_configspi(priv->spi);
#endif
/* Select the ADXL345 */ /* Select the ADXL345 */
@@ -199,9 +188,7 @@ uint16_t adxl345_getreg16(FAR struct adxl345_dev_s *priv, uint8_t regaddr)
/* Unlock bus */ /* Unlock bus */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, false); (void)SPI_LOCK(priv->spi, false);
#endif
#ifdef CONFIG_ADXL345_REGDEBUG #ifdef CONFIG_ADXL345_REGDEBUG
dbg("%02x->%04x\n", regaddr, regval); dbg("%02x->%04x\n", regaddr, regval);
-9
View File
@@ -279,15 +279,6 @@ int max31855_register(FAR const char *devpath, FAR struct spi_dev_s *spi)
priv->spi = spi; priv->spi = spi;
priv->temp = 0; priv->temp = 0;
#ifdef CONFIG_SPI_OWNBUS
/* Configure SPI for the MAX31855 */
SPI_SETMODE(priv->spi, SPIDEV_MODE1);
SPI_SETBITS(priv->spi, 8);
(void)SPI_HWFEATURES(priv->spi, 0);
(void)SPI_SETFREQUENCY(priv->spi, MAX31855_SPI_MAXFREQ);
#endif
/* Register the character driver */ /* Register the character driver */
ret = register_driver(devpath, &g_max31855fops, 0666, priv); ret = register_driver(devpath, &g_max31855fops, 0666, priv);
-9
View File
@@ -256,15 +256,6 @@ int max6675_register(FAR const char *devpath, FAR struct spi_dev_s *spi)
priv->spi = spi; priv->spi = spi;
priv->temp = 0; priv->temp = 0;
#ifdef CONFIG_SPI_OWNBUS
/* Configure SPI for the MAX6675 */
SPI_SETMODE(priv->spi, SPIDEV_MODE1);
SPI_SETBITS(priv->spi, 8);
(void)SPI_HWFEATURES(priv->spi, 0);
(void)SPI_SETFREQUENCY(priv->spi, MAX6675_SPI_MAXFREQ);
#endif
/* Register the character driver */ /* Register the character driver */
ret = register_driver(devpath, &g_max6675fops, 0666, priv); ret = register_driver(devpath, &g_max6675fops, 0666, priv);
-6
View File
@@ -112,7 +112,6 @@ static const struct file_operations g_mpl115afops =
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static inline void mpl115a_configspi(FAR struct spi_dev_s *spi) static inline void mpl115a_configspi(FAR struct spi_dev_s *spi)
{ {
/* Configure SPI for the MPL115A */ /* Configure SPI for the MPL115A */
@@ -122,7 +121,6 @@ static inline void mpl115a_configspi(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, MPL115A_SPI_MAXFREQUENCY); (void)SPI_SETFREQUENCY(spi, MPL115A_SPI_MAXFREQUENCY);
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: mpl115a_getreg8 * Name: mpl115a_getreg8
@@ -138,10 +136,8 @@ static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv, uint8_t regaddr)
/* If SPI bus is shared then lock and configure it */ /* If SPI bus is shared then lock and configure it */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, true); (void)SPI_LOCK(priv->spi, true);
mpl115a_configspi(priv->spi); mpl115a_configspi(priv->spi);
#endif
/* Select the MPL115A */ /* Select the MPL115A */
@@ -158,9 +154,7 @@ static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv, uint8_t regaddr)
/* Unlock bus */ /* Unlock bus */
#ifndef CONFIG_SPI_OWNBUS
(void)SPI_LOCK(priv->spi, false); (void)SPI_LOCK(priv->spi, false);
#endif
#ifdef CONFIG_MPL115A_REGDEBUG #ifdef CONFIG_MPL115A_REGDEBUG
dbg("%02x->%02x\n", regaddr, regval); dbg("%02x->%02x\n", regaddr, regval);
-8
View File
@@ -22,14 +22,6 @@ config SPI_SLAVE_DMA
endif endif
config SPI_OWNBUS
bool "SPI single device"
default n
---help---
Set if there is only one active device on the SPI bus. No locking or
SPI configuration will be performed. It is not necessary for clients to
lock, re-configure, etc.
config SPI_EXCHANGE config SPI_EXCHANGE
bool "SPI exchange" bool "SPI exchange"
default y default y
-6
View File
@@ -110,9 +110,7 @@
/* SPI methods */ /* SPI methods */
#ifndef CONFIG_SPI_OWNBUS
static int spi_lock(FAR struct spi_dev_s *dev, bool lock); static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
#endif
static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
bool selected); bool selected);
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev,
@@ -144,9 +142,7 @@ static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
static const struct spi_ops_s g_spiops = static const struct spi_ops_s g_spiops =
{ {
#ifndef CONFIG_SPI_OWNBUS
spi_lock, /* lock */ spi_lock, /* lock */
#endif
spi_select, /* select */ spi_select, /* select */
spi_setfrequency, /* setfrequency */ spi_setfrequency, /* setfrequency */
spi_setmode, /* setmode */ spi_setmode, /* setmode */
@@ -193,7 +189,6 @@ static const struct spi_ops_s g_spiops =
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static int spi_lock(FAR struct spi_dev_s *dev, bool lock) static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
{ {
FAR struct spi_bitbang_s *priv = (FAR struct spi_bitbang_s *)dev; FAR struct spi_bitbang_s *priv = (FAR struct spi_bitbang_s *)dev;
@@ -219,7 +214,6 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
return OK; return OK;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: spi_select * Name: spi_select
+2 -11
View File
@@ -283,15 +283,9 @@ static inline void cc3000_configspi(FAR struct spi_dev_s *spi)
static void cc3000_lock_and_select(FAR struct spi_dev_s *spi) static void cc3000_lock_and_select(FAR struct spi_dev_s *spi)
{ {
#ifndef CONFIG_SPI_OWNBUS
/* Lock the SPI bus because there are multiple devices competing for the
* SPI bus
*/
/* Lock the SPI bus so that we have exclusive access */ /* Lock the SPI bus so that we have exclusive access */
(void)SPI_LOCK(spi, true); (void)SPI_LOCK(spi, true);
#endif
/* We have the lock. Now make sure that the SPI bus is configured for the /* We have the lock. Now make sure that the SPI bus is configured for the
* CC3000 (it might have gotten configured for a different device while * CC3000 (it might have gotten configured for a different device while
@@ -306,9 +300,8 @@ static void cc3000_lock_and_select(FAR struct spi_dev_s *spi)
* Function: cc3000_unlock * Function: cc3000_unlock
* *
* Description: * Description:
* If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS * Un-lock the SPI bus after each transfer, possibly losing the current
* undefined) then we need to un-lock the SPI bus for each transfer, * configuration if we are sharing the SPI bus with other devices.
* possibly losing the current configuration.
* *
* Parameters: * Parameters:
* spi - Reference to the SPI driver structure * spi - Reference to the SPI driver structure
@@ -326,11 +319,9 @@ static void cc3000_deselect_and_unlock(FAR struct spi_dev_s *spi)
SPI_SELECT(spi, SPIDEV_WIRELESS, false); SPI_SELECT(spi, SPIDEV_WIRELESS, false);
#ifndef CONFIG_SPI_OWNBUS
/* Relinquish the SPI bus. */ /* Relinquish the SPI bus. */
(void)SPI_LOCK(spi, false); (void)SPI_LOCK(spi, false);
#endif
} }
/**************************************************************************** /****************************************************************************
+4 -24
View File
@@ -158,21 +158,13 @@ struct nrf24l01_dev_s
****************************************************************************/ ****************************************************************************/
/* Low-level SPI helpers */ /* Low-level SPI helpers */
#ifdef CONFIG_SPI_OWNBUS
static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi); static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi);
# define nrf24l01_lock(spi)
# define nrf24l01_unlock(spi)
#else
# define nrf24l01_configspi(spi);
static void nrf24l01_lock(FAR struct spi_dev_s *spi); static void nrf24l01_lock(FAR struct spi_dev_s *spi);
static void nrf24l01_unlock(FAR struct spi_dev_s *spi); static void nrf24l01_unlock(FAR struct spi_dev_s *spi);
#endif
static uint8_t nrf24l01_access(FAR struct nrf24l01_dev_s *dev, static uint8_t nrf24l01_access(FAR struct nrf24l01_dev_s *dev,
nrf24l01_access_mode_t mode, uint8_t cmd, uint8_t *buf, int length); nrf24l01_access_mode_t mode, uint8_t cmd, uint8_t *buf, int length);
static uint8_t nrf24l01_flush_rx(FAR struct nrf24l01_dev_s *dev); static uint8_t nrf24l01_flush_rx(FAR struct nrf24l01_dev_s *dev);
static uint8_t nrf24l01_flush_tx(FAR struct nrf24l01_dev_s *dev); static uint8_t nrf24l01_flush_tx(FAR struct nrf24l01_dev_s *dev);
/* Read register from nrf24 */ /* Read register from nrf24 */
@@ -250,7 +242,6 @@ static const struct file_operations nrf24l01_fops =
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void nrf24l01_lock(FAR struct spi_dev_s *spi) static void nrf24l01_lock(FAR struct spi_dev_s *spi)
{ {
/* Lock the SPI bus because there are multiple devices competing for the /* Lock the SPI bus because there are multiple devices competing for the
@@ -271,15 +262,13 @@ static void nrf24l01_lock(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ); (void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ);
SPI_SELECT(spi, SPIDEV_WIRELESS, false); SPI_SELECT(spi, SPIDEV_WIRELESS, false);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: nrf24l01_unlock * Function: nrf24l01_unlock
* *
* Description: * Description:
* If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS * Un-lock the SPI bus after each transfer, possibly losing the current
* undefined) then we need to un-lock the SPI bus for each transfer, * configuration if we are sharing the SPI bus with other devices.
* possibly losing the current configuration.
* *
* Parameters: * Parameters:
* spi - Reference to the SPI driver structure * spi - Reference to the SPI driver structure
@@ -291,23 +280,18 @@ static void nrf24l01_lock(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void nrf24l01_unlock(FAR struct spi_dev_s *spi) static void nrf24l01_unlock(FAR struct spi_dev_s *spi)
{ {
/* Relinquish the SPI bus. */ /* Relinquish the SPI bus. */
(void)SPI_LOCK(spi, false); (void)SPI_LOCK(spi, false);
} }
#endif
/**************************************************************************** /****************************************************************************
* Function: nrf24l01_configspi * Function: nrf24l01_configspi
* *
* Description: * Description:
* Configure the SPI for use with the NRF24L01. This function should be * Configure the SPI for use with the NRF24L01.
* called once during touchscreen initialization to configure the SPI
* bus. Note that if CONFIG_SPI_OWNBUS is not defined, then this function
* does nothing.
* *
* Parameters: * Parameters:
* spi - Reference to the SPI driver structure * spi - Reference to the SPI driver structure
@@ -319,12 +303,9 @@ static void nrf24l01_unlock(FAR struct spi_dev_s *spi)
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi) static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi)
{ {
/* Configure SPI for the NRF24L01 module. /* Configure SPI for the NRF24L01 module. */
* As we own the SPI bus this method is called just once.
*/
SPI_SELECT(spi, SPIDEV_WIRELESS, true); /* Useful ? */ SPI_SELECT(spi, SPIDEV_WIRELESS, true); /* Useful ? */
SPI_SETMODE(spi, SPIDEV_MODE0); SPI_SETMODE(spi, SPIDEV_MODE0);
@@ -333,7 +314,6 @@ static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi)
(void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ); (void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ);
SPI_SELECT(spi, SPIDEV_WIRELESS, false); SPI_SELECT(spi, SPIDEV_WIRELESS, false);
} }
#endif
static inline void nrf24l01_select(struct nrf24l01_dev_s * dev) static inline void nrf24l01_select(struct nrf24l01_dev_s * dev)
{ {
-12
View File
@@ -85,15 +85,9 @@
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SPI_OWNBUS
static inline void pn532_configspi(FAR struct spi_dev_s *spi); static inline void pn532_configspi(FAR struct spi_dev_s *spi);
# define pn532_lock(spi)
# define pn532_unlock(spi)
#else
# define pn532_configspi(spi);
static void pn532_lock(FAR struct spi_dev_s *spi); static void pn532_lock(FAR struct spi_dev_s *spi);
static void pn532_unlock(FAR struct spi_dev_s *spi); static void pn532_unlock(FAR struct spi_dev_s *spi);
#endif
/* Character driver methods */ /* Character driver methods */
@@ -143,7 +137,6 @@ static const uint8_t pn532ack[] =
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS
static void pn532_lock(FAR struct spi_dev_s *spi) static void pn532_lock(FAR struct spi_dev_s *spi)
{ {
(void)SPI_LOCK(spi, true); (void)SPI_LOCK(spi, true);
@@ -153,16 +146,12 @@ static void pn532_lock(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ); (void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ);
} }
#endif
#ifndef CONFIG_SPI_OWNBUS
static void pn532_unlock(FAR struct spi_dev_s *spi) static void pn532_unlock(FAR struct spi_dev_s *spi)
{ {
(void)SPI_LOCK(spi, false); (void)SPI_LOCK(spi, false);
} }
#endif
#ifdef CONFIG_SPI_OWNBUS
static inline void pn532_configspi(FAR struct spi_dev_s *spi) static inline void pn532_configspi(FAR struct spi_dev_s *spi)
{ {
/* Configure SPI for the PN532 module. /* Configure SPI for the PN532 module.
@@ -174,7 +163,6 @@ static inline void pn532_configspi(FAR struct spi_dev_s *spi)
(void)SPI_HWFEATURES(spi, 0); (void)SPI_HWFEATURES(spi, 0);
(void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ); (void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ);
} }
#endif
static inline void pn532_select(struct pn532_dev_s *dev) static inline void pn532_select(struct pn532_dev_s *dev)
{ {
-2
View File
@@ -73,8 +73,6 @@
* When SPI_SELECT is called with devid=SPIDEV_MUX. * When SPI_SELECT is called with devid=SPIDEV_MUX.
* *
* Other settings that effect the driver: * Other settings that effect the driver:
* CONFIG_SPI_OWNBUS -- If the PGA117 is enabled, this must be set to 'y'
* if the PGA117 is the only device on the SPI bus;
* CONFIG_DEBUG_SPI -- With CONFIG_DEBUG and CONFIG_DEBUG_VERBOSE, * CONFIG_DEBUG_SPI -- With CONFIG_DEBUG and CONFIG_DEBUG_VERBOSE,
* this will enable debug output from the PGA117 driver. * this will enable debug output from the PGA117 driver.
*/ */
+3 -11
View File
@@ -51,11 +51,9 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* CONFIG_SPI_OWNBUS - Set if there is only one active device on the SPI bus. /* CONFIG_SPI_EXCHANGE - Driver supports a single exchange method
* No locking or SPI configuration will be performed. It is not necessary
* for clients to lock, re-configure, etc..
* CONFIG_SPI_EXCHANGE - Driver supports a single exchange method
* (vs a recvblock() and sndblock ()methods). * (vs a recvblock() and sndblock ()methods).
* CONFIG_SPI_HWFEATURES - Support special, hardware-specific SPI features.
* CONFIG_SPI_CMDDATA - Devices on the SPI bus require out-of-band support * CONFIG_SPI_CMDDATA - Devices on the SPI bus require out-of-band support
* to distinguish command transfers from data transfers. Such devices * to distinguish command transfers from data transfers. Such devices
* will often support either 9-bit SPI (yech) or 8-bit SPI and a GPIO * will often support either 9-bit SPI (yech) or 8-bit SPI and a GPIO
@@ -85,11 +83,7 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_SPI_OWNBUS #define SPI_LOCK(d,l) (d)->ops->lock(d,l)
# define SPI_LOCK(d,l) (d)->ops->lock(d,l)
#else
# define SPI_LOCK(d,l) 0
#endif
/**************************************************************************** /****************************************************************************
* Name: SPI_SELECT * Name: SPI_SELECT
@@ -428,9 +422,7 @@ typedef uint8_t spi_hwfeatures_t;
struct spi_dev_s; struct spi_dev_s;
struct spi_ops_s struct spi_ops_s
{ {
#ifndef CONFIG_SPI_OWNBUS
CODE int (*lock)(FAR struct spi_dev_s *dev, bool lock); CODE int (*lock)(FAR struct spi_dev_s *dev, bool lock);
#endif
CODE void (*select)(FAR struct spi_dev_s *dev, enum spi_dev_e devid, CODE void (*select)(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
bool selected); bool selected);
CODE uint32_t (*setfrequency)(FAR struct spi_dev_s *dev, uint32_t frequency); CODE uint32_t (*setfrequency)(FAR struct spi_dev_s *dev, uint32_t frequency);
-2
View File
@@ -127,9 +127,7 @@ struct spi_bitbang_s
FAR const struct spi_bitbang_ops_s *low; /* Low-level operations */ FAR const struct spi_bitbang_ops_s *low; /* Low-level operations */
uint32_t holdtime; /* SCK hold time to achieve requested frequency */ uint32_t holdtime; /* SCK hold time to achieve requested frequency */
bitexchange_t exchange; /* The select bit exchange function */ bitexchange_t exchange; /* The select bit exchange function */
#ifndef CONFIG_SPI_OWNBUS
sem_t exclsem; /* Supports mutually exclusive access to SPI */ sem_t exclsem; /* Supports mutually exclusive access to SPI */
#endif
#ifdef CONFIG_SPI_BITBANG_VARWIDTH #ifdef CONFIG_SPI_BITBANG_VARWIDTH
uint8_t nbits; /* Number of bits in the transfer */ uint8_t nbits; /* Number of bits in the transfer */
#endif #endif