stm32f4discovery - add mfrc522 rfid support

This commit is contained in:
Felipe Moura 2024-08-23 11:48:26 -03:00 committed by Alan Carvalho de Assis
parent 9769816385
commit 75f81e6e24
3 changed files with 32 additions and 2 deletions

View File

@ -58,6 +58,10 @@
#include "stm32_apds9960.h" #include "stm32_apds9960.h"
#endif #endif
#ifdef CONFIG_CL_MFRC522
#include "stm32_mfrc522.h"
#endif
#include "stm32f4discovery.h" #include "stm32f4discovery.h"
/* Conditional logic in stm32f4discovery.h will determine if certain features /* Conditional logic in stm32f4discovery.h will determine if certain features
@ -609,5 +613,13 @@ int stm32_bringup(void)
usbdev_adb_initialize(); usbdev_adb_initialize();
#endif #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; return ret;
} }

View File

@ -67,9 +67,14 @@ void weak_function stm32_spidev_initialize(void)
stm32_configgpio(GPIO_W5500_INTR); stm32_configgpio(GPIO_W5500_INTR);
#endif #endif
#ifdef CONFIG_STM32_SPI1 #if defined(CONFIG_STM32_SPI1) && defined(CONFIG_SENSORS_LIS3MDL)
stm32_configgpio(GPIO_CS_MEMS); /* MEMS chip select */ stm32_configgpio(GPIO_CS_MEMS); /* MEMS chip select */
#endif #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) #if defined(CONFIG_STM32_SPI2) && defined(CONFIG_SENSORS_MAX31855)
stm32_configgpio(GPIO_MAX31855_CS); /* MAX31855 chip select */ stm32_configgpio(GPIO_MAX31855_CS); /* MAX31855 chip select */
#endif #endif
@ -176,11 +181,21 @@ void stm32_spi1select(struct spi_dev_s *dev, uint32_t devid,
{ {
stm32_gpiowrite(GPIO_OLED_CS, !selected); stm32_gpiowrite(GPIO_OLED_CS, !selected);
} }
else
#endif #endif
#if defined (CONFIG_SENSORS_LIS3MDL)
if (devid == SPIDEV_ACCELEROMETER(0))
{ {
stm32_gpiowrite(GPIO_CS_MEMS, !selected); 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) uint8_t stm32_spi1status(struct spi_dev_s *dev, uint32_t devid)

View File

@ -289,6 +289,9 @@
#define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\ #define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\
GPIO_OPENDRAIN|GPIO_PORTE|GPIO_PIN4) 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 */ /* Use same pins as ENC28J60 to W5500 */
#define GPIO_W5500_CS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ #define GPIO_W5500_CS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\