diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c index 125fecee12..c9dbb99e16 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c @@ -58,6 +58,10 @@ #include "stm32_apds9960.h" #endif +#ifdef CONFIG_CL_MFRC522 +#include "stm32_mfrc522.h" +#endif + #include "stm32f4discovery.h" /* Conditional logic in stm32f4discovery.h will determine if certain features @@ -609,5 +613,13 @@ int stm32_bringup(void) usbdev_adb_initialize(); #endif +#ifdef CONFIG_CL_MFRC522 + ret = stm32_mfrc522initialize("/dev/rfid0"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_mfrc522initialize() failed: %d\n", ret); + } +#endif + return ret; } diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_spi.c b/boards/arm/stm32/stm32f4discovery/src/stm32_spi.c index 6b94c2932d..a4ea656473 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_spi.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_spi.c @@ -67,9 +67,14 @@ void weak_function stm32_spidev_initialize(void) stm32_configgpio(GPIO_W5500_INTR); #endif -#ifdef CONFIG_STM32_SPI1 +#if defined(CONFIG_STM32_SPI1) && defined(CONFIG_SENSORS_LIS3MDL) stm32_configgpio(GPIO_CS_MEMS); /* MEMS chip select */ #endif + +#if defined(CONFIG_STM32_SPI1) && defined(CONFIG_CL_MFRC522) + stm32_configgpio(GPIO_CS_MFRC522); /* MFRC522 chip select */ +#endif + #if defined(CONFIG_STM32_SPI2) && defined(CONFIG_SENSORS_MAX31855) stm32_configgpio(GPIO_MAX31855_CS); /* MAX31855 chip select */ #endif @@ -176,11 +181,21 @@ void stm32_spi1select(struct spi_dev_s *dev, uint32_t devid, { stm32_gpiowrite(GPIO_OLED_CS, !selected); } - else #endif + +#if defined (CONFIG_SENSORS_LIS3MDL) + if (devid == SPIDEV_ACCELEROMETER(0)) { stm32_gpiowrite(GPIO_CS_MEMS, !selected); } +#endif + +#if defined(CONFIG_CL_MFRC522) + if (devid == SPIDEV_CONTACTLESS(0)) + { + stm32_gpiowrite(GPIO_CS_MFRC522, !selected); + } +#endif } uint8_t stm32_spi1status(struct spi_dev_s *dev, uint32_t devid) diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h b/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h index 89048910bb..90803e20e7 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h +++ b/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h @@ -289,6 +289,9 @@ #define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\ GPIO_OPENDRAIN|GPIO_PORTE|GPIO_PIN4) +#define GPIO_CS_MFRC522 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ + GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3) + /* Use same pins as ENC28J60 to W5500 */ #define GPIO_W5500_CS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\