├── examples ├── stm32 │ ├── stm32.7z │ ├── stm32_dump_mifare │ │ ├── Inc │ │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ ├── .mxproject │ │ └── Src │ │ │ └── main.c │ ├── stm32_dump_ntag2 │ │ ├── Inc │ │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ ├── .mxproject │ │ └── Src │ │ │ └── main.c │ ├── stm32_get_uid │ │ ├── Inc │ │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ ├── .mxproject │ │ └── Src │ │ │ └── main.c │ ├── stm32_read_gpio │ │ ├── Inc │ │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ ├── .mxproject │ │ └── Src │ │ │ └── main.c │ ├── stm32_rw_mifare │ │ ├── Inc │ │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ └── .mxproject │ ├── stm32_rw_ntag2 │ │ ├── Inc │ │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ ├── .mxproject │ │ └── Src │ │ │ └── main.c │ └── stm32_write_gpio │ │ ├── Inc │ │ └── main.h │ │ ├── pn532_stm32.ioc │ │ ├── .mxproject │ │ └── Src │ │ └── main.c ├── raspberrypi │ ├── Makefile │ ├── rpi_read_gpio.c │ ├── rpi_get_uid.c │ ├── rpi_write_gpio.c │ ├── rpi_dump_ntag2.c │ ├── rpi_dump_mifare.c │ ├── rpi_rw_ntag2.c │ └── rpi_rw_mifare.c └── arduino │ ├── uno_get_uid │ └── uno_get_uid.ino │ ├── uno_read_gpio │ └── uno_read_gpio.ino │ ├── uno_write_gpio │ └── uno_write_gpio.ino │ ├── uno_dump_ntag2 │ └── uno_dump_ntag2.ino │ ├── uno_rw_ntag2 │ └── uno_rw_ntag2.ino │ ├── uno_dump_mifare │ └── uno_dump_mifare.ino │ └── uno_rw_mifare │ └── uno_rw_mifare.ino ├── pn532_uno.h ├── pn532_stm32f1.h ├── pn532_rpi.h ├── README.md ├── pn532_stm32f1.c └── pn532_uno.cpp /examples/stm32/stm32.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soonuse/pn532-lib/HEAD/examples/stm32/stm32.7z -------------------------------------------------------------------------------- /examples/raspberrypi/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | DLIBS = -lwiringPi 3 | INC_DIR = ../../ 4 | SRCS = $(wildcard *.c) 5 | all: $(SRCS:.c=.exe) 6 | .PHONY: clean 7 | %.exe: %.o pn532.o pn532_rpi.o 8 | $(CC) -Wall -o $@ $^ $(DLIBS) 9 | %.o: %.c 10 | $(CC) -Wall -c $^ $(DLIBS) -I$(INC_DIR) 11 | pn532.o pn532_rpi.o: $(INC_DIR)pn532.c $(INC_DIR)pn532_rpi.c 12 | $(CC) -Wall -c $(INC_DIR)pn532.c 13 | $(CC) -Wall -c $(INC_DIR)pn532_rpi.c 14 | clean: 15 | rm *.o *.exe 16 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_read_gpio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "pn532.h" 5 | #include "pn532_rpi.h" 6 | 7 | int main(int argc, char** argv) { 8 | uint8_t buff[3]; 9 | bool pin_state = false; 10 | PN532 pn532; 11 | //PN532_SPI_Init(&pn532); 12 | PN532_I2C_Init(&pn532); 13 | //PN532_UART_Init(&pn532); 14 | if (PN532_GetFirmwareVersion(&pn532, buff) != PN532_STATUS_OK) { 15 | printf("PN532 not found\r\n"); 16 | return -1; 17 | } 18 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 19 | PN532_ReadGpio(&pn532, buff); 20 | printf("Port P3: 0x%02x\r\n", buff[0]); 21 | printf("Port P7: 0x%02x\r\n", buff[1]); 22 | printf("Port I: 0x%02x\r\n", buff[3]); 23 | for (uint8_t i = 30; i < 36; i++) { 24 | pin_state = PN532_ReadGpioP(&pn532, i); 25 | printf("Pin P%d: %d\r\n", i, pin_state); 26 | } 27 | for (uint8_t i = 0; i < 2; i++) { 28 | pin_state = PN532_ReadGpioI(&pn532, i); 29 | printf("Pin I%d: %d\r\n", i, pin_state); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/arduino/uno_get_uid/uno_get_uid.ino: -------------------------------------------------------------------------------- 1 | #include "pn532.h" 2 | #include "pn532_uno.h" 3 | 4 | uint8_t buff[255]; 5 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 6 | int32_t uid_len = 0; 7 | PN532 pn532; 8 | 9 | void setup() { 10 | // put your setup code here, to run once: 11 | PN532_I2C_Init(&pn532); 12 | Serial.println("Hello!"); 13 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 14 | Serial.print("Found PN532 with firmware version: "); 15 | Serial.print(buff[1], DEC); 16 | Serial.print("."); 17 | Serial.println(buff[2], DEC); 18 | Serial.println("Waiting for RFID/NFC card..."); 19 | } 20 | PN532_SamConfiguration(&pn532); 21 | } 22 | 23 | void loop() { 24 | // put your main code here, to run repeatedly: 25 | // Check if a card is available to read 26 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 27 | if (uid_len == PN532_STATUS_ERROR) { 28 | Serial.print("."); 29 | } else { 30 | Serial.print("Found card with UID: "); 31 | for (uint8_t i = 0; i < uid_len; i++) { 32 | if (uid[i] <= 0xF) { 33 | Serial.print("0"); 34 | } 35 | Serial.print(uid[i], HEX); 36 | Serial.print(" "); 37 | } 38 | Serial.println(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_get_uid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "pn532.h" 5 | #include "pn532_rpi.h" 6 | 7 | int main(int argc, char** argv) { 8 | uint8_t buff[255]; 9 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 10 | int32_t uid_len = 0; 11 | printf("Hello!\r\n"); 12 | PN532 pn532; 13 | //PN532_SPI_Init(&pn532); 14 | PN532_I2C_Init(&pn532); 15 | //PN532_UART_Init(&pn532); 16 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 17 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 18 | } else { 19 | return -1; 20 | } 21 | PN532_SamConfiguration(&pn532); 22 | printf("Waiting for RFID/NFC card...\r\n"); 23 | while (1) 24 | { 25 | // Check if a card is available to read 26 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 27 | if (uid_len == PN532_STATUS_ERROR) { 28 | printf("."); 29 | fflush(stdout); 30 | } else { 31 | printf("Found card with UID: "); 32 | for (uint8_t i = 0; i < uid_len; i++) { 33 | printf("%02x ", uid[i]); 34 | } 35 | printf("\r\n"); 36 | break; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_write_gpio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "pn532.h" 5 | #include "pn532_rpi.h" 6 | 7 | int main(int argc, char** argv) { 8 | uint8_t buff[3]; 9 | bool pin_state = false; 10 | PN532 pn532; 11 | //PN532_SPI_Init(&pn532); 12 | PN532_I2C_Init(&pn532); 13 | //PN532_UART_Init(&pn532); 14 | if (PN532_GetFirmwareVersion(&pn532, buff) != PN532_STATUS_OK) { 15 | printf("PN532 not found\r\n"); 16 | return -1; 17 | } 18 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 19 | PN532_WriteGpioP(&pn532, 30, true); 20 | PN532_WriteGpioP(&pn532, 31, false); 21 | //PN532_WriteGpioP(&pn532, 32, true); // Reserved, don't change this 22 | PN532_WriteGpioP(&pn532, 33, false); 23 | //PN532_WriteGpioP(&pn532, 34, true); // Reserved, don't change this 24 | PN532_WriteGpioP(&pn532, 35, false); 25 | PN532_WriteGpioP(&pn532, 71, false); // Always HIGH in SPI mode 26 | PN532_WriteGpioP(&pn532, 72, true); // Always HIGH in SPI mode 27 | for (uint8_t i = 30; i < 36; i++) { 28 | pin_state = PN532_ReadGpioP(&pn532, i); 29 | printf("Pin P%d: %d\r\n", i, pin_state); 30 | } 31 | for (uint8_t i = 71; i < 73; i++) { 32 | pin_state = PN532_ReadGpioP(&pn532, i); 33 | printf("Pin P%d: %d\r\n", i, pin_state); 34 | } 35 | for (uint8_t i = 0; i < 2; i++) { 36 | pin_state = PN532_ReadGpioI(&pn532, i); 37 | printf("Pin I%d: %d\r\n", i, pin_state); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/arduino/uno_read_gpio/uno_read_gpio.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pn532.h" 3 | #include "pn532_uno.h" 4 | 5 | uint8_t buff[255]; 6 | uint32_t pn532_error = PN532_ERROR_NONE; 7 | bool pin_state = false; 8 | PN532 pn532; 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | PN532_I2C_Init(&pn532); 13 | Serial.println("Hello!"); 14 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 15 | Serial.print("Found PN532 with firmware version: "); 16 | Serial.print(buff[1], DEC); 17 | Serial.print("."); 18 | Serial.println(buff[2], DEC); 19 | } else { 20 | return; 21 | } 22 | PN532_ReadGpio(&pn532, buff); 23 | Serial.print("Port P3: 0x"); 24 | if (buff[0] <= 0xF) { 25 | Serial.print("0"); 26 | } 27 | Serial.println(buff[0], HEX); 28 | Serial.print("Port P7: 0x"); 29 | if (buff[1] <= 0xF) { 30 | Serial.print("0"); 31 | } 32 | Serial.println(buff[1], HEX); 33 | Serial.print("Port I: 0x"); 34 | if (buff[3] <= 0xF) { 35 | Serial.print("0"); 36 | } 37 | Serial.println(buff[3], HEX); 38 | for (uint8_t i = 30; i < 36; i++) { 39 | pin_state = PN532_ReadGpioP(&pn532, i); 40 | Serial.print("Pin P"); 41 | Serial.print(i); 42 | Serial.print(": "); 43 | Serial.println(pin_state); 44 | } 45 | for (uint8_t i = 0; i < 2; i++) { 46 | pin_state = PN532_ReadGpioI(&pn532, i); 47 | Serial.print("Pin I"); 48 | Serial.print(i); 49 | Serial.print(": "); 50 | Serial.println(pin_state); 51 | } 52 | } 53 | 54 | void loop() { 55 | // put your main code here, to run repeatedly: 56 | } 57 | -------------------------------------------------------------------------------- /examples/arduino/uno_write_gpio/uno_write_gpio.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pn532.h" 3 | #include "pn532_uno.h" 4 | 5 | uint8_t buff[255]; 6 | uint8_t pins_state[2]; 7 | uint32_t pn532_error = PN532_ERROR_NONE; 8 | bool pin_state = false; 9 | PN532 pn532; 10 | 11 | void setup() { 12 | // put your setup code here, to run once: 13 | PN532_I2C_Init(&pn532); 14 | Serial.println("Hello!"); 15 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 16 | Serial.print("Found PN532 with firmware version: "); 17 | Serial.print(buff[1], DEC); 18 | Serial.print("."); 19 | Serial.println(buff[2], DEC); 20 | } else { 21 | return; 22 | } 23 | PN532_WriteGpioP(&pn532, 30, true); 24 | PN532_WriteGpioP(&pn532, 31, false); 25 | //PN532_WriteGpioP(&pn532, 32, true); // Reserved, don't change this 26 | PN532_WriteGpioP(&pn532, 33, false); 27 | //PN532_WriteGpioP(&pn532, 34, true); // Reserved, don't change this 28 | PN532_WriteGpioP(&pn532, 35, false); 29 | PN532_WriteGpioP(&pn532, 71, false); // Always HIGH in SPI mode 30 | PN532_WriteGpioP(&pn532, 72, true); // Always HIGH in SPI mode 31 | for (uint8_t i = 30; i < 36; i++) { 32 | pin_state = PN532_ReadGpioP(&pn532, i); 33 | Serial.print("Pin P"); 34 | Serial.print(i); 35 | Serial.print(": "); 36 | Serial.println(pin_state); 37 | } 38 | for (uint8_t i = 71; i < 73; i++) { 39 | pin_state = PN532_ReadGpioP(&pn532, i); 40 | Serial.print("Pin P"); 41 | Serial.print(i); 42 | Serial.print(": "); 43 | Serial.println(pin_state); 44 | } 45 | for (uint8_t i = 0; i < 2; i++) { 46 | pin_state = PN532_ReadGpioI(&pn532, i); 47 | Serial.print("Pin I"); 48 | Serial.print(i); 49 | Serial.print(": "); 50 | Serial.println(pin_state); 51 | } 52 | } 53 | 54 | void loop() { 55 | // put your main code here, to run repeatedly: 56 | } 57 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_dump_ntag2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "pn532.h" 5 | #include "pn532_rpi.h" 6 | 7 | int main(int argc, char** argv) { 8 | uint8_t buff[255]; 9 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 10 | uint32_t pn532_error = PN532_ERROR_NONE; 11 | int32_t uid_len = 0; 12 | printf("Hello!\r\n"); 13 | PN532 pn532; 14 | //PN532_SPI_Init(&pn532); 15 | PN532_I2C_Init(&pn532); 16 | //PN532_UART_Init(&pn532); 17 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 18 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 19 | } else { 20 | return -1; 21 | } 22 | PN532_SamConfiguration(&pn532); 23 | printf("Waiting for RFID/NFC card...\r\n"); 24 | while (1) 25 | { 26 | // Check if a card is available to read 27 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 28 | if (uid_len == PN532_STATUS_ERROR) { 29 | printf("."); 30 | } else { 31 | printf("Found card with UID: "); 32 | for (uint8_t i = 0; i < uid_len; i++) { 33 | printf("%02x ", uid[i]); 34 | } 35 | printf("\r\n"); 36 | break; 37 | } 38 | } 39 | printf("Reading blocks...\r\n"); 40 | for (uint8_t block_number = 0; block_number < 135; block_number++) { 41 | pn532_error = PN532_Ntag2xxReadBlock(&pn532, buff, block_number); 42 | if (pn532_error != PN532_ERROR_NONE) { 43 | break; 44 | } 45 | printf("%d: ", block_number); 46 | for (uint8_t i = 0; i < 4; i++) { 47 | printf("%02x ", buff[i]); 48 | } 49 | printf("\r\n"); 50 | } 51 | if (pn532_error) { 52 | printf("Error: 0x%02x\r\n", pn532_error); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/arduino/uno_dump_ntag2/uno_dump_ntag2.ino: -------------------------------------------------------------------------------- 1 | #include "pn532.h" 2 | #include "pn532_uno.h" 3 | 4 | uint8_t buff[255]; 5 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 6 | int32_t uid_len = 0; 7 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 8 | uint32_t pn532_error = PN532_ERROR_NONE; 9 | 10 | PN532 pn532; 11 | 12 | void setup() { 13 | // put your setup code here, to run once: 14 | PN532_I2C_Init(&pn532); 15 | Serial.println("Hello!"); 16 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 17 | Serial.print("Found PN532 with firmware version: "); 18 | Serial.print(buff[1], DEC); 19 | Serial.print("."); 20 | Serial.println(buff[2], DEC); 21 | Serial.println("Waiting for RFID/NFC card..."); 22 | } else { 23 | return; 24 | } 25 | PN532_SamConfiguration(&pn532); 26 | while (1) 27 | { 28 | // Check if a card is available to read 29 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 30 | if (uid_len == PN532_STATUS_ERROR) { 31 | Serial.print("."); 32 | } else { 33 | Serial.print("Found card with UID: "); 34 | for (uint8_t i = 0; i < uid_len; i++) { 35 | if (uid[i] <= 0xF) { 36 | Serial.print("0"); 37 | } 38 | Serial.print(uid[i], HEX); 39 | Serial.print(" "); 40 | } 41 | Serial.println(); 42 | break; 43 | } 44 | } 45 | Serial.println("Reading blocks..."); 46 | for (uint8_t block_number = 0; block_number < 135; block_number++) { 47 | pn532_error = PN532_Ntag2xxReadBlock(&pn532, buff, block_number); 48 | if (pn532_error) { 49 | break; 50 | } 51 | Serial.print(block_number, DEC); 52 | Serial.print(": "); 53 | for (uint8_t i = 0; i < 4; i++) { 54 | if (buff[i] <= 0xF) { 55 | Serial.print("0"); 56 | } 57 | Serial.print(buff[i], HEX); 58 | Serial.print(" "); 59 | } 60 | Serial.println(); 61 | } 62 | if (pn532_error) { 63 | Serial.print("Error: 0x"); 64 | Serial.print(pn532_error, HEX); 65 | } 66 | } 67 | 68 | void loop() { 69 | // put your main code here, to run repeatedly: 70 | } 71 | -------------------------------------------------------------------------------- /pn532_uno.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @file pn532_uno.h 3 | * @author Yehui from Waveshare 4 | * @license BSD 5 | * 6 | * Header file for pn532_uno.c 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documnetation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | **************************************************************************/ 26 | 27 | #ifndef PN532_UNO 28 | #define PN532_UNO 29 | 30 | #include "pn532.h" 31 | 32 | int PN532_Reset(void); 33 | void PN532_Log(const char* log); 34 | 35 | void PN532_SPI_Init(PN532* dev); 36 | int PN532_SPI_ReadData(uint8_t* data, uint16_t count); 37 | int PN532_SPI_WriteData(uint8_t *data, uint16_t count); 38 | bool PN532_SPI_WaitReady(uint32_t timeout); 39 | int PN532_SPI_Wakeup(void); 40 | 41 | void PN532_I2C_Init(PN532* dev); 42 | int PN532_I2C_ReadData(uint8_t* data, uint16_t count); 43 | int PN532_I2C_WriteData(uint8_t *data, uint16_t count); 44 | bool PN532_I2C_WaitReady(uint32_t timeout); 45 | int PN532_I2C_Wakeup(void); 46 | 47 | #endif /* PN532_UNO */ 48 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_dump_mifare.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "pn532.h" 5 | #include "pn532_rpi.h" 6 | 7 | int main(int argc, char** argv) { 8 | uint8_t buff[255]; 9 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 10 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 11 | uint32_t pn532_error = PN532_ERROR_NONE; 12 | int32_t uid_len = 0; 13 | printf("Hello!\r\n"); 14 | PN532 pn532; 15 | //PN532_SPI_Init(&pn532); 16 | PN532_I2C_Init(&pn532); 17 | //PN532_UART_Init(&pn532); 18 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 19 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 20 | } else { 21 | return -1; 22 | } 23 | PN532_SamConfiguration(&pn532); 24 | printf("Waiting for RFID/NFC card...\r\n"); 25 | while (1) 26 | { 27 | // Check if a card is available to read 28 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 29 | if (uid_len == PN532_STATUS_ERROR) { 30 | printf("."); 31 | } else { 32 | printf("Found card with UID: "); 33 | for (uint8_t i = 0; i < uid_len; i++) { 34 | printf("%02x ", uid[i]); 35 | } 36 | printf("\r\n"); 37 | break; 38 | } 39 | } 40 | printf("Reading blocks...\r\n"); 41 | for (uint8_t block_number = 0; block_number < 64; block_number++) { 42 | pn532_error = PN532_MifareClassicAuthenticateBlock(&pn532, uid, uid_len, 43 | block_number, MIFARE_CMD_AUTH_A, key_a); 44 | if (pn532_error != PN532_ERROR_NONE) { 45 | break; 46 | } 47 | pn532_error = PN532_MifareClassicReadBlock(&pn532, buff, block_number); 48 | if (pn532_error != PN532_ERROR_NONE) { 49 | break; 50 | } 51 | printf("%d: ", block_number); 52 | for (uint8_t i = 0; i < 16; i++) { 53 | printf("%02x ", buff[i]); 54 | } 55 | printf("\r\n"); 56 | } 57 | if (pn532_error) { 58 | printf("Error: 0x%02x\r\n", pn532_error); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /pn532_stm32f1.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @file pn532_stm32f1.h 3 | * @author Yehui from Waveshare 4 | * @license BSD 5 | * 6 | * Header file for pn532_stm32f1.c 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documnetation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | **************************************************************************/ 26 | 27 | #ifndef PN532_STM32F1 28 | #define PN532_STM32F1 29 | 30 | #include "pn532.h" 31 | 32 | void PN532_Init(PN532* dev); 33 | int PN532_Reset(void); 34 | void PN532_Log(const char* log); 35 | 36 | int PN532_SPI_ReadData(uint8_t* data, uint16_t count); 37 | int PN532_SPI_WriteData(uint8_t *data, uint16_t count); 38 | bool PN532_SPI_WaitReady(uint32_t timeout); 39 | int PN532_SPI_Wakeup(void); 40 | void PN532_SPI_Init(PN532* dev); 41 | 42 | int PN532_I2C_ReadData(uint8_t* data, uint16_t count); 43 | int PN532_I2C_WriteData(uint8_t *data, uint16_t count); 44 | bool PN532_I2C_WaitReady(uint32_t timeout); 45 | int PN532_I2C_Wakeup(void); 46 | void PN532_I2C_Init(PN532* dev); 47 | 48 | #endif /* PN532_STM32F1 */ 49 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_rw_ntag2.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This example shows connecting to the PN532 and writing an NTAG215 3 | * type RFID tag 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include "pn532.h" 9 | #include "pn532_rpi.h" 10 | 11 | int main(int argc, char** argv) { 12 | uint8_t buff[255]; 13 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 14 | uint32_t pn532_error = PN532_ERROR_NONE; 15 | int32_t uid_len = 0; 16 | printf("Hello!\r\n"); 17 | PN532 pn532; 18 | PN532_SPI_Init(&pn532); 19 | //PN532_I2C_Init(&pn532); 20 | //PN532_UART_Init(&pn532); 21 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 22 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 23 | } else { 24 | return -1; 25 | } 26 | PN532_SamConfiguration(&pn532); 27 | printf("Waiting for RFID/NFC card...\r\n"); 28 | while (1) { 29 | // Check if a card is available to read 30 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 31 | if (uid_len == PN532_STATUS_ERROR) { 32 | printf("."); 33 | fflush(stdout); 34 | } else { 35 | printf("Found card with UID: "); 36 | for (uint8_t i = 0; i < uid_len; i++) { 37 | printf("%02x ", uid[i]); 38 | } 39 | printf("\r\n"); 40 | break; 41 | } 42 | } 43 | // Write block #6 44 | uint8_t block_number = 6; 45 | uint8_t DATA[] = {0x00, 0x01, 0x02, 0x03}; 46 | pn532_error = PN532_Ntag2xxWriteBlock(&pn532, DATA, block_number); 47 | if (pn532_error) { 48 | printf("Error: 0x%02x\r\n", pn532_error); 49 | return -1; 50 | } 51 | pn532_error = PN532_Ntag2xxReadBlock(&pn532, buff, block_number); 52 | if (pn532_error) { 53 | printf("Error: 0x%02x\r\n", pn532_error); 54 | return -1; 55 | } 56 | for (uint8_t i = 0; i < sizeof(DATA); i++) { 57 | if (DATA[i] != buff[i]) { 58 | printf("Write block %d failed\r\n", block_number); 59 | return -1; 60 | } 61 | } 62 | printf("Write block %d successfully\r\n", block_number); 63 | } 64 | -------------------------------------------------------------------------------- /examples/arduino/uno_rw_ntag2/uno_rw_ntag2.ino: -------------------------------------------------------------------------------- 1 | #include "pn532.h" 2 | #include "pn532_uno.h" 3 | 4 | uint8_t buff[255]; 5 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 6 | int32_t uid_len = 0; 7 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 8 | uint32_t pn532_error = PN532_ERROR_NONE; 9 | 10 | PN532 pn532; 11 | 12 | void setup() { 13 | // put your setup code here, to run once: 14 | PN532_I2C_Init(&pn532); 15 | Serial.println("Hello!"); 16 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 17 | Serial.print("Found PN532 with firmware version: "); 18 | Serial.print(buff[1], DEC); 19 | Serial.print("."); 20 | Serial.println(buff[2], DEC); 21 | Serial.println("Waiting for RFID/NFC card..."); 22 | } else { 23 | return; 24 | } 25 | PN532_SamConfiguration(&pn532); 26 | while (1) 27 | { 28 | // Check if a card is available to read 29 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 30 | if (uid_len == PN532_STATUS_ERROR) { 31 | Serial.print("."); 32 | } else { 33 | Serial.print("Found card with UID: "); 34 | for (uint8_t i = 0; i < uid_len; i++) { 35 | if (uid[i] <= 0xF) { 36 | Serial.print("0"); 37 | } 38 | Serial.print(uid[i], HEX); 39 | Serial.print(" "); 40 | } 41 | Serial.println(); 42 | break; 43 | } 44 | } 45 | // Write block #6 46 | uint8_t block_number = 6; 47 | uint8_t DATA[] = {0x00, 0x01, 0x02, 0x03}; 48 | pn532_error = PN532_Ntag2xxWriteBlock(&pn532, DATA, block_number); 49 | if (pn532_error) { 50 | Serial.print("Error: 0x"); 51 | Serial.print(pn532_error, HEX); 52 | return; 53 | } 54 | pn532_error = PN532_Ntag2xxReadBlock(&pn532, buff, block_number); 55 | if (pn532_error) { 56 | Serial.print("Error: 0x"); 57 | Serial.print(pn532_error, HEX); 58 | return; 59 | } 60 | for (uint8_t i = 0; i < sizeof(DATA); i++) { 61 | if (DATA[i] != buff[i]) { 62 | Serial.print("Write block "); 63 | Serial.print(block_number, DEC); 64 | Serial.print(" failed\r\n"); 65 | return; 66 | } 67 | } 68 | Serial.print("Write block "); 69 | Serial.print(block_number, DEC); 70 | Serial.print(" successfully\r\n"); 71 | } 72 | 73 | void loop() { 74 | // put your main code here, to run repeatedly: 75 | } 76 | -------------------------------------------------------------------------------- /examples/arduino/uno_dump_mifare/uno_dump_mifare.ino: -------------------------------------------------------------------------------- 1 | #include "pn532.h" 2 | #include "pn532_uno.h" 3 | 4 | uint8_t buff[255]; 5 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 6 | int32_t uid_len = 0; 7 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 8 | uint32_t pn532_error = PN532_ERROR_NONE; 9 | 10 | PN532 pn532; 11 | 12 | void setup() { 13 | // put your setup code here, to run once: 14 | PN532_I2C_Init(&pn532); 15 | Serial.println("Hello!"); 16 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 17 | Serial.print("Found PN532 with firmware version: "); 18 | Serial.print(buff[1], DEC); 19 | Serial.print("."); 20 | Serial.println(buff[2], DEC); 21 | Serial.println("Waiting for RFID/NFC card..."); 22 | } else { 23 | return; 24 | } 25 | PN532_SamConfiguration(&pn532); 26 | while (1) 27 | { 28 | // Check if a card is available to read 29 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 30 | if (uid_len == PN532_STATUS_ERROR) { 31 | Serial.print("."); 32 | } else { 33 | Serial.print("Found card with UID: "); 34 | for (uint8_t i = 0; i < uid_len; i++) { 35 | if (uid[i] <= 0xF) { 36 | Serial.print("0"); 37 | } 38 | Serial.print(uid[i], HEX); 39 | Serial.print(" "); 40 | } 41 | Serial.println(); 42 | break; 43 | } 44 | } 45 | Serial.println("Reading blocks..."); 46 | for (uint8_t block_number = 0; block_number < 64; block_number++) { 47 | pn532_error = PN532_MifareClassicAuthenticateBlock(&pn532, uid, uid_len, 48 | block_number, MIFARE_CMD_AUTH_A, key_a); 49 | if (pn532_error != PN532_ERROR_NONE) { 50 | break; 51 | } 52 | pn532_error = PN532_MifareClassicReadBlock(&pn532, buff, block_number); 53 | if (pn532_error != PN532_ERROR_NONE) { 54 | break; 55 | } 56 | Serial.print(block_number, DEC); 57 | Serial.print(": "); 58 | for (uint8_t i = 0; i < 16; i++) { 59 | if (buff[i] <= 0xF) { 60 | Serial.print("0"); 61 | } 62 | Serial.print(buff[i], HEX); 63 | Serial.print(" "); 64 | } 65 | Serial.println(); 66 | } 67 | if (pn532_error) { 68 | Serial.print("Error: 0x"); 69 | Serial.print(pn532_error, HEX); 70 | } 71 | } 72 | 73 | void loop() { 74 | // put your main code here, to run repeatedly: 75 | } 76 | -------------------------------------------------------------------------------- /pn532_rpi.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @file pn532_rpi.h 3 | * @author Yehui from Waveshare 4 | * @license BSD 5 | * 6 | * Header file for pn532_rpi.c 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documnetation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | **************************************************************************/ 26 | 27 | #ifndef PN532_RPI 28 | #define PN532_RPI 29 | 30 | #include "pn532.h" 31 | 32 | int PN532_Reset(void); 33 | void PN532_Log(const char* log); 34 | 35 | void PN532_SPI_Init(PN532* dev); 36 | int PN532_SPI_ReadData(uint8_t* data, uint16_t count); 37 | int PN532_SPI_WriteData(uint8_t *data, uint16_t count); 38 | bool PN532_SPI_WaitReady(uint32_t timeout); 39 | int PN532_SPI_Wakeup(void); 40 | 41 | void PN532_UART_Init(PN532* dev); 42 | int PN532_UART_ReadData(uint8_t* data, uint16_t count); 43 | int PN532_UART_WriteData(uint8_t *data, uint16_t count); 44 | bool PN532_UART_WaitReady(uint32_t timeout); 45 | int PN532_UART_Wakeup(void); 46 | 47 | void PN532_I2C_Init(PN532* dev); 48 | int PN532_I2C_ReadData(uint8_t* data, uint16_t count); 49 | int PN532_I2C_WriteData(uint8_t *data, uint16_t count); 50 | bool PN532_I2C_WaitReady(uint32_t timeout); 51 | int PN532_I2C_Wakeup(void); 52 | 53 | #endif /* PN532_RPI */ 54 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_mifare/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_ntag2/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/stm32/stm32_get_uid/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/stm32/stm32_read_gpio/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_mifare/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_ntag2/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/stm32/stm32_write_gpio/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define SS_Pin GPIO_PIN_4 62 | #define SS_GPIO_Port GPIOA 63 | #define PN532_RST_Pin GPIO_PIN_0 64 | #define PN532_RST_GPIO_Port GPIOB 65 | #define PN532_REQ_Pin GPIO_PIN_1 66 | #define PN532_REQ_GPIO_Port GPIOB 67 | /* USER CODE BEGIN Private defines */ 68 | 69 | /* USER CODE END Private defines */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __MAIN_H */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /examples/raspberrypi/rpi_rw_mifare.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This example shows connecting to the PN532 and writing an Mifare Classic 3 | * type RFID tag 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include "pn532.h" 9 | #include "pn532_rpi.h" 10 | 11 | int main(int argc, char** argv) { 12 | uint8_t buff[255]; 13 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 14 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 15 | uint32_t pn532_error = PN532_ERROR_NONE; 16 | int32_t uid_len = 0; 17 | printf("Hello!\r\n"); 18 | PN532 pn532; 19 | //PN532_SPI_Init(&pn532); 20 | PN532_I2C_Init(&pn532); 21 | //PN532_UART_Init(&pn532); 22 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 23 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 24 | } else { 25 | return -1; 26 | } 27 | PN532_SamConfiguration(&pn532); 28 | printf("Waiting for RFID/NFC card...\r\n"); 29 | while (1) 30 | { 31 | // Check if a card is available to read 32 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 33 | if (uid_len == PN532_STATUS_ERROR) { 34 | printf("."); 35 | fflush(stdout); 36 | } else { 37 | printf("Found card with UID: "); 38 | for (uint8_t i = 0; i < uid_len; i++) { 39 | printf("%02x ", uid[i]); 40 | } 41 | printf("\r\n"); 42 | break; 43 | } 44 | } 45 | /** 46 | * Warning: DO NOT write the blocks of 4N+3 (3, 7, 11, ..., 63) 47 | * or else you will change the password for blocks 4N ~ 4N+2. 48 | * Note: 49 | * 1. The first 6 bytes (KEY A) of the 4N+3 blocks are always shown as 0x00, 50 | * since 'KEY A' is unreadable. In contrast, the last 6 bytes (KEY B) of the 51 | * 4N+3 blocks are readable. 52 | * 2. Block 0 is unwritable. 53 | */ 54 | // Write block #6 55 | uint8_t block_number = 6; 56 | uint8_t DATA[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; 57 | pn532_error = PN532_MifareClassicAuthenticateBlock(&pn532, uid, uid_len, 58 | block_number, MIFARE_CMD_AUTH_A, key_a); 59 | if (pn532_error) { 60 | printf("Error: 0x%02x\r\n", pn532_error); 61 | return -1; 62 | } 63 | pn532_error = PN532_MifareClassicWriteBlock(&pn532, DATA, block_number); 64 | if (pn532_error) { 65 | printf("Error: 0x%02x\r\n", pn532_error); 66 | return -1; 67 | } 68 | pn532_error = PN532_MifareClassicReadBlock(&pn532, buff, block_number); 69 | if (pn532_error) { 70 | printf("Error: 0x%02x\r\n", pn532_error); 71 | return -1; 72 | } 73 | for (uint8_t i = 0; i < sizeof(DATA); i++) { 74 | if (DATA[i] != buff[i]) { 75 | printf("Write block %d failed\r\n", block_number); 76 | return -1; 77 | } 78 | } 79 | printf("Write block %d successfully\r\n", block_number); 80 | } 81 | -------------------------------------------------------------------------------- /examples/arduino/uno_rw_mifare/uno_rw_mifare.ino: -------------------------------------------------------------------------------- 1 | #include "pn532.h" 2 | #include "pn532_uno.h" 3 | 4 | uint8_t buff[255]; 5 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 6 | int32_t uid_len = 0; 7 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 8 | uint32_t pn532_error = PN532_ERROR_NONE; 9 | 10 | PN532 pn532; 11 | 12 | void setup() { 13 | // put your setup code here, to run once: 14 | PN532_I2C_Init(&pn532); 15 | Serial.println("Hello!"); 16 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 17 | Serial.print("Found PN532 with firmware version: "); 18 | Serial.print(buff[1], DEC); 19 | Serial.print("."); 20 | Serial.println(buff[2], DEC); 21 | Serial.println("Waiting for RFID/NFC card..."); 22 | } else { 23 | return; 24 | } 25 | PN532_SamConfiguration(&pn532); 26 | while (1) 27 | { 28 | // Check if a card is available to read 29 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 30 | if (uid_len == PN532_STATUS_ERROR) { 31 | Serial.print("."); 32 | } else { 33 | Serial.print("Found card with UID: "); 34 | for (uint8_t i = 0; i < uid_len; i++) { 35 | if (uid[i] <= 0xF) { 36 | Serial.print("0"); 37 | } 38 | Serial.print(uid[i], HEX); 39 | Serial.print(" "); 40 | } 41 | Serial.println(); 42 | break; 43 | } 44 | } 45 | /** 46 | * Warning: DO NOT write the blocks of 4N+3 (3, 7, 11, ..., 63) 47 | * or else you will change the password for blocks 4N ~ 4N+2. 48 | * Note: 49 | * 1. The first 6 bytes (KEY A) of the 4N+3 blocks are always shown as 0x00, 50 | * since 'KEY A' is unreadable. In contrast, the last 6 bytes (KEY B) of the 51 | * 4N+3 blocks are readable. 52 | * 2. Block 0 is unwritable. 53 | */ 54 | // Write block #6 55 | uint8_t block_number = 6; 56 | uint8_t DATA[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; 57 | pn532_error = PN532_MifareClassicAuthenticateBlock(&pn532, uid, uid_len, 58 | block_number, MIFARE_CMD_AUTH_A, key_a); 59 | if (pn532_error) { 60 | Serial.print("Error: 0x"); 61 | Serial.print(pn532_error, HEX); 62 | return; 63 | } 64 | pn532_error = PN532_MifareClassicWriteBlock(&pn532, DATA, block_number); 65 | if (pn532_error) { 66 | Serial.print("Error: 0x"); 67 | Serial.print(pn532_error, HEX); 68 | return; 69 | } 70 | pn532_error = PN532_MifareClassicReadBlock(&pn532, buff, block_number); 71 | if (pn532_error) { 72 | Serial.print("Error: 0x"); 73 | Serial.print(pn532_error, HEX); 74 | return; 75 | } 76 | for (uint8_t i = 0; i < sizeof(DATA); i++) { 77 | if (DATA[i] != buff[i]) { 78 | Serial.print("Write block "); 79 | Serial.print(block_number, DEC); 80 | Serial.print(" failed\r\n"); 81 | return; 82 | } 83 | } 84 | Serial.print("Write block "); 85 | Serial.print(block_number, DEC); 86 | Serial.print(" successfully\r\n"); 87 | } 88 | 89 | void loop() { 90 | // put your main code here, to run repeatedly: 91 | } 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pn532-lib 2 | PN532 NFC Library for Raspberry Pi, STM32, Arduino 3 | 4 | ![image](http://www.waveshare.net/photo/accBoard/PN532-NFC-HAT/PN532-NFC-HAT-3.jpg) 5 | 6 | # How to use? 7 | 8 | ## For Raspberry Pi 9 | 10 | ### Using SPI 11 | 1. Set I0I1: 12 | - I0 --> LOW 13 | - I1 --> HIGH 14 | 2. Hardware Connection: 15 | - SCK --> SCK 16 | - MISO --> MISO 17 | - MOSI/SDA/TX --> MOSI 18 | - NSS/SCL/RX --> D4 (GPIO 4 of BCM pinout) 19 | Optional: 20 | - RSTPDN --> D20 (for hardware reset) 21 | 3. Modify the PN532 Init lines for SPI in `example/raspberrypi/rpi_get_uid.c`: 22 | ``` 23 | PN532_SPI_Init(&pn532); 24 | //PN532_I2C_Init(&pn532); 25 | //PN532_UART_Init(&pn532); 26 | ``` 27 | 4. Compile with make: 28 | ``` 29 | cd examples/raspberrypi && make 30 | ``` 31 | 5. Run the demo with: 32 | ``` 33 | ./rpi_get_uid.exe 34 | ``` 35 | 36 | ### Using I2C 37 | 1. Set I0I1: 38 | - I0 --> HIGH 39 | - I1 --> LOW 40 | 2. Hardware Connection: 41 | - MOSI/SDA/TX --> SDA 42 | - NSS/SCL/RX --> SCL 43 | Optional: 44 | - P32 --> D16 (for hardware request) 45 | - RSTPDN --> D20 (for hardware reset) 46 | 3. Modify the PN532 Init lines for I2C in `example/raspberrypi/rpi_get_uid.c`: 47 | ``` 48 | //PN532_SPI_Init(&pn532); 49 | PN532_I2C_Init(&pn532); 50 | //PN532_UART_Init(&pn532); 51 | ``` 52 | 4. Compile with make: 53 | ``` 54 | cd examples/raspberrypi && make 55 | ``` 56 | 5. Run the demo with: 57 | ``` 58 | ./rpi_get_uid.exe 59 | ``` 60 | 61 | ### Using UART 62 | 1. Set I0I1: 63 | - I0 --> LOW 64 | - I1 --> LOW 65 | 2. Hardware Connection: 66 | - MOSI/SDA/TX --> RX 67 | - NSS/SCL/RX --> TX 68 | Optional: 69 | - RSTPDN --> D20 (for hardware reset) 70 | 3. Modify the PN532 Init lines for UART in `example/raspberrypi/rpi_get_uid.c`: 71 | ``` 72 | //PN532_SPI_Init(&pn532); 73 | //PN532_I2C_Init(&pn532); 74 | PN532_UART_Init(&pn532); 75 | ``` 76 | 4. Compile with make: 77 | ``` 78 | cd examples/raspberrypi && make 79 | ``` 80 | 5. Run the demo with: 81 | ``` 82 | ./rpi_get_uid.exe 83 | ``` 84 | 85 | ## For Arduino UNO 86 | Please first copy the files pn532.c, pn532.h, pn532_uno.cpp and pn532_uno.h to the libraries directory, 87 | which can be set up by Arduino IDE --> preference. 88 | 89 | Then you should also connect the serial port from your UNO to a PC for Serial Monitor. 90 | - Baudrate: 115200. 91 | 92 | ### Using SPI 93 | 1. Set I0I1: 94 | - I0 --> LOW 95 | - I1 --> HIGH 96 | 2. Hardware Connection: 97 | - SCK --> Arduino D13 98 | - MISO --> ArduinoD12 99 | - MOSI --> Arduino D11 100 | - NSS --> Arduino D4 101 | 102 | 3. Open examples\arduino\uno_get_uid\ uno_get_uid.ino with Arduino IDE then change the PN532 Init lines for SPI: 103 | ``` 104 | PN532_SPI_Init(&pn532); 105 | //PN532_I2C_Init(&pn532); 106 | ``` 107 | 4. Compile and upload the demo to your Arduino UNO board: 108 | ``` 109 | examples\arduino\uno_get_uid\ uno_get_uid.ino 110 | ``` 111 | 112 | ### Using I2C 113 | 1. Set I0I1: 114 | - I0 --> HIGH 115 | - I1 --> LOW 116 | 2. Hardware Connection: 117 | - SCL --> ArduinoA5 118 | - SDA --> ArduinoA4 119 | 3. Open examples\arduino\uno_get_uid\uno_get_uid.ino with Arduino IDE then change the PN532 Init lines for I2C: 120 | ``` 121 | //PN532_SPI_Init(&pn532); 122 | PN532_I2C_Init(&pn532); 123 | ``` 124 | 4. Compile and upload the demo to your Arduino UNO board: 125 | ``` 126 | examples\arduino\uno_get_uid\uno_get_uid.ino 127 | ``` 128 | 129 | ## For STM32 130 | The demos are build on STM32F103CBT6, but you can port them with STM32CubeMX. 131 | 132 | 1. Set I0I1: 133 | - I0 --> LOW 134 | - I1 --> HIGH 135 | 2. Hardware connection: 136 | - SCK --> PA5 137 | - MISO --> PA6 138 | - MOSI --> PA7 139 | - NSS --> PA4 140 | - PA9 --> RX 141 | - PA10 --> TX 142 | 3. Extract: pn532-lib\examples\stm32\stm32.7z 143 | 4. Open the project MDK-ARM\pn532_stm32.uvprojx with Keil V5 144 | 5. Build and download the project to your STM32 board. 145 | -------------------------------------------------------------------------------- /examples/stm32/stm32_get_uid/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_mifare/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_ntag2/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_read_gpio/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_mifare/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_ntag2/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_write_gpio/pn532_stm32.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.IPParameters=OwnAddress,NoStretchMode 4 | I2C1.NoStretchMode=I2C_NOSTRETCH_DISABLE 5 | I2C1.OwnAddress=0x48 6 | KeepUserPlacement=false 7 | Mcu.Family=STM32F1 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SPI1 12 | Mcu.IP4=SYS 13 | Mcu.IP5=USART1 14 | Mcu.IPNb=6 15 | Mcu.Name=STM32F103C(8-B)Tx 16 | Mcu.Package=LQFP48 17 | Mcu.Pin0=PA4 18 | Mcu.Pin1=PA5 19 | Mcu.Pin10=VP_SYS_VS_ND 20 | Mcu.Pin11=VP_SYS_VS_Systick 21 | Mcu.Pin2=PA6 22 | Mcu.Pin3=PA7 23 | Mcu.Pin4=PB0 24 | Mcu.Pin5=PB1 25 | Mcu.Pin6=PA9 26 | Mcu.Pin7=PA10 27 | Mcu.Pin8=PB6 28 | Mcu.Pin9=PB7 29 | Mcu.PinsNb=12 30 | Mcu.ThirdPartyNb=0 31 | Mcu.UserConstants= 32 | Mcu.UserName=STM32F103CBTx 33 | MxCube.Version=5.1.0 34 | MxDb.Version=DB.5.0.10 35 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 36 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 38 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 39 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 40 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 41 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 42 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 43 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 44 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 45 | PA10.Mode=Asynchronous 46 | PA10.Signal=USART1_RX 47 | PA4.GPIOParameters=GPIO_PuPd,GPIO_Label 48 | PA4.GPIO_Label=SS 49 | PA4.GPIO_PuPd=GPIO_PULLUP 50 | PA4.Locked=true 51 | PA4.Signal=GPIO_Output 52 | PA5.Mode=Full_Duplex_Master 53 | PA5.Signal=SPI1_SCK 54 | PA6.Mode=Full_Duplex_Master 55 | PA6.Signal=SPI1_MISO 56 | PA7.Mode=Full_Duplex_Master 57 | PA7.Signal=SPI1_MOSI 58 | PA9.Mode=Asynchronous 59 | PA9.Signal=USART1_TX 60 | PB0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 61 | PB0.GPIO_Label=PN532_RST 62 | PB0.GPIO_PuPd=GPIO_PULLUP 63 | PB0.Locked=true 64 | PB0.PinState=GPIO_PIN_SET 65 | PB0.Signal=GPIO_Output 66 | PB1.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label 67 | PB1.GPIO_Label=PN532_REQ 68 | PB1.GPIO_PuPd=GPIO_PULLUP 69 | PB1.Locked=true 70 | PB1.PinState=GPIO_PIN_SET 71 | PB1.Signal=GPIO_Output 72 | PB6.Mode=I2C 73 | PB6.Signal=I2C1_SCL 74 | PB7.Mode=I2C 75 | PB7.Signal=I2C1_SDA 76 | PCC.Checker=false 77 | PCC.Line=STM32F103 78 | PCC.MCU=STM32F103C(8-B)Tx 79 | PCC.PartNumber=STM32F103CBTx 80 | PCC.Seq0=0 81 | PCC.Series=STM32F1 82 | PCC.Temperature=25 83 | PCC.Vdd=3.3 84 | PinOutPanel.RotationAngle=0 85 | ProjectManager.AskForMigrate=true 86 | ProjectManager.BackupPrevious=false 87 | ProjectManager.CompilerOptimize=6 88 | ProjectManager.ComputerToolchain=false 89 | ProjectManager.CoupleFile=false 90 | ProjectManager.CustomerFirmwarePackage= 91 | ProjectManager.DefaultFWLocation=true 92 | ProjectManager.DeletePrevious=true 93 | ProjectManager.DeviceId=STM32F103CBTx 94 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0 95 | ProjectManager.FreePins=false 96 | ProjectManager.HalAssertFull=false 97 | ProjectManager.HeapSize=0x200 98 | ProjectManager.KeepUserCode=true 99 | ProjectManager.LastFirmware=true 100 | ProjectManager.LibraryCopy=0 101 | ProjectManager.MainLocation=Src 102 | ProjectManager.NoMain=false 103 | ProjectManager.PreviousToolchain= 104 | ProjectManager.ProjectBuild=false 105 | ProjectManager.ProjectFileName=pn532_stm32.ioc 106 | ProjectManager.ProjectName=pn532_stm32 107 | ProjectManager.StackSize=0x400 108 | ProjectManager.TargetToolchain=MDK-ARM V5 109 | ProjectManager.ToolChainLocation= 110 | ProjectManager.UnderRoot=false 111 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_I2C1_Init-I2C1-false-HAL-true 112 | RCC.APB1Freq_Value=8000000 113 | RCC.APB2Freq_Value=8000000 114 | RCC.FamilyName=M 115 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 116 | RCC.PLLCLKFreq_Value=8000000 117 | RCC.PLLMCOFreq_Value=4000000 118 | RCC.TimSysFreq_Value=8000000 119 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 120 | SPI1.CalculateBaudRate=62.5 KBits/s 121 | SPI1.Direction=SPI_DIRECTION_2LINES 122 | SPI1.FirstBit=SPI_FIRSTBIT_LSB 123 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,FirstBit 124 | SPI1.Mode=SPI_MODE_MASTER 125 | SPI1.VirtualType=VM_MASTER 126 | USART1.IPParameters=VirtualMode 127 | USART1.VirtualMode=VM_ASYNC 128 | VP_SYS_VS_ND.Mode=No_Debug 129 | VP_SYS_VS_ND.Signal=SYS_VS_ND 130 | VP_SYS_VS_Systick.Mode=SysTick 131 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 132 | board=custom 133 | -------------------------------------------------------------------------------- /examples/stm32/stm32_get_uid/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /examples/stm32/stm32_read_gpio/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_mifare/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_ntag2/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_mifare/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_ntag2/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /examples/stm32/stm32_write_gpio/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Anne/Desktop/stm32_get_uid/Inc 3 | HeaderFiles=stm32f1xx_it.h;stm32f1xx_hal_conf.h;main.h; 4 | SourcePath=C:/Users/Anne/Desktop/stm32_get_uid/Src 5 | SourceFiles=stm32f1xx_it.c;stm32f1xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedKeilFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/Users/Anne/Desktop/stm32_get_uid//MDK-ARM/startup_stm32f103xb.s; 12 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | 14 | -------------------------------------------------------------------------------- /pn532_stm32f1.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @file pn532_stm32f1.c 3 | * @author Yehui from Waveshare 4 | * @license BSD 5 | * 6 | * This implements the peripheral interfaces. 7 | * 8 | * Check out the links above for our tutorials and wiring diagrams 9 | * These chips use SPI communicate. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documnetation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | **************************************************************************/ 29 | 30 | #include "stm32f1xx_hal.h" 31 | #include "main.h" 32 | #include "pn532_stm32f1.h" 33 | 34 | #define _SPI_STATREAD 0x02 35 | #define _SPI_DATAWRITE 0x01 36 | #define _SPI_DATAREAD 0x03 37 | #define _SPI_READY 0x01 38 | 39 | #define _SPI_TIMEOUT 10 40 | // This indicates if the bits read/write should be reversed 41 | #define _SPI_HARDWARE_LSB 42 | 43 | #define _I2C_ADDRESS 0x48 44 | #define _I2C_TIMEOUT 10 45 | 46 | extern SPI_HandleTypeDef hspi1; 47 | extern I2C_HandleTypeDef hi2c1; 48 | 49 | /************************************************************************** 50 | * Reset and Log implements 51 | **************************************************************************/ 52 | int PN532_Reset(void) { 53 | HAL_GPIO_WritePin(PN532_RST_GPIO_Port, PN532_RST_Pin, GPIO_PIN_SET); 54 | HAL_Delay(100); 55 | HAL_GPIO_WritePin(PN532_RST_GPIO_Port, PN532_RST_Pin, GPIO_PIN_RESET); 56 | HAL_Delay(500); 57 | HAL_GPIO_WritePin(PN532_RST_GPIO_Port, PN532_RST_Pin, GPIO_PIN_SET); 58 | HAL_Delay(100); 59 | return PN532_STATUS_OK; 60 | } 61 | 62 | void PN532_Log(const char* log) { 63 | printf("%s\r\n", log); 64 | } 65 | 66 | void PN532_Init(PN532* pn532) { 67 | PN532_SPI_Init(pn532); 68 | } 69 | /************************************************************************** 70 | * End: Reset and Log implements 71 | **************************************************************************/ 72 | /************************************************************************** 73 | * SPI 74 | **************************************************************************/ 75 | uint8_t reverse_bit(uint8_t num) { 76 | uint8_t result = 0; 77 | for (uint8_t i = 0; i < 8; i++) { 78 | result <<= 1; 79 | result += (num & 1); 80 | num >>= 1; 81 | } 82 | return result; 83 | } 84 | 85 | void spi_rw(uint8_t* data, uint8_t count) { 86 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 87 | HAL_Delay(1); 88 | #ifndef _SPI_HARDWARE_LSB 89 | for (uint8_t i = 0; i < count; i++) { 90 | data[i] = reverse_bit(data[i]); 91 | } 92 | HAL_SPI_TransmitReceive(&hspi1, data, data, count, _SPI_TIMEOUT); 93 | for (uint8_t i = 0; i < count; i++) { 94 | data[i] = reverse_bit(data[i]); 95 | } 96 | #else 97 | HAL_SPI_TransmitReceive(&hspi1, data, data, count, _SPI_TIMEOUT); 98 | #endif 99 | HAL_Delay(1); 100 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_SET); 101 | } 102 | 103 | int PN532_SPI_ReadData(uint8_t* data, uint16_t count) { 104 | uint8_t frame[count + 1]; 105 | frame[0] = _SPI_DATAREAD; 106 | HAL_Delay(5); 107 | spi_rw(frame, count + 1); 108 | for (uint8_t i = 0; i < count; i++) { 109 | data[i] = frame[i + 1]; 110 | } 111 | return PN532_STATUS_OK; 112 | } 113 | 114 | int PN532_SPI_WriteData(uint8_t *data, uint16_t count) { 115 | uint8_t frame[count + 1]; 116 | frame[0] = _SPI_DATAWRITE; 117 | for (uint8_t i = 0; i < count; i++) { 118 | frame[i + 1] = data[i]; 119 | } 120 | spi_rw(frame, count + 1); 121 | return PN532_STATUS_OK; 122 | } 123 | 124 | bool PN532_SPI_WaitReady(uint32_t timeout) { 125 | uint8_t status[] = {_SPI_STATREAD, 0x00}; 126 | uint32_t tickstart = HAL_GetTick(); 127 | while (HAL_GetTick() - tickstart < timeout) { 128 | HAL_Delay(10); 129 | spi_rw(status, sizeof(status)); 130 | if (status[1] == _SPI_READY) { 131 | return true; 132 | } else { 133 | HAL_Delay(5); 134 | } 135 | } 136 | return false; 137 | } 138 | 139 | int PN532_SPI_Wakeup(void) { 140 | // Send any special commands/data to wake up PN532 141 | uint8_t data[] = {0x00}; 142 | HAL_Delay(1000); 143 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 144 | HAL_Delay(2); // T_osc_start 145 | spi_rw(data, 1); 146 | HAL_Delay(1000); 147 | return PN532_STATUS_OK; 148 | } 149 | 150 | void PN532_SPI_Init(PN532* pn532) { 151 | // init the pn532 functions 152 | pn532->reset = PN532_Reset; 153 | pn532->read_data = PN532_SPI_ReadData; 154 | pn532->write_data = PN532_SPI_WriteData; 155 | pn532->wait_ready = PN532_SPI_WaitReady; 156 | pn532->wakeup = PN532_SPI_Wakeup; 157 | pn532->log = PN532_Log; 158 | 159 | // hardware wakeup 160 | pn532->wakeup(); 161 | } 162 | /************************************************************************** 163 | * End: SPI 164 | **************************************************************************/ 165 | /************************************************************************** 166 | * I2C 167 | **************************************************************************/ 168 | void i2c_read(uint8_t* data, uint16_t count) { 169 | HAL_I2C_Master_Receive(&hi2c1, _I2C_ADDRESS, data, count, _I2C_TIMEOUT); 170 | } 171 | 172 | void i2c_write(uint8_t* data, uint16_t count) { 173 | HAL_I2C_Master_Transmit(&hi2c1, _I2C_ADDRESS, data, count, _I2C_TIMEOUT); 174 | } 175 | 176 | int PN532_I2C_ReadData(uint8_t* data, uint16_t count) { 177 | uint8_t status[] = {0x00}; 178 | uint8_t frame[count + 1]; 179 | i2c_read(status, sizeof(status)); 180 | if (status[0] != PN532_I2C_READY) { 181 | return PN532_STATUS_ERROR; 182 | } 183 | i2c_read(frame, count + 1); 184 | for (uint8_t i = 0; i < count; i++) { 185 | data[i] = frame[i + 1]; 186 | } 187 | return PN532_STATUS_OK; 188 | } 189 | 190 | int PN532_I2C_WriteData(uint8_t *data, uint16_t count) { 191 | i2c_write(data, count); 192 | return PN532_STATUS_OK; 193 | } 194 | 195 | bool PN532_I2C_WaitReady(uint32_t timeout) { 196 | uint8_t status[] = {0x00}; 197 | uint32_t tickstart = HAL_GetTick(); 198 | while (HAL_GetTick() - tickstart < timeout) { 199 | i2c_read(status, sizeof(status)); 200 | if (status[0] == PN532_I2C_READY) { 201 | return true; 202 | } else { 203 | HAL_Delay(5); 204 | } 205 | } 206 | return false; 207 | } 208 | 209 | int PN532_I2C_Wakeup(void) { 210 | // TODO 211 | HAL_GPIO_WritePin(PN532_REQ_GPIO_Port, PN532_REQ_Pin, GPIO_PIN_SET); 212 | HAL_Delay(100); 213 | HAL_GPIO_WritePin(PN532_REQ_GPIO_Port, PN532_REQ_Pin, GPIO_PIN_RESET); 214 | HAL_Delay(100); 215 | HAL_GPIO_WritePin(PN532_REQ_GPIO_Port, PN532_REQ_Pin, GPIO_PIN_SET); 216 | HAL_Delay(500); 217 | return PN532_STATUS_OK; 218 | } 219 | 220 | void PN532_I2C_Init(PN532* pn532) { 221 | // init the pn532 functions 222 | pn532->reset = PN532_Reset; 223 | pn532->read_data = PN532_I2C_ReadData; 224 | pn532->write_data = PN532_I2C_WriteData; 225 | pn532->wait_ready = PN532_I2C_WaitReady; 226 | pn532->wakeup = PN532_I2C_Wakeup; 227 | pn532->log = PN532_Log; 228 | 229 | // hardware wakeup 230 | pn532->wakeup(); 231 | } 232 | /************************************************************************** 233 | * End: I2C 234 | **************************************************************************/ 235 | -------------------------------------------------------------------------------- /pn532_uno.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * @file pn532_uno.c 3 | * @author Yehui from Waveshare 4 | * @license BSD 5 | * 6 | * This implements the peripheral interfaces. 7 | * 8 | * Check out the links above for our tutorials and wiring diagrams 9 | * These chips use SPI communicate. 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documnetation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | **************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include "pn532_uno.h" 37 | 38 | #define PN532_SPI_STATREAD (0x02) 39 | #define PN532_SPI_DATAWRITE (0x01) 40 | #define PN532_SPI_DATAREAD (0x03) 41 | #define PN532_SPI_READY (0x01) 42 | 43 | #define PN532_SPI_TIMEOUT (10) 44 | // This indicates if the bits read/write should be reversed 45 | #define PN532_SPI_HARDWARE_LSB 46 | 47 | #define PN532_NSS (4) 48 | #define PN532_REQ (2) 49 | #define PN532_RST (3) 50 | 51 | #define PN532_I2C_READY (0x01) 52 | #define PN532_I2C_ADDRESS (0x48 >> 1) 53 | 54 | 55 | /************************************************************************** 56 | * Reset and Log implements 57 | **************************************************************************/ 58 | int PN532_Reset(void) { 59 | digitalWrite(PN532_RST, HIGH); 60 | delay(100); 61 | digitalWrite(PN532_RST, LOW); 62 | delay(500); 63 | digitalWrite(PN532_RST, HIGH); 64 | delay(100); 65 | return PN532_STATUS_OK; 66 | } 67 | 68 | void PN532_Log(const char* log) { 69 | Serial.println(log); 70 | } 71 | /************************************************************************** 72 | * End: Reset and Log implements 73 | **************************************************************************/ 74 | /************************************************************************** 75 | * SPI 76 | **************************************************************************/ 77 | uint8_t reverse_bit(uint8_t num) { 78 | uint8_t result = 0; 79 | for (uint8_t i = 0; i < 8; i++) { 80 | result <<= 1; 81 | result += (num & 1); 82 | num >>= 1; 83 | } 84 | return result; 85 | } 86 | 87 | void spi_rw(uint8_t* data, uint8_t count) { 88 | digitalWrite(PN532_NSS, LOW); 89 | SPI.transfer(data, count); 90 | digitalWrite(PN532_NSS, HIGH); 91 | } 92 | 93 | int PN532_SPI_ReadData(uint8_t* data, uint16_t count) { 94 | uint8_t frame[count + 1]; 95 | frame[0] = PN532_SPI_DATAREAD; 96 | delay(5); 97 | spi_rw(frame, count + 1); 98 | for (uint8_t i = 0; i < count; i++) { 99 | data[i] = frame[i + 1]; 100 | } 101 | return PN532_STATUS_OK; 102 | } 103 | 104 | int PN532_SPI_WriteData(uint8_t* data, uint16_t count) { 105 | uint8_t frame[count + 1]; 106 | frame[0] = PN532_SPI_DATAWRITE; 107 | for (uint8_t i = 0; i < count; i++) { 108 | frame[i + 1] = data[i]; 109 | } 110 | spi_rw(frame, count + 1); 111 | return PN532_STATUS_OK; 112 | } 113 | 114 | bool PN532_SPI_WaitReady(uint32_t timeout) { 115 | uint8_t status[] = {PN532_SPI_STATREAD, 0x00}; 116 | uint32_t tickstart = millis(); 117 | while (millis() - tickstart < timeout) { 118 | delay(10); 119 | spi_rw(status, sizeof(status)); 120 | if (status[1] == PN532_SPI_READY) { 121 | return true; 122 | } else { 123 | delay(5); 124 | } 125 | } 126 | return false; 127 | } 128 | 129 | int PN532_SPI_Wakeup(void) { 130 | // Send any special commands/data to wake up PN532 131 | uint8_t data[] = {0x00}; 132 | delay(1000); 133 | digitalWrite(PN532_NSS, LOW); 134 | delay(2); // T_osc_start 135 | spi_rw(data, 1); 136 | delay(2); // T_osc_start 137 | digitalWrite(PN532_NSS, HIGH); 138 | delay(1000); 139 | return PN532_STATUS_OK; 140 | } 141 | 142 | 143 | void PN532_SPI_Init(PN532* pn532) { 144 | // init the pn532 functions 145 | pn532->reset = PN532_Reset; 146 | pn532->read_data = PN532_SPI_ReadData; 147 | pn532->write_data = PN532_SPI_WriteData; 148 | pn532->wait_ready = PN532_SPI_WaitReady; 149 | pn532->wakeup = PN532_SPI_Wakeup; 150 | pn532->log = PN532_Log; 151 | Serial.begin(115200); 152 | pinMode(PN532_REQ, OUTPUT); 153 | pinMode(PN532_RST, OUTPUT); 154 | pinMode(PN532_NSS, OUTPUT); 155 | digitalWrite(PN532_REQ, HIGH); 156 | digitalWrite(PN532_RST, HIGH); 157 | digitalWrite(PN532_NSS, HIGH); 158 | SPI.begin(); 159 | SPI.beginTransaction(SPISettings(10000, LSBFIRST, SPI_MODE0)); 160 | // hardware wakeup 161 | pn532->wakeup(); 162 | } 163 | /************************************************************************** 164 | * End: SPI 165 | **************************************************************************/ 166 | /************************************************************************** 167 | * I2C 168 | **************************************************************************/ 169 | void i2c_read(uint8_t* data, uint16_t count) { 170 | Wire.requestFrom(PN532_I2C_ADDRESS, count); 171 | for (uint16_t i = 0; i < count; i++) { 172 | data[i] = Wire.read(); 173 | } 174 | } 175 | 176 | void i2c_write(uint8_t* data, uint16_t count) { 177 | Wire.beginTransmission(PN532_I2C_ADDRESS); 178 | Wire.write(data, count); 179 | Wire.endTransmission(); 180 | } 181 | 182 | int PN532_I2C_ReadData(uint8_t* data, uint16_t count) { 183 | uint8_t status[] = {0x00}; 184 | uint8_t frame[count + 1]; 185 | i2c_read(status, sizeof(status)); 186 | if (status[0] != PN532_I2C_READY) { 187 | return PN532_STATUS_ERROR; 188 | } 189 | i2c_read(frame, count + 1); 190 | for (uint8_t i = 0; i < count; i++) { 191 | data[i] = frame[i + 1]; 192 | } 193 | return PN532_STATUS_OK; 194 | } 195 | 196 | int PN532_I2C_WriteData(uint8_t* data, uint16_t count) { 197 | i2c_write(data, count); 198 | return PN532_STATUS_OK; 199 | } 200 | 201 | bool PN532_I2C_WaitReady(uint32_t timeout) { 202 | uint8_t status[] = {0x00}; 203 | uint32_t tickstart = millis(); 204 | while (millis() - tickstart < timeout) { 205 | i2c_read(status, sizeof(status)); 206 | if (status[0] == PN532_I2C_READY) { 207 | return true; 208 | } else { 209 | delay(5); 210 | } 211 | } 212 | return false; 213 | } 214 | 215 | int PN532_I2C_Wakeup(void) { 216 | digitalWrite(PN532_REQ, HIGH); 217 | delay(100); 218 | digitalWrite(PN532_REQ, LOW); 219 | delay(100); 220 | digitalWrite(PN532_REQ, HIGH); 221 | delay(500); 222 | return PN532_STATUS_OK; 223 | } 224 | 225 | void PN532_I2C_Init(PN532* pn532) { 226 | // init the pn532 functions 227 | pn532->reset = PN532_Reset; 228 | pn532->read_data = PN532_I2C_ReadData; 229 | pn532->write_data = PN532_I2C_WriteData; 230 | pn532->wait_ready = PN532_I2C_WaitReady; 231 | pn532->wakeup = PN532_I2C_Wakeup; 232 | pn532->log = PN532_Log; 233 | Serial.begin(115200); 234 | pinMode(PN532_REQ, OUTPUT); 235 | pinMode(PN532_RST, OUTPUT); 236 | Wire.begin(); 237 | Wire.beginTransmission(PN532_I2C_ADDRESS); 238 | // hardware reset 239 | pn532->reset(); 240 | // hardware wakeup 241 | pn532->wakeup(); 242 | } 243 | /************************************************************************** 244 | * End: I2C 245 | **************************************************************************/ -------------------------------------------------------------------------------- /examples/stm32/stm32_read_gpio/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | #include "pn532_stm32f1.h" 27 | /* USER CODE END Includes */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN PTD */ 31 | 32 | /* USER CODE END PTD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN PD */ 36 | 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | I2C_HandleTypeDef hi2c1; 46 | 47 | SPI_HandleTypeDef hspi1; 48 | 49 | UART_HandleTypeDef huart1; 50 | 51 | /* USER CODE BEGIN PV */ 52 | PN532 pn532; 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_SPI1_Init(void); 59 | static void MX_USART1_UART_Init(void); 60 | static void MX_I2C1_Init(void); 61 | /* USER CODE BEGIN PFP */ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* Private user code ---------------------------------------------------------*/ 66 | /* USER CODE BEGIN 0 */ 67 | 68 | /* USER CODE END 0 */ 69 | 70 | /** 71 | * @brief The application entry point. 72 | * @retval int 73 | */ 74 | int main(void) 75 | { 76 | /* USER CODE BEGIN 1 */ 77 | uint8_t buff[255]; 78 | bool pin_state = false; 79 | /* USER CODE END 1 */ 80 | 81 | /* MCU Configuration--------------------------------------------------------*/ 82 | 83 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 84 | HAL_Init(); 85 | 86 | /* USER CODE BEGIN Init */ 87 | 88 | /* USER CODE END Init */ 89 | 90 | /* Configure the system clock */ 91 | SystemClock_Config(); 92 | 93 | /* USER CODE BEGIN SysInit */ 94 | 95 | /* USER CODE END SysInit */ 96 | 97 | /* Initialize all configured peripherals */ 98 | MX_GPIO_Init(); 99 | MX_SPI1_Init(); 100 | MX_USART1_UART_Init(); 101 | MX_I2C1_Init(); 102 | /* USER CODE BEGIN 2 */ 103 | printf("Hello!\r\n"); 104 | PN532 pn532; 105 | // PN532_SPI_Init(&pn532); 106 | PN532_I2C_Init(&pn532); 107 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 108 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 109 | } else { 110 | return -1; 111 | } 112 | PN532_ReadGpio(&pn532, buff); 113 | printf("Port P3: 0x%02x\r\n", buff[0]); 114 | printf("Port P7: 0x%02x\r\n", buff[1]); 115 | printf("Port I: 0x%02x\r\n", buff[3]); 116 | for (uint8_t i = 30; i < 36; i++) { 117 | pin_state = PN532_ReadGpioP(&pn532, i); 118 | printf("Pin P%d: %d\r\n", i, pin_state); 119 | } 120 | for (uint8_t i = 0; i < 2; i++) { 121 | pin_state = PN532_ReadGpioI(&pn532, i); 122 | printf("Pin I%d: %d\r\n", i, pin_state); 123 | } 124 | /* USER CODE END 2 */ 125 | 126 | /* Infinite loop */ 127 | /* USER CODE BEGIN WHILE */ 128 | while (1) 129 | { 130 | /* USER CODE END WHILE */ 131 | 132 | /* USER CODE BEGIN 3 */ 133 | } 134 | /* USER CODE END 3 */ 135 | } 136 | 137 | /** 138 | * @brief System Clock Configuration 139 | * @retval None 140 | */ 141 | void SystemClock_Config(void) 142 | { 143 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 144 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 145 | 146 | /** Initializes the CPU, AHB and APB busses clocks 147 | */ 148 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 149 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 150 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 151 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 152 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 153 | { 154 | Error_Handler(); 155 | } 156 | /** Initializes the CPU, AHB and APB busses clocks 157 | */ 158 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 159 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 160 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 161 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 162 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 163 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 164 | 165 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 166 | { 167 | Error_Handler(); 168 | } 169 | } 170 | 171 | /** 172 | * @brief I2C1 Initialization Function 173 | * @param None 174 | * @retval None 175 | */ 176 | static void MX_I2C1_Init(void) 177 | { 178 | 179 | /* USER CODE BEGIN I2C1_Init 0 */ 180 | 181 | /* USER CODE END I2C1_Init 0 */ 182 | 183 | /* USER CODE BEGIN I2C1_Init 1 */ 184 | 185 | /* USER CODE END I2C1_Init 1 */ 186 | hi2c1.Instance = I2C1; 187 | hi2c1.Init.ClockSpeed = 100000; 188 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 189 | hi2c1.Init.OwnAddress1 = 144; 190 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 191 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 192 | hi2c1.Init.OwnAddress2 = 0; 193 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 194 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 195 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 196 | { 197 | Error_Handler(); 198 | } 199 | /* USER CODE BEGIN I2C1_Init 2 */ 200 | 201 | /* USER CODE END I2C1_Init 2 */ 202 | 203 | } 204 | 205 | /** 206 | * @brief SPI1 Initialization Function 207 | * @param None 208 | * @retval None 209 | */ 210 | static void MX_SPI1_Init(void) 211 | { 212 | 213 | /* USER CODE BEGIN SPI1_Init 0 */ 214 | 215 | /* USER CODE END SPI1_Init 0 */ 216 | 217 | /* USER CODE BEGIN SPI1_Init 1 */ 218 | 219 | /* USER CODE END SPI1_Init 1 */ 220 | /* SPI1 parameter configuration*/ 221 | hspi1.Instance = SPI1; 222 | hspi1.Init.Mode = SPI_MODE_MASTER; 223 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 224 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 225 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 226 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 227 | hspi1.Init.NSS = SPI_NSS_SOFT; 228 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; 229 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; 230 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 231 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 232 | hspi1.Init.CRCPolynomial = 10; 233 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 234 | { 235 | Error_Handler(); 236 | } 237 | /* USER CODE BEGIN SPI1_Init 2 */ 238 | 239 | /* USER CODE END SPI1_Init 2 */ 240 | 241 | } 242 | 243 | /** 244 | * @brief USART1 Initialization Function 245 | * @param None 246 | * @retval None 247 | */ 248 | static void MX_USART1_UART_Init(void) 249 | { 250 | 251 | /* USER CODE BEGIN USART1_Init 0 */ 252 | 253 | /* USER CODE END USART1_Init 0 */ 254 | 255 | /* USER CODE BEGIN USART1_Init 1 */ 256 | 257 | /* USER CODE END USART1_Init 1 */ 258 | huart1.Instance = USART1; 259 | huart1.Init.BaudRate = 115200; 260 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 261 | huart1.Init.StopBits = UART_STOPBITS_1; 262 | huart1.Init.Parity = UART_PARITY_NONE; 263 | huart1.Init.Mode = UART_MODE_TX_RX; 264 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 265 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 266 | if (HAL_UART_Init(&huart1) != HAL_OK) 267 | { 268 | Error_Handler(); 269 | } 270 | /* USER CODE BEGIN USART1_Init 2 */ 271 | 272 | /* USER CODE END USART1_Init 2 */ 273 | 274 | } 275 | 276 | /** 277 | * @brief GPIO Initialization Function 278 | * @param None 279 | * @retval None 280 | */ 281 | static void MX_GPIO_Init(void) 282 | { 283 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 284 | 285 | /* GPIO Ports Clock Enable */ 286 | __HAL_RCC_GPIOA_CLK_ENABLE(); 287 | __HAL_RCC_GPIOB_CLK_ENABLE(); 288 | 289 | /*Configure GPIO pin Output Level */ 290 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 291 | 292 | /*Configure GPIO pin Output Level */ 293 | HAL_GPIO_WritePin(GPIOB, PN532_RST_Pin|PN532_REQ_Pin, GPIO_PIN_SET); 294 | 295 | /*Configure GPIO pin : SS_Pin */ 296 | GPIO_InitStruct.Pin = SS_Pin; 297 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 298 | GPIO_InitStruct.Pull = GPIO_PULLUP; 299 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 300 | HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); 301 | 302 | /*Configure GPIO pins : PN532_RST_Pin PN532_REQ_Pin */ 303 | GPIO_InitStruct.Pin = PN532_RST_Pin|PN532_REQ_Pin; 304 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 305 | GPIO_InitStruct.Pull = GPIO_PULLUP; 306 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 307 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 308 | 309 | } 310 | 311 | /* USER CODE BEGIN 4 */ 312 | #ifdef __GNUC__ 313 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 314 | set to 'Yes') calls __io_putchar() */ 315 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 316 | #else 317 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 318 | #endif /* __GNUC__ */ 319 | /** 320 | * @brief Retargets the C library printf function to the USART. 321 | * @param None 322 | * @retval None 323 | */ 324 | PUTCHAR_PROTOTYPE 325 | { 326 | /* Place your implementation of fputc here */ 327 | /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ 328 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 329 | 330 | return ch; 331 | } 332 | /* USER CODE END 4 */ 333 | 334 | /** 335 | * @brief This function is executed in case of error occurrence. 336 | * @retval None 337 | */ 338 | void Error_Handler(void) 339 | { 340 | /* USER CODE BEGIN Error_Handler_Debug */ 341 | /* User can add his own implementation to report the HAL error return state */ 342 | 343 | /* USER CODE END Error_Handler_Debug */ 344 | } 345 | 346 | #ifdef USE_FULL_ASSERT 347 | /** 348 | * @brief Reports the name of the source file and the source line number 349 | * where the assert_param error has occurred. 350 | * @param file: pointer to the source file name 351 | * @param line: assert_param error line source number 352 | * @retval None 353 | */ 354 | void assert_failed(uint8_t *file, uint32_t line) 355 | { 356 | /* USER CODE BEGIN 6 */ 357 | /* User can add his own implementation to report the file name and line number, 358 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 359 | /* USER CODE END 6 */ 360 | } 361 | #endif /* USE_FULL_ASSERT */ 362 | 363 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 364 | -------------------------------------------------------------------------------- /examples/stm32/stm32_get_uid/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | #include "pn532_stm32f1.h" 27 | /* USER CODE END Includes */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN PTD */ 31 | 32 | /* USER CODE END PTD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN PD */ 36 | 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | I2C_HandleTypeDef hi2c1; 46 | 47 | SPI_HandleTypeDef hspi1; 48 | 49 | UART_HandleTypeDef huart1; 50 | 51 | /* USER CODE BEGIN PV */ 52 | PN532 pn532; 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_SPI1_Init(void); 59 | static void MX_USART1_UART_Init(void); 60 | static void MX_I2C1_Init(void); 61 | /* USER CODE BEGIN PFP */ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* Private user code ---------------------------------------------------------*/ 66 | /* USER CODE BEGIN 0 */ 67 | 68 | /* USER CODE END 0 */ 69 | 70 | /** 71 | * @brief The application entry point. 72 | * @retval int 73 | */ 74 | int main(void) 75 | { 76 | /* USER CODE BEGIN 1 */ 77 | uint8_t buff[255]; 78 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 79 | int32_t uid_len = 0; 80 | /* USER CODE END 1 */ 81 | 82 | /* MCU Configuration--------------------------------------------------------*/ 83 | 84 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 85 | HAL_Init(); 86 | 87 | /* USER CODE BEGIN Init */ 88 | 89 | /* USER CODE END Init */ 90 | 91 | /* Configure the system clock */ 92 | SystemClock_Config(); 93 | 94 | /* USER CODE BEGIN SysInit */ 95 | 96 | /* USER CODE END SysInit */ 97 | 98 | /* Initialize all configured peripherals */ 99 | MX_GPIO_Init(); 100 | MX_SPI1_Init(); 101 | MX_USART1_UART_Init(); 102 | MX_I2C1_Init(); 103 | /* USER CODE BEGIN 2 */ 104 | printf("Hello!\r\n"); 105 | PN532 pn532; 106 | // PN532_SPI_Init(&pn532); 107 | PN532_I2C_Init(&pn532); 108 | PN532_GetFirmwareVersion(&pn532, buff); 109 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 110 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 111 | } else { 112 | return -1; 113 | } 114 | PN532_SamConfiguration(&pn532); 115 | printf("Waiting for RFID/NFC card...\r\n"); 116 | /* USER CODE END 2 */ 117 | 118 | /* Infinite loop */ 119 | /* USER CODE BEGIN WHILE */ 120 | while (1) 121 | { 122 | /* USER CODE END WHILE */ 123 | 124 | /* USER CODE BEGIN 3 */ 125 | // Check if a card is available to read 126 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 127 | if (uid_len == PN532_STATUS_ERROR) { 128 | printf("."); 129 | } else { 130 | printf("Found card with UID: "); 131 | for (uint8_t i = 0; i < uid_len; i++) { 132 | printf("%02x ", uid[i]); 133 | } 134 | printf("\r\n"); 135 | } 136 | } 137 | /* USER CODE END 3 */ 138 | } 139 | 140 | /** 141 | * @brief System Clock Configuration 142 | * @retval None 143 | */ 144 | void SystemClock_Config(void) 145 | { 146 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 147 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 148 | 149 | /** Initializes the CPU, AHB and APB busses clocks 150 | */ 151 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 152 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 153 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 154 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 155 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 156 | { 157 | Error_Handler(); 158 | } 159 | /** Initializes the CPU, AHB and APB busses clocks 160 | */ 161 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 162 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 163 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 164 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 165 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 166 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 167 | 168 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 169 | { 170 | Error_Handler(); 171 | } 172 | } 173 | 174 | /** 175 | * @brief I2C1 Initialization Function 176 | * @param None 177 | * @retval None 178 | */ 179 | static void MX_I2C1_Init(void) 180 | { 181 | 182 | /* USER CODE BEGIN I2C1_Init 0 */ 183 | 184 | /* USER CODE END I2C1_Init 0 */ 185 | 186 | /* USER CODE BEGIN I2C1_Init 1 */ 187 | 188 | /* USER CODE END I2C1_Init 1 */ 189 | hi2c1.Instance = I2C1; 190 | hi2c1.Init.ClockSpeed = 100000; 191 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 192 | hi2c1.Init.OwnAddress1 = 144; 193 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 194 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 195 | hi2c1.Init.OwnAddress2 = 0; 196 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 197 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 198 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 199 | { 200 | Error_Handler(); 201 | } 202 | /* USER CODE BEGIN I2C1_Init 2 */ 203 | 204 | /* USER CODE END I2C1_Init 2 */ 205 | 206 | } 207 | 208 | /** 209 | * @brief SPI1 Initialization Function 210 | * @param None 211 | * @retval None 212 | */ 213 | static void MX_SPI1_Init(void) 214 | { 215 | 216 | /* USER CODE BEGIN SPI1_Init 0 */ 217 | 218 | /* USER CODE END SPI1_Init 0 */ 219 | 220 | /* USER CODE BEGIN SPI1_Init 1 */ 221 | 222 | /* USER CODE END SPI1_Init 1 */ 223 | /* SPI1 parameter configuration*/ 224 | hspi1.Instance = SPI1; 225 | hspi1.Init.Mode = SPI_MODE_MASTER; 226 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 227 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 228 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 229 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 230 | hspi1.Init.NSS = SPI_NSS_SOFT; 231 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; 232 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; 233 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 234 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 235 | hspi1.Init.CRCPolynomial = 10; 236 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 237 | { 238 | Error_Handler(); 239 | } 240 | /* USER CODE BEGIN SPI1_Init 2 */ 241 | 242 | /* USER CODE END SPI1_Init 2 */ 243 | 244 | } 245 | 246 | /** 247 | * @brief USART1 Initialization Function 248 | * @param None 249 | * @retval None 250 | */ 251 | static void MX_USART1_UART_Init(void) 252 | { 253 | 254 | /* USER CODE BEGIN USART1_Init 0 */ 255 | 256 | /* USER CODE END USART1_Init 0 */ 257 | 258 | /* USER CODE BEGIN USART1_Init 1 */ 259 | 260 | /* USER CODE END USART1_Init 1 */ 261 | huart1.Instance = USART1; 262 | huart1.Init.BaudRate = 115200; 263 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 264 | huart1.Init.StopBits = UART_STOPBITS_1; 265 | huart1.Init.Parity = UART_PARITY_NONE; 266 | huart1.Init.Mode = UART_MODE_TX_RX; 267 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 268 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 269 | if (HAL_UART_Init(&huart1) != HAL_OK) 270 | { 271 | Error_Handler(); 272 | } 273 | /* USER CODE BEGIN USART1_Init 2 */ 274 | 275 | /* USER CODE END USART1_Init 2 */ 276 | 277 | } 278 | 279 | /** 280 | * @brief GPIO Initialization Function 281 | * @param None 282 | * @retval None 283 | */ 284 | static void MX_GPIO_Init(void) 285 | { 286 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 287 | 288 | /* GPIO Ports Clock Enable */ 289 | __HAL_RCC_GPIOA_CLK_ENABLE(); 290 | __HAL_RCC_GPIOB_CLK_ENABLE(); 291 | 292 | /*Configure GPIO pin Output Level */ 293 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 294 | 295 | /*Configure GPIO pin Output Level */ 296 | HAL_GPIO_WritePin(GPIOB, PN532_RST_Pin|PN532_REQ_Pin, GPIO_PIN_SET); 297 | 298 | /*Configure GPIO pin : SS_Pin */ 299 | GPIO_InitStruct.Pin = SS_Pin; 300 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 301 | GPIO_InitStruct.Pull = GPIO_PULLUP; 302 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 303 | HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); 304 | 305 | /*Configure GPIO pins : PN532_RST_Pin PN532_REQ_Pin */ 306 | GPIO_InitStruct.Pin = PN532_RST_Pin|PN532_REQ_Pin; 307 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 308 | GPIO_InitStruct.Pull = GPIO_PULLUP; 309 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 310 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 311 | 312 | } 313 | 314 | /* USER CODE BEGIN 4 */ 315 | #ifdef __GNUC__ 316 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 317 | set to 'Yes') calls __io_putchar() */ 318 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 319 | #else 320 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 321 | #endif /* __GNUC__ */ 322 | /** 323 | * @brief Retargets the C library printf function to the USART. 324 | * @param None 325 | * @retval None 326 | */ 327 | PUTCHAR_PROTOTYPE 328 | { 329 | /* Place your implementation of fputc here */ 330 | /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ 331 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 332 | 333 | return ch; 334 | } 335 | /* USER CODE END 4 */ 336 | 337 | /** 338 | * @brief This function is executed in case of error occurrence. 339 | * @retval None 340 | */ 341 | void Error_Handler(void) 342 | { 343 | /* USER CODE BEGIN Error_Handler_Debug */ 344 | /* User can add his own implementation to report the HAL error return state */ 345 | 346 | /* USER CODE END Error_Handler_Debug */ 347 | } 348 | 349 | #ifdef USE_FULL_ASSERT 350 | /** 351 | * @brief Reports the name of the source file and the source line number 352 | * where the assert_param error has occurred. 353 | * @param file: pointer to the source file name 354 | * @param line: assert_param error line source number 355 | * @retval None 356 | */ 357 | void assert_failed(uint8_t *file, uint32_t line) 358 | { 359 | /* USER CODE BEGIN 6 */ 360 | /* User can add his own implementation to report the file name and line number, 361 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 362 | /* USER CODE END 6 */ 363 | } 364 | #endif /* USE_FULL_ASSERT */ 365 | 366 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 367 | -------------------------------------------------------------------------------- /examples/stm32/stm32_write_gpio/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | #include "pn532_stm32f1.h" 27 | /* USER CODE END Includes */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN PTD */ 31 | 32 | /* USER CODE END PTD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN PD */ 36 | 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | I2C_HandleTypeDef hi2c1; 46 | 47 | SPI_HandleTypeDef hspi1; 48 | 49 | UART_HandleTypeDef huart1; 50 | 51 | /* USER CODE BEGIN PV */ 52 | PN532 pn532; 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_SPI1_Init(void); 59 | static void MX_USART1_UART_Init(void); 60 | static void MX_I2C1_Init(void); 61 | /* USER CODE BEGIN PFP */ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* Private user code ---------------------------------------------------------*/ 66 | /* USER CODE BEGIN 0 */ 67 | 68 | /* USER CODE END 0 */ 69 | 70 | /** 71 | * @brief The application entry point. 72 | * @retval int 73 | */ 74 | int main(void) 75 | { 76 | /* USER CODE BEGIN 1 */ 77 | uint8_t buff[255]; 78 | bool pin_state = false; 79 | /* USER CODE END 1 */ 80 | 81 | /* MCU Configuration--------------------------------------------------------*/ 82 | 83 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 84 | HAL_Init(); 85 | 86 | /* USER CODE BEGIN Init */ 87 | 88 | /* USER CODE END Init */ 89 | 90 | /* Configure the system clock */ 91 | SystemClock_Config(); 92 | 93 | /* USER CODE BEGIN SysInit */ 94 | 95 | /* USER CODE END SysInit */ 96 | 97 | /* Initialize all configured peripherals */ 98 | MX_GPIO_Init(); 99 | MX_SPI1_Init(); 100 | MX_USART1_UART_Init(); 101 | MX_I2C1_Init(); 102 | /* USER CODE BEGIN 2 */ 103 | printf("Hello!\r\n"); 104 | PN532 pn532; 105 | // PN532_SPI_Init(&pn532); 106 | PN532_I2C_Init(&pn532); 107 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 108 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 109 | } else { 110 | return -1; 111 | } 112 | PN532_WriteGpioP(&pn532, 30, true); 113 | PN532_WriteGpioP(&pn532, 31, false); 114 | //PN532_WriteGpioP(&pn532, 32, true); // Reserved, don't change this 115 | PN532_WriteGpioP(&pn532, 33, false); 116 | //PN532_WriteGpioP(&pn532, 34, true); // Reserved, don't change this 117 | PN532_WriteGpioP(&pn532, 35, false); 118 | PN532_WriteGpioP(&pn532, 71, false); // Always HIGH in SPI mode 119 | PN532_WriteGpioP(&pn532, 72, true); // Always HIGH in SPI mode 120 | for (uint8_t i = 30; i < 36; i++) { 121 | pin_state = PN532_ReadGpioP(&pn532, i); 122 | printf("Pin P%d: %d\r\n", i, pin_state); 123 | } 124 | for (uint8_t i = 71; i < 73; i++) { 125 | pin_state = PN532_ReadGpioP(&pn532, i); 126 | printf("Pin P%d: %d\r\n", i, pin_state); 127 | } 128 | for (uint8_t i = 0; i < 2; i++) { 129 | pin_state = PN532_ReadGpioI(&pn532, i); 130 | printf("Pin I%d: %d\r\n", i, pin_state); 131 | } 132 | /* USER CODE END 2 */ 133 | 134 | /* Infinite loop */ 135 | /* USER CODE BEGIN WHILE */ 136 | while (1) 137 | { 138 | /* USER CODE END WHILE */ 139 | 140 | /* USER CODE BEGIN 3 */ 141 | } 142 | /* USER CODE END 3 */ 143 | } 144 | 145 | /** 146 | * @brief System Clock Configuration 147 | * @retval None 148 | */ 149 | void SystemClock_Config(void) 150 | { 151 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 152 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 153 | 154 | /** Initializes the CPU, AHB and APB busses clocks 155 | */ 156 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 157 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 158 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 159 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 160 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 161 | { 162 | Error_Handler(); 163 | } 164 | /** Initializes the CPU, AHB and APB busses clocks 165 | */ 166 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 167 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 168 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 169 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 170 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 171 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 172 | 173 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 174 | { 175 | Error_Handler(); 176 | } 177 | } 178 | 179 | /** 180 | * @brief I2C1 Initialization Function 181 | * @param None 182 | * @retval None 183 | */ 184 | static void MX_I2C1_Init(void) 185 | { 186 | 187 | /* USER CODE BEGIN I2C1_Init 0 */ 188 | 189 | /* USER CODE END I2C1_Init 0 */ 190 | 191 | /* USER CODE BEGIN I2C1_Init 1 */ 192 | 193 | /* USER CODE END I2C1_Init 1 */ 194 | hi2c1.Instance = I2C1; 195 | hi2c1.Init.ClockSpeed = 100000; 196 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 197 | hi2c1.Init.OwnAddress1 = 144; 198 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 199 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 200 | hi2c1.Init.OwnAddress2 = 0; 201 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 202 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 203 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 204 | { 205 | Error_Handler(); 206 | } 207 | /* USER CODE BEGIN I2C1_Init 2 */ 208 | 209 | /* USER CODE END I2C1_Init 2 */ 210 | 211 | } 212 | 213 | /** 214 | * @brief SPI1 Initialization Function 215 | * @param None 216 | * @retval None 217 | */ 218 | static void MX_SPI1_Init(void) 219 | { 220 | 221 | /* USER CODE BEGIN SPI1_Init 0 */ 222 | 223 | /* USER CODE END SPI1_Init 0 */ 224 | 225 | /* USER CODE BEGIN SPI1_Init 1 */ 226 | 227 | /* USER CODE END SPI1_Init 1 */ 228 | /* SPI1 parameter configuration*/ 229 | hspi1.Instance = SPI1; 230 | hspi1.Init.Mode = SPI_MODE_MASTER; 231 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 232 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 233 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 234 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 235 | hspi1.Init.NSS = SPI_NSS_SOFT; 236 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; 237 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; 238 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 239 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 240 | hspi1.Init.CRCPolynomial = 10; 241 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 242 | { 243 | Error_Handler(); 244 | } 245 | /* USER CODE BEGIN SPI1_Init 2 */ 246 | 247 | /* USER CODE END SPI1_Init 2 */ 248 | 249 | } 250 | 251 | /** 252 | * @brief USART1 Initialization Function 253 | * @param None 254 | * @retval None 255 | */ 256 | static void MX_USART1_UART_Init(void) 257 | { 258 | 259 | /* USER CODE BEGIN USART1_Init 0 */ 260 | 261 | /* USER CODE END USART1_Init 0 */ 262 | 263 | /* USER CODE BEGIN USART1_Init 1 */ 264 | 265 | /* USER CODE END USART1_Init 1 */ 266 | huart1.Instance = USART1; 267 | huart1.Init.BaudRate = 115200; 268 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 269 | huart1.Init.StopBits = UART_STOPBITS_1; 270 | huart1.Init.Parity = UART_PARITY_NONE; 271 | huart1.Init.Mode = UART_MODE_TX_RX; 272 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 273 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 274 | if (HAL_UART_Init(&huart1) != HAL_OK) 275 | { 276 | Error_Handler(); 277 | } 278 | /* USER CODE BEGIN USART1_Init 2 */ 279 | 280 | /* USER CODE END USART1_Init 2 */ 281 | 282 | } 283 | 284 | /** 285 | * @brief GPIO Initialization Function 286 | * @param None 287 | * @retval None 288 | */ 289 | static void MX_GPIO_Init(void) 290 | { 291 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 292 | 293 | /* GPIO Ports Clock Enable */ 294 | __HAL_RCC_GPIOA_CLK_ENABLE(); 295 | __HAL_RCC_GPIOB_CLK_ENABLE(); 296 | 297 | /*Configure GPIO pin Output Level */ 298 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 299 | 300 | /*Configure GPIO pin Output Level */ 301 | HAL_GPIO_WritePin(GPIOB, PN532_RST_Pin|PN532_REQ_Pin, GPIO_PIN_SET); 302 | 303 | /*Configure GPIO pin : SS_Pin */ 304 | GPIO_InitStruct.Pin = SS_Pin; 305 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 306 | GPIO_InitStruct.Pull = GPIO_PULLUP; 307 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 308 | HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); 309 | 310 | /*Configure GPIO pins : PN532_RST_Pin PN532_REQ_Pin */ 311 | GPIO_InitStruct.Pin = PN532_RST_Pin|PN532_REQ_Pin; 312 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 313 | GPIO_InitStruct.Pull = GPIO_PULLUP; 314 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 315 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 316 | 317 | } 318 | 319 | /* USER CODE BEGIN 4 */ 320 | #ifdef __GNUC__ 321 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 322 | set to 'Yes') calls __io_putchar() */ 323 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 324 | #else 325 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 326 | #endif /* __GNUC__ */ 327 | /** 328 | * @brief Retargets the C library printf function to the USART. 329 | * @param None 330 | * @retval None 331 | */ 332 | PUTCHAR_PROTOTYPE 333 | { 334 | /* Place your implementation of fputc here */ 335 | /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ 336 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 337 | 338 | return ch; 339 | } 340 | /* USER CODE END 4 */ 341 | 342 | /** 343 | * @brief This function is executed in case of error occurrence. 344 | * @retval None 345 | */ 346 | void Error_Handler(void) 347 | { 348 | /* USER CODE BEGIN Error_Handler_Debug */ 349 | /* User can add his own implementation to report the HAL error return state */ 350 | 351 | /* USER CODE END Error_Handler_Debug */ 352 | } 353 | 354 | #ifdef USE_FULL_ASSERT 355 | /** 356 | * @brief Reports the name of the source file and the source line number 357 | * where the assert_param error has occurred. 358 | * @param file: pointer to the source file name 359 | * @param line: assert_param error line source number 360 | * @retval None 361 | */ 362 | void assert_failed(uint8_t *file, uint32_t line) 363 | { 364 | /* USER CODE BEGIN 6 */ 365 | /* User can add his own implementation to report the file name and line number, 366 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 367 | /* USER CODE END 6 */ 368 | } 369 | #endif /* USE_FULL_ASSERT */ 370 | 371 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 372 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_ntag2/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | #include "pn532_stm32f1.h" 27 | /* USER CODE END Includes */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN PTD */ 31 | 32 | /* USER CODE END PTD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN PD */ 36 | 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | I2C_HandleTypeDef hi2c1; 46 | 47 | SPI_HandleTypeDef hspi1; 48 | 49 | UART_HandleTypeDef huart1; 50 | 51 | /* USER CODE BEGIN PV */ 52 | PN532 pn532; 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_SPI1_Init(void); 59 | static void MX_USART1_UART_Init(void); 60 | static void MX_I2C1_Init(void); 61 | /* USER CODE BEGIN PFP */ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* Private user code ---------------------------------------------------------*/ 66 | /* USER CODE BEGIN 0 */ 67 | 68 | /* USER CODE END 0 */ 69 | 70 | /** 71 | * @brief The application entry point. 72 | * @retval int 73 | */ 74 | int main(void) 75 | { 76 | /* USER CODE BEGIN 1 */ 77 | uint8_t buff[255]; 78 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 79 | uint32_t pn532_error = PN532_ERROR_NONE; 80 | int32_t uid_len = 0; 81 | /* USER CODE END 1 */ 82 | 83 | /* MCU Configuration--------------------------------------------------------*/ 84 | 85 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 86 | HAL_Init(); 87 | 88 | /* USER CODE BEGIN Init */ 89 | 90 | /* USER CODE END Init */ 91 | 92 | /* Configure the system clock */ 93 | SystemClock_Config(); 94 | 95 | /* USER CODE BEGIN SysInit */ 96 | 97 | /* USER CODE END SysInit */ 98 | 99 | /* Initialize all configured peripherals */ 100 | MX_GPIO_Init(); 101 | MX_SPI1_Init(); 102 | MX_USART1_UART_Init(); 103 | MX_I2C1_Init(); 104 | /* USER CODE BEGIN 2 */ 105 | printf("Hello!\r\n"); 106 | PN532 pn532; 107 | // PN532_SPI_Init(&pn532); 108 | PN532_I2C_Init(&pn532); 109 | PN532_GetFirmwareVersion(&pn532, buff); 110 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 111 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 112 | } else { 113 | return -1; 114 | } 115 | PN532_SamConfiguration(&pn532); 116 | printf("Waiting for RFID/NFC card...\r\n"); 117 | /* USER CODE END 2 */ 118 | 119 | /* Infinite loop */ 120 | /* USER CODE BEGIN WHILE */ 121 | while (1) 122 | { 123 | /* USER CODE END WHILE */ 124 | 125 | /* USER CODE BEGIN 3 */ 126 | // Check if a card is available to read 127 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 128 | if (uid_len == PN532_STATUS_ERROR) { 129 | printf("."); 130 | } else { 131 | printf("Found card with UID: "); 132 | for (uint8_t i = 0; i < uid_len; i++) { 133 | printf("%02x ", uid[i]); 134 | } 135 | printf("\r\n"); 136 | break; 137 | } 138 | } 139 | printf("Reading blocks...\r\n"); 140 | for (uint8_t block_number = 0; block_number < 135; block_number++) { 141 | pn532_error = PN532_Ntag2xxReadBlock(&pn532, buff, block_number); 142 | if (pn532_error != PN532_ERROR_NONE) { 143 | break; 144 | } 145 | printf("%d: ", block_number); 146 | for (uint8_t i = 0; i < 4; i++) { 147 | printf("%02x ", buff[i]); 148 | } 149 | printf("\r\n"); 150 | } 151 | if (pn532_error) { 152 | printf("Error: 0x%02x\r\n", pn532_error); 153 | } 154 | /* USER CODE END 3 */ 155 | } 156 | 157 | /** 158 | * @brief System Clock Configuration 159 | * @retval None 160 | */ 161 | void SystemClock_Config(void) 162 | { 163 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 164 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 165 | 166 | /** Initializes the CPU, AHB and APB busses clocks 167 | */ 168 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 169 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 170 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 171 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 172 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 173 | { 174 | Error_Handler(); 175 | } 176 | /** Initializes the CPU, AHB and APB busses clocks 177 | */ 178 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 179 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 180 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 181 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 182 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 183 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 184 | 185 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 186 | { 187 | Error_Handler(); 188 | } 189 | } 190 | 191 | /** 192 | * @brief I2C1 Initialization Function 193 | * @param None 194 | * @retval None 195 | */ 196 | static void MX_I2C1_Init(void) 197 | { 198 | 199 | /* USER CODE BEGIN I2C1_Init 0 */ 200 | 201 | /* USER CODE END I2C1_Init 0 */ 202 | 203 | /* USER CODE BEGIN I2C1_Init 1 */ 204 | 205 | /* USER CODE END I2C1_Init 1 */ 206 | hi2c1.Instance = I2C1; 207 | hi2c1.Init.ClockSpeed = 100000; 208 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 209 | hi2c1.Init.OwnAddress1 = 144; 210 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 211 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 212 | hi2c1.Init.OwnAddress2 = 0; 213 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 214 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 215 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 216 | { 217 | Error_Handler(); 218 | } 219 | /* USER CODE BEGIN I2C1_Init 2 */ 220 | 221 | /* USER CODE END I2C1_Init 2 */ 222 | 223 | } 224 | 225 | /** 226 | * @brief SPI1 Initialization Function 227 | * @param None 228 | * @retval None 229 | */ 230 | static void MX_SPI1_Init(void) 231 | { 232 | 233 | /* USER CODE BEGIN SPI1_Init 0 */ 234 | 235 | /* USER CODE END SPI1_Init 0 */ 236 | 237 | /* USER CODE BEGIN SPI1_Init 1 */ 238 | 239 | /* USER CODE END SPI1_Init 1 */ 240 | /* SPI1 parameter configuration*/ 241 | hspi1.Instance = SPI1; 242 | hspi1.Init.Mode = SPI_MODE_MASTER; 243 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 244 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 245 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 246 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 247 | hspi1.Init.NSS = SPI_NSS_SOFT; 248 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; 249 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; 250 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 251 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 252 | hspi1.Init.CRCPolynomial = 10; 253 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 254 | { 255 | Error_Handler(); 256 | } 257 | /* USER CODE BEGIN SPI1_Init 2 */ 258 | 259 | /* USER CODE END SPI1_Init 2 */ 260 | 261 | } 262 | 263 | /** 264 | * @brief USART1 Initialization Function 265 | * @param None 266 | * @retval None 267 | */ 268 | static void MX_USART1_UART_Init(void) 269 | { 270 | 271 | /* USER CODE BEGIN USART1_Init 0 */ 272 | 273 | /* USER CODE END USART1_Init 0 */ 274 | 275 | /* USER CODE BEGIN USART1_Init 1 */ 276 | 277 | /* USER CODE END USART1_Init 1 */ 278 | huart1.Instance = USART1; 279 | huart1.Init.BaudRate = 115200; 280 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 281 | huart1.Init.StopBits = UART_STOPBITS_1; 282 | huart1.Init.Parity = UART_PARITY_NONE; 283 | huart1.Init.Mode = UART_MODE_TX_RX; 284 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 285 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 286 | if (HAL_UART_Init(&huart1) != HAL_OK) 287 | { 288 | Error_Handler(); 289 | } 290 | /* USER CODE BEGIN USART1_Init 2 */ 291 | 292 | /* USER CODE END USART1_Init 2 */ 293 | 294 | } 295 | 296 | /** 297 | * @brief GPIO Initialization Function 298 | * @param None 299 | * @retval None 300 | */ 301 | static void MX_GPIO_Init(void) 302 | { 303 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 304 | 305 | /* GPIO Ports Clock Enable */ 306 | __HAL_RCC_GPIOA_CLK_ENABLE(); 307 | __HAL_RCC_GPIOB_CLK_ENABLE(); 308 | 309 | /*Configure GPIO pin Output Level */ 310 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 311 | 312 | /*Configure GPIO pin Output Level */ 313 | HAL_GPIO_WritePin(GPIOB, PN532_RST_Pin|PN532_REQ_Pin, GPIO_PIN_SET); 314 | 315 | /*Configure GPIO pin : SS_Pin */ 316 | GPIO_InitStruct.Pin = SS_Pin; 317 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 318 | GPIO_InitStruct.Pull = GPIO_PULLUP; 319 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 320 | HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); 321 | 322 | /*Configure GPIO pins : PN532_RST_Pin PN532_REQ_Pin */ 323 | GPIO_InitStruct.Pin = PN532_RST_Pin|PN532_REQ_Pin; 324 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 325 | GPIO_InitStruct.Pull = GPIO_PULLUP; 326 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 327 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 328 | 329 | } 330 | 331 | /* USER CODE BEGIN 4 */ 332 | #ifdef __GNUC__ 333 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 334 | set to 'Yes') calls __io_putchar() */ 335 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 336 | #else 337 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 338 | #endif /* __GNUC__ */ 339 | /** 340 | * @brief Retargets the C library printf function to the USART. 341 | * @param None 342 | * @retval None 343 | */ 344 | PUTCHAR_PROTOTYPE 345 | { 346 | /* Place your implementation of fputc here */ 347 | /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ 348 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 349 | 350 | return ch; 351 | } 352 | /* USER CODE END 4 */ 353 | 354 | /** 355 | * @brief This function is executed in case of error occurrence. 356 | * @retval None 357 | */ 358 | void Error_Handler(void) 359 | { 360 | /* USER CODE BEGIN Error_Handler_Debug */ 361 | /* User can add his own implementation to report the HAL error return state */ 362 | 363 | /* USER CODE END Error_Handler_Debug */ 364 | } 365 | 366 | #ifdef USE_FULL_ASSERT 367 | /** 368 | * @brief Reports the name of the source file and the source line number 369 | * where the assert_param error has occurred. 370 | * @param file: pointer to the source file name 371 | * @param line: assert_param error line source number 372 | * @retval None 373 | */ 374 | void assert_failed(uint8_t *file, uint32_t line) 375 | { 376 | /* USER CODE BEGIN 6 */ 377 | /* User can add his own implementation to report the file name and line number, 378 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 379 | /* USER CODE END 6 */ 380 | } 381 | #endif /* USE_FULL_ASSERT */ 382 | 383 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 384 | -------------------------------------------------------------------------------- /examples/stm32/stm32_rw_ntag2/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | #include "pn532_stm32f1.h" 27 | /* USER CODE END Includes */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN PTD */ 31 | 32 | /* USER CODE END PTD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN PD */ 36 | 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | I2C_HandleTypeDef hi2c1; 46 | 47 | SPI_HandleTypeDef hspi1; 48 | 49 | UART_HandleTypeDef huart1; 50 | 51 | /* USER CODE BEGIN PV */ 52 | PN532 pn532; 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_SPI1_Init(void); 59 | static void MX_USART1_UART_Init(void); 60 | static void MX_I2C1_Init(void); 61 | /* USER CODE BEGIN PFP */ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* Private user code ---------------------------------------------------------*/ 66 | /* USER CODE BEGIN 0 */ 67 | 68 | /* USER CODE END 0 */ 69 | 70 | /** 71 | * @brief The application entry point. 72 | * @retval int 73 | */ 74 | int main(void) 75 | { 76 | /* USER CODE BEGIN 1 */ 77 | uint8_t buff[255]; 78 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 79 | uint32_t pn532_error = PN532_ERROR_NONE; 80 | int32_t uid_len = 0; 81 | /* USER CODE END 1 */ 82 | 83 | /* MCU Configuration--------------------------------------------------------*/ 84 | 85 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 86 | HAL_Init(); 87 | 88 | /* USER CODE BEGIN Init */ 89 | 90 | /* USER CODE END Init */ 91 | 92 | /* Configure the system clock */ 93 | SystemClock_Config(); 94 | 95 | /* USER CODE BEGIN SysInit */ 96 | 97 | /* USER CODE END SysInit */ 98 | 99 | /* Initialize all configured peripherals */ 100 | MX_GPIO_Init(); 101 | MX_SPI1_Init(); 102 | MX_USART1_UART_Init(); 103 | MX_I2C1_Init(); 104 | /* USER CODE BEGIN 2 */ 105 | printf("Hello!\r\n"); 106 | PN532 pn532; 107 | // PN532_SPI_Init(&pn532); 108 | PN532_I2C_Init(&pn532); 109 | PN532_GetFirmwareVersion(&pn532, buff); 110 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 111 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 112 | } else { 113 | return -1; 114 | } 115 | PN532_SamConfiguration(&pn532); 116 | printf("Waiting for RFID/NFC card...\r\n"); 117 | /* USER CODE END 2 */ 118 | 119 | /* Infinite loop */ 120 | /* USER CODE BEGIN WHILE */ 121 | while (1) 122 | { 123 | /* USER CODE END WHILE */ 124 | 125 | /* USER CODE BEGIN 3 */ 126 | // Check if a card is available to read 127 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 128 | if (uid_len == PN532_STATUS_ERROR) { 129 | printf("."); 130 | } else { 131 | printf("Found card with UID: "); 132 | for (uint8_t i = 0; i < uid_len; i++) { 133 | printf("%02x ", uid[i]); 134 | } 135 | printf("\r\n"); 136 | break; 137 | } 138 | } 139 | // Write block #6 140 | uint8_t block_number = 6; 141 | uint8_t DATA[] = {0x00, 0x01, 0x02, 0x03}; 142 | pn532_error = PN532_Ntag2xxWriteBlock(&pn532, DATA, block_number); 143 | if (pn532_error) { 144 | printf("Error: 0x%02x\r\n", pn532_error); 145 | return -1; 146 | } 147 | pn532_error = PN532_Ntag2xxReadBlock(&pn532, buff, block_number); 148 | if (pn532_error) { 149 | printf("Error: 0x%02x\r\n", pn532_error); 150 | return -1; 151 | } 152 | for (uint8_t i = 0; i < sizeof(DATA); i++) { 153 | if (DATA[i] != buff[i]) { 154 | printf("Write block %d failed\r\n", block_number); 155 | return -1; 156 | } 157 | } 158 | printf("Write block %d successfully\r\n", block_number); 159 | /* USER CODE END 3 */ 160 | } 161 | 162 | /** 163 | * @brief System Clock Configuration 164 | * @retval None 165 | */ 166 | void SystemClock_Config(void) 167 | { 168 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 169 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 170 | 171 | /** Initializes the CPU, AHB and APB busses clocks 172 | */ 173 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 174 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 175 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 176 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 177 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 178 | { 179 | Error_Handler(); 180 | } 181 | /** Initializes the CPU, AHB and APB busses clocks 182 | */ 183 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 184 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 185 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 186 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 187 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 188 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 189 | 190 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 191 | { 192 | Error_Handler(); 193 | } 194 | } 195 | 196 | /** 197 | * @brief I2C1 Initialization Function 198 | * @param None 199 | * @retval None 200 | */ 201 | static void MX_I2C1_Init(void) 202 | { 203 | 204 | /* USER CODE BEGIN I2C1_Init 0 */ 205 | 206 | /* USER CODE END I2C1_Init 0 */ 207 | 208 | /* USER CODE BEGIN I2C1_Init 1 */ 209 | 210 | /* USER CODE END I2C1_Init 1 */ 211 | hi2c1.Instance = I2C1; 212 | hi2c1.Init.ClockSpeed = 100000; 213 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 214 | hi2c1.Init.OwnAddress1 = 144; 215 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 216 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 217 | hi2c1.Init.OwnAddress2 = 0; 218 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 219 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 220 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 221 | { 222 | Error_Handler(); 223 | } 224 | /* USER CODE BEGIN I2C1_Init 2 */ 225 | 226 | /* USER CODE END I2C1_Init 2 */ 227 | 228 | } 229 | 230 | /** 231 | * @brief SPI1 Initialization Function 232 | * @param None 233 | * @retval None 234 | */ 235 | static void MX_SPI1_Init(void) 236 | { 237 | 238 | /* USER CODE BEGIN SPI1_Init 0 */ 239 | 240 | /* USER CODE END SPI1_Init 0 */ 241 | 242 | /* USER CODE BEGIN SPI1_Init 1 */ 243 | 244 | /* USER CODE END SPI1_Init 1 */ 245 | /* SPI1 parameter configuration*/ 246 | hspi1.Instance = SPI1; 247 | hspi1.Init.Mode = SPI_MODE_MASTER; 248 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 249 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 250 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 251 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 252 | hspi1.Init.NSS = SPI_NSS_SOFT; 253 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; 254 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; 255 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 256 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 257 | hspi1.Init.CRCPolynomial = 10; 258 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 259 | { 260 | Error_Handler(); 261 | } 262 | /* USER CODE BEGIN SPI1_Init 2 */ 263 | 264 | /* USER CODE END SPI1_Init 2 */ 265 | 266 | } 267 | 268 | /** 269 | * @brief USART1 Initialization Function 270 | * @param None 271 | * @retval None 272 | */ 273 | static void MX_USART1_UART_Init(void) 274 | { 275 | 276 | /* USER CODE BEGIN USART1_Init 0 */ 277 | 278 | /* USER CODE END USART1_Init 0 */ 279 | 280 | /* USER CODE BEGIN USART1_Init 1 */ 281 | 282 | /* USER CODE END USART1_Init 1 */ 283 | huart1.Instance = USART1; 284 | huart1.Init.BaudRate = 115200; 285 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 286 | huart1.Init.StopBits = UART_STOPBITS_1; 287 | huart1.Init.Parity = UART_PARITY_NONE; 288 | huart1.Init.Mode = UART_MODE_TX_RX; 289 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 290 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 291 | if (HAL_UART_Init(&huart1) != HAL_OK) 292 | { 293 | Error_Handler(); 294 | } 295 | /* USER CODE BEGIN USART1_Init 2 */ 296 | 297 | /* USER CODE END USART1_Init 2 */ 298 | 299 | } 300 | 301 | /** 302 | * @brief GPIO Initialization Function 303 | * @param None 304 | * @retval None 305 | */ 306 | static void MX_GPIO_Init(void) 307 | { 308 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 309 | 310 | /* GPIO Ports Clock Enable */ 311 | __HAL_RCC_GPIOA_CLK_ENABLE(); 312 | __HAL_RCC_GPIOB_CLK_ENABLE(); 313 | 314 | /*Configure GPIO pin Output Level */ 315 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 316 | 317 | /*Configure GPIO pin Output Level */ 318 | HAL_GPIO_WritePin(GPIOB, PN532_RST_Pin|PN532_REQ_Pin, GPIO_PIN_SET); 319 | 320 | /*Configure GPIO pin : SS_Pin */ 321 | GPIO_InitStruct.Pin = SS_Pin; 322 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 323 | GPIO_InitStruct.Pull = GPIO_PULLUP; 324 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 325 | HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); 326 | 327 | /*Configure GPIO pins : PN532_RST_Pin PN532_REQ_Pin */ 328 | GPIO_InitStruct.Pin = PN532_RST_Pin|PN532_REQ_Pin; 329 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 330 | GPIO_InitStruct.Pull = GPIO_PULLUP; 331 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 332 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 333 | 334 | } 335 | 336 | /* USER CODE BEGIN 4 */ 337 | #ifdef __GNUC__ 338 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 339 | set to 'Yes') calls __io_putchar() */ 340 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 341 | #else 342 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 343 | #endif /* __GNUC__ */ 344 | /** 345 | * @brief Retargets the C library printf function to the USART. 346 | * @param None 347 | * @retval None 348 | */ 349 | PUTCHAR_PROTOTYPE 350 | { 351 | /* Place your implementation of fputc here */ 352 | /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ 353 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 354 | 355 | return ch; 356 | } 357 | /* USER CODE END 4 */ 358 | 359 | /** 360 | * @brief This function is executed in case of error occurrence. 361 | * @retval None 362 | */ 363 | void Error_Handler(void) 364 | { 365 | /* USER CODE BEGIN Error_Handler_Debug */ 366 | /* User can add his own implementation to report the HAL error return state */ 367 | 368 | /* USER CODE END Error_Handler_Debug */ 369 | } 370 | 371 | #ifdef USE_FULL_ASSERT 372 | /** 373 | * @brief Reports the name of the source file and the source line number 374 | * where the assert_param error has occurred. 375 | * @param file: pointer to the source file name 376 | * @param line: assert_param error line source number 377 | * @retval None 378 | */ 379 | void assert_failed(uint8_t *file, uint32_t line) 380 | { 381 | /* USER CODE BEGIN 6 */ 382 | /* User can add his own implementation to report the file name and line number, 383 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 384 | /* USER CODE END 6 */ 385 | } 386 | #endif /* USE_FULL_ASSERT */ 387 | 388 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 389 | -------------------------------------------------------------------------------- /examples/stm32/stm32_dump_mifare/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | #include "pn532_stm32f1.h" 27 | /* USER CODE END Includes */ 28 | 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* USER CODE BEGIN PTD */ 31 | 32 | /* USER CODE END PTD */ 33 | 34 | /* Private define ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN PD */ 36 | 37 | /* USER CODE END PD */ 38 | 39 | /* Private macro -------------------------------------------------------------*/ 40 | /* USER CODE BEGIN PM */ 41 | 42 | /* USER CODE END PM */ 43 | 44 | /* Private variables ---------------------------------------------------------*/ 45 | I2C_HandleTypeDef hi2c1; 46 | 47 | SPI_HandleTypeDef hspi1; 48 | 49 | UART_HandleTypeDef huart1; 50 | 51 | /* USER CODE BEGIN PV */ 52 | PN532 pn532; 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_SPI1_Init(void); 59 | static void MX_USART1_UART_Init(void); 60 | static void MX_I2C1_Init(void); 61 | /* USER CODE BEGIN PFP */ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* Private user code ---------------------------------------------------------*/ 66 | /* USER CODE BEGIN 0 */ 67 | 68 | /* USER CODE END 0 */ 69 | 70 | /** 71 | * @brief The application entry point. 72 | * @retval int 73 | */ 74 | int main(void) 75 | { 76 | /* USER CODE BEGIN 1 */ 77 | uint8_t buff[255]; 78 | uint8_t uid[MIFARE_UID_MAX_LENGTH]; 79 | uint8_t key_a[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 80 | uint32_t pn532_error = PN532_ERROR_NONE; 81 | int32_t uid_len = 0; 82 | /* USER CODE END 1 */ 83 | 84 | /* MCU Configuration--------------------------------------------------------*/ 85 | 86 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 87 | HAL_Init(); 88 | 89 | /* USER CODE BEGIN Init */ 90 | 91 | /* USER CODE END Init */ 92 | 93 | /* Configure the system clock */ 94 | SystemClock_Config(); 95 | 96 | /* USER CODE BEGIN SysInit */ 97 | 98 | /* USER CODE END SysInit */ 99 | 100 | /* Initialize all configured peripherals */ 101 | MX_GPIO_Init(); 102 | MX_SPI1_Init(); 103 | MX_USART1_UART_Init(); 104 | MX_I2C1_Init(); 105 | /* USER CODE BEGIN 2 */ 106 | printf("Hello!\r\n"); 107 | PN532 pn532; 108 | // PN532_SPI_Init(&pn532); 109 | PN532_I2C_Init(&pn532); 110 | PN532_GetFirmwareVersion(&pn532, buff); 111 | if (PN532_GetFirmwareVersion(&pn532, buff) == PN532_STATUS_OK) { 112 | printf("Found PN532 with firmware version: %d.%d\r\n", buff[1], buff[2]); 113 | } 114 | PN532_SamConfiguration(&pn532); 115 | printf("Waiting for RFID/NFC card...\r\n"); 116 | /* USER CODE END 2 */ 117 | 118 | /* Infinite loop */ 119 | /* USER CODE BEGIN WHILE */ 120 | while (1) 121 | { 122 | /* USER CODE END WHILE */ 123 | 124 | /* USER CODE BEGIN 3 */ 125 | // Check if a card is available to read 126 | uid_len = PN532_ReadPassiveTarget(&pn532, uid, PN532_MIFARE_ISO14443A, 1000); 127 | if (uid_len == PN532_STATUS_ERROR) { 128 | printf("."); 129 | } else { 130 | printf("Found card with UID: "); 131 | for (uint8_t i = 0; i < uid_len; i++) { 132 | printf("%02x ", uid[i]); 133 | } 134 | printf("\r\n"); 135 | break; 136 | } 137 | } 138 | printf("Reading blocks...\r\n"); 139 | for (uint8_t block_number = 0; block_number < 64; block_number++) { 140 | pn532_error = PN532_MifareClassicAuthenticateBlock(&pn532, uid, uid_len, 141 | block_number, MIFARE_CMD_AUTH_A, key_a); 142 | if (pn532_error != PN532_ERROR_NONE) { 143 | break; 144 | } 145 | pn532_error = PN532_MifareClassicReadBlock(&pn532, buff, block_number); 146 | if (pn532_error != PN532_ERROR_NONE) { 147 | break; 148 | } 149 | printf("%d: ", block_number); 150 | for (uint8_t i = 0; i < 16; i++) { 151 | printf("%02x ", buff[i]); 152 | } 153 | printf("\r\n"); 154 | } 155 | if (pn532_error) { 156 | printf("Error: 0x%02x\r\n", pn532_error); 157 | } 158 | /* USER CODE END 3 */ 159 | } 160 | 161 | /** 162 | * @brief System Clock Configuration 163 | * @retval None 164 | */ 165 | void SystemClock_Config(void) 166 | { 167 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 168 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 169 | 170 | /** Initializes the CPU, AHB and APB busses clocks 171 | */ 172 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 173 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 174 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 175 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 176 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 177 | { 178 | Error_Handler(); 179 | } 180 | /** Initializes the CPU, AHB and APB busses clocks 181 | */ 182 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 183 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 184 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 185 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 186 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 187 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 188 | 189 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 190 | { 191 | Error_Handler(); 192 | } 193 | } 194 | 195 | /** 196 | * @brief I2C1 Initialization Function 197 | * @param None 198 | * @retval None 199 | */ 200 | static void MX_I2C1_Init(void) 201 | { 202 | 203 | /* USER CODE BEGIN I2C1_Init 0 */ 204 | 205 | /* USER CODE END I2C1_Init 0 */ 206 | 207 | /* USER CODE BEGIN I2C1_Init 1 */ 208 | 209 | /* USER CODE END I2C1_Init 1 */ 210 | hi2c1.Instance = I2C1; 211 | hi2c1.Init.ClockSpeed = 100000; 212 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 213 | hi2c1.Init.OwnAddress1 = 144; 214 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 215 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 216 | hi2c1.Init.OwnAddress2 = 0; 217 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 218 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 219 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 220 | { 221 | Error_Handler(); 222 | } 223 | /* USER CODE BEGIN I2C1_Init 2 */ 224 | 225 | /* USER CODE END I2C1_Init 2 */ 226 | 227 | } 228 | 229 | /** 230 | * @brief SPI1 Initialization Function 231 | * @param None 232 | * @retval None 233 | */ 234 | static void MX_SPI1_Init(void) 235 | { 236 | 237 | /* USER CODE BEGIN SPI1_Init 0 */ 238 | 239 | /* USER CODE END SPI1_Init 0 */ 240 | 241 | /* USER CODE BEGIN SPI1_Init 1 */ 242 | 243 | /* USER CODE END SPI1_Init 1 */ 244 | /* SPI1 parameter configuration*/ 245 | hspi1.Instance = SPI1; 246 | hspi1.Init.Mode = SPI_MODE_MASTER; 247 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; 248 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 249 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 250 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 251 | hspi1.Init.NSS = SPI_NSS_SOFT; 252 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; 253 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; 254 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; 255 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; 256 | hspi1.Init.CRCPolynomial = 10; 257 | if (HAL_SPI_Init(&hspi1) != HAL_OK) 258 | { 259 | Error_Handler(); 260 | } 261 | /* USER CODE BEGIN SPI1_Init 2 */ 262 | 263 | /* USER CODE END SPI1_Init 2 */ 264 | 265 | } 266 | 267 | /** 268 | * @brief USART1 Initialization Function 269 | * @param None 270 | * @retval None 271 | */ 272 | static void MX_USART1_UART_Init(void) 273 | { 274 | 275 | /* USER CODE BEGIN USART1_Init 0 */ 276 | 277 | /* USER CODE END USART1_Init 0 */ 278 | 279 | /* USER CODE BEGIN USART1_Init 1 */ 280 | 281 | /* USER CODE END USART1_Init 1 */ 282 | huart1.Instance = USART1; 283 | huart1.Init.BaudRate = 115200; 284 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 285 | huart1.Init.StopBits = UART_STOPBITS_1; 286 | huart1.Init.Parity = UART_PARITY_NONE; 287 | huart1.Init.Mode = UART_MODE_TX_RX; 288 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 289 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 290 | if (HAL_UART_Init(&huart1) != HAL_OK) 291 | { 292 | Error_Handler(); 293 | } 294 | /* USER CODE BEGIN USART1_Init 2 */ 295 | 296 | /* USER CODE END USART1_Init 2 */ 297 | 298 | } 299 | 300 | /** 301 | * @brief GPIO Initialization Function 302 | * @param None 303 | * @retval None 304 | */ 305 | static void MX_GPIO_Init(void) 306 | { 307 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 308 | 309 | /* GPIO Ports Clock Enable */ 310 | __HAL_RCC_GPIOA_CLK_ENABLE(); 311 | __HAL_RCC_GPIOB_CLK_ENABLE(); 312 | 313 | /*Configure GPIO pin Output Level */ 314 | HAL_GPIO_WritePin(SS_GPIO_Port, SS_Pin, GPIO_PIN_RESET); 315 | 316 | /*Configure GPIO pin Output Level */ 317 | HAL_GPIO_WritePin(GPIOB, PN532_RST_Pin|PN532_REQ_Pin, GPIO_PIN_SET); 318 | 319 | /*Configure GPIO pin : SS_Pin */ 320 | GPIO_InitStruct.Pin = SS_Pin; 321 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 322 | GPIO_InitStruct.Pull = GPIO_PULLUP; 323 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 324 | HAL_GPIO_Init(SS_GPIO_Port, &GPIO_InitStruct); 325 | 326 | /*Configure GPIO pins : PN532_RST_Pin PN532_REQ_Pin */ 327 | GPIO_InitStruct.Pin = PN532_RST_Pin|PN532_REQ_Pin; 328 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 329 | GPIO_InitStruct.Pull = GPIO_PULLUP; 330 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 331 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 332 | 333 | } 334 | 335 | /* USER CODE BEGIN 4 */ 336 | #ifdef __GNUC__ 337 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 338 | set to 'Yes') calls __io_putchar() */ 339 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 340 | #else 341 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 342 | #endif /* __GNUC__ */ 343 | /** 344 | * @brief Retargets the C library printf function to the USART. 345 | * @param None 346 | * @retval None 347 | */ 348 | PUTCHAR_PROTOTYPE 349 | { 350 | /* Place your implementation of fputc here */ 351 | /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ 352 | HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); 353 | 354 | return ch; 355 | } 356 | /* USER CODE END 4 */ 357 | 358 | /** 359 | * @brief This function is executed in case of error occurrence. 360 | * @retval None 361 | */ 362 | void Error_Handler(void) 363 | { 364 | /* USER CODE BEGIN Error_Handler_Debug */ 365 | /* User can add his own implementation to report the HAL error return state */ 366 | 367 | /* USER CODE END Error_Handler_Debug */ 368 | } 369 | 370 | #ifdef USE_FULL_ASSERT 371 | /** 372 | * @brief Reports the name of the source file and the source line number 373 | * where the assert_param error has occurred. 374 | * @param file: pointer to the source file name 375 | * @param line: assert_param error line source number 376 | * @retval None 377 | */ 378 | void assert_failed(uint8_t *file, uint32_t line) 379 | { 380 | /* USER CODE BEGIN 6 */ 381 | /* User can add his own implementation to report the file name and line number, 382 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 383 | /* USER CODE END 6 */ 384 | } 385 | #endif /* USE_FULL_ASSERT */ 386 | 387 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 388 | --------------------------------------------------------------------------------