A C++ STM32Cube library can handle MFRC522(or RC522 RFID module).
- Based on code Dr.Leong ( WWW.B2CQSHOP.COM )
- Created by Miguel Balboa (circuitito.com), Jan, 2012.
- Rewritten by Soren Thing Andersen (access.thing.dk), fall of 2013 (Translation to English, refactored, comments, anti collision, cascade levels.)
- Ported to mbed by Martin Olejar, Dec, 2013 mbed library
- Ported to STM32Cube by _0x4d from Factoryal Laboratory, March, 2022.
This library runs in blocking mode.
SPI instructions are not implemented using IT or DMA and also uses HAL_Delay()
.
Using in ISR is not recommended.
MFRC522(SPI_HandleTypeDef* hspi, GPIO_TypeDef* cs_port, uint32_t cs_pin, GPIO_TypeDef* reset_port, uint32_t reset_pin);
where,
SPI_HandleTypeDef* hspi
: Target SPI peripheral HandleTypeDef pointer.
GPIO_TypeDef* cs_port
: Target GPIO port start address which MFRC522 SPI chip select pin has connected to.
uint32_t cs_pin
: Target GPIO pin address offset which MFRC522 SPI chip select pin has connected to.
GPIO_TypeDef* reset_port
: Target GPIO port start address which MFRC522 reset pin has connected to.
uint32_t reset_pin
: Target GPIO pin address offset which MFRC522 reset pin has connected to.
If MFRC522 SPI bus is connected to SPI1
, chip select pin connected to PA8
, reset pin connected to PB7
,
MFRC522(&hspi1, GPIOA, GPIO_PIN_8, GPIOB, GPIO_PIN_7);
If chip select pin and reset pin has named as MFRC522_CS
, MFRC522_RESET
on STM32Cube and auto-generated by,
MFRC522(&hspi1, MFRC522_CS_GPIO_Port, MFRC522_CS_Pin, MFRC522_RESET_GPIO_Port, MFRC522_RESET_PIN);
All APIs except constructor is identical to mbed library. Please refer to the following link: https://os.mbed.com/users/AtomX/code/MFRC522/docs/tip/classMFRC522.html