Make bit-order SPI H/W feature configurable for better error detection
This commit is contained in:
parent
c3cfd37791
commit
6df28bc74e
@ -1082,6 +1082,7 @@ static void spi_setbits(struct spi_dev_s *dev, int nbits)
|
||||
#ifdef CONFIG_SPI_HWFEATURES
|
||||
static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
{
|
||||
#ifdef CONFIG_SPI_BITORDER
|
||||
struct efm32_spidev_s *priv = (struct efm32_spidev_s *)dev;
|
||||
const struct efm32_spiconfig_s *config;
|
||||
uint32_t regval;
|
||||
@ -1124,6 +1125,9 @@ static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
/* Other H/W features are not supported */
|
||||
|
||||
return ((features & ~HWFEAT_LSBFIRST) == 0) ? OK : -ENOSYS;
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1221,6 +1221,7 @@ static int spi_setdelay(struct spi_dev_s *dev, uint32_t startdelay,
|
||||
#ifdef CONFIG_SPI_HWFEATURES
|
||||
static int spi_hwfeatures(struct spi_dev_s *dev, uint8_t features)
|
||||
{
|
||||
#ifdef CONFIG_SPI_CS_CONTROL
|
||||
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
|
||||
struct sam_spidev_s *spi = spi_device(spics);
|
||||
uint32_t regval;
|
||||
@ -1280,7 +1281,10 @@ static int spi_hwfeatures(struct spi_dev_s *dev, uint8_t features)
|
||||
spi->escape_lastxfer = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ((features & ~HWFEAT_FORCE_CS_CONTROL_MASK) == 0) ? OK : -ENOSYS;
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1198,6 +1198,7 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
|
||||
#ifdef CONFIG_SPI_HWFEATURES
|
||||
static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
{
|
||||
#ifdef CONFIG_SPI_BITORDER
|
||||
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)dev;
|
||||
uint16_t setbits;
|
||||
uint16_t clrbits;
|
||||
@ -1224,6 +1225,9 @@ static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
/* Other H/W features are not supported */
|
||||
|
||||
return ((features & ~HWFEAT_LSBFIRST) == 0) ? OK : -ENOSYS;
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1301,6 +1301,7 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
|
||||
#ifdef CONFIG_SPI_HWFEATURES
|
||||
static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
{
|
||||
#ifdef CONFIG_SPI_BITORDER
|
||||
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)dev;
|
||||
uint16_t setbitscr1;
|
||||
uint16_t clrbitscr1;
|
||||
@ -1330,6 +1331,9 @@ static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
/* Other H/W features are not supported */
|
||||
|
||||
return ((features & ~HWFEAT_LSBFIRST) == 0) ? OK : -ENOSYS;
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1165,6 +1165,7 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
|
||||
#ifdef CONFIG_SPI_HWFEATURES
|
||||
static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
{
|
||||
#ifdef CONFIG_SPI_BITORDER
|
||||
FAR struct stm32_spidev_s *priv = (FAR struct stm32_spidev_s *)dev;
|
||||
uint16_t setbits;
|
||||
uint16_t clrbits;
|
||||
@ -1191,6 +1192,9 @@ static int spi_hwfeatures(FAR struct spi_dev_s *dev, spi_hwfeatures_t features)
|
||||
/* Other H/W features are not supported */
|
||||
|
||||
return ((features & ~HWFEAT_LSBFIRST) == 0) ? OK : -ENOSYS;
|
||||
#else
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -59,10 +59,12 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* H/W features must be enabled in order to support LSB first operation */
|
||||
/* Bit order H/W feature must be enabled in order to support LSB first
|
||||
* operation.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SPI_HWFEATURES
|
||||
# error CONFIG_SPI_HWFEATURES=y required by this driver
|
||||
#if !defined(CONFIG_SPI_HWFEATURES) || !defined(CONFIG_SPI_BITORDER)
|
||||
# error CONFIG_SPI_HWFEATURES=y and CONFIG_SPI_BITORDER=y required by this driver
|
||||
#endif
|
||||
|
||||
/* Cisplay resolution */
|
||||
|
@ -72,6 +72,14 @@ config SPI_CS_CONTROL
|
||||
Enables possibilities to define the behavior of CS.
|
||||
Also enables the hwfeatures() interface method.
|
||||
|
||||
config SPI_BITORDER
|
||||
bool "SPI Bit Order Control"
|
||||
default n
|
||||
select SPI_HWFEATURES
|
||||
---help---
|
||||
Enables capability to select MSB- or LSB-first hardware feature for
|
||||
data transfers.
|
||||
|
||||
config SPI_CS_DELAY_CONTROL
|
||||
bool "SPI CS Delay Control"
|
||||
default n
|
||||
|
@ -57,10 +57,12 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
/* H/W features must be enabled in order to support LSB first operation */
|
||||
/* Bit order H/W feature must be enabled in order to support LSB first
|
||||
* operation.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SPI_HWFEATURES
|
||||
# error CONFIG_SPI_HWFEATURES=y required by this driver
|
||||
#if !defined(CONFIG_SPI_HWFEATURES) || !defined(CONFIG_SPI_BITORDER)
|
||||
# error CONFIG_SPI_HWFEATURES=y and CONFIG_SPI_BITORDER=y required by this driver
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WL_PN532_DEBUG
|
||||
|
@ -232,13 +232,16 @@
|
||||
# endif
|
||||
|
||||
# ifdef CONFIG_SPI_CS_CONTROL
|
||||
# define HWFEAT_FORCE_CS_CONTROL_MASK (7 << 1)
|
||||
# define HWFEAT_FORCE_CS_INACTIVE_AFTER_TRANSFER (1 << 1)
|
||||
# define HWFEAT_FORCE_CS_ACTIVE_AFTER_TRANSFER (1 << 2)
|
||||
# define HWFEAT_ESCAPE_LASTXFER (1 << 3)
|
||||
# endif
|
||||
|
||||
# define HWFEAT_MSBFIRST (0 << 4)
|
||||
# define HWFEAT_LSBFIRST (1 << 4)
|
||||
# ifdef CONFIG_SPI_BITORDER
|
||||
# define HWFEAT_MSBFIRST (0 << 4)
|
||||
# define HWFEAT_LSBFIRST (1 << 4)
|
||||
# endif
|
||||
|
||||
#else
|
||||
/* Any attempt to select hardware features with CONFIG_SPI_HWFEATURES
|
||||
|
Loading…
Reference in New Issue
Block a user