Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 5:b1ac24b6f25d
- Parent:
- 4:60f9b48d9eb6
- Child:
- 6:11cf998faa50
--- a/main.cpp Tue Apr 30 14:50:28 2019 +0000
+++ b/main.cpp Thu May 02 11:46:17 2019 +0000
@@ -1,46 +1,50 @@
/*
* File : main.cpp
* License : MIT License
- * Version : 0.9
+ * Version : 0.91
* Author : Janus Bo Andersen (JA67494)
* Last edit : Janus
* Created on : 27 Apr 2019
- * Last change: 30 Apr 2019
+ * Last change: 2 May 2019
* Description: Demo program for Mifare RC-522 RFID reader/writer chip.
* : Communicates with RFID reader, transmits card numbers to terminal
* : and toggles a digital pin upon reading a card.
* Structure : Uses SPI protocol to communicate with the RFID
* : Uses U(S)ART to communicate with connected computer/terminal.
* Adapted for: STM32 Nucleo L432KC, but can be adapted for NXP KL25Z.
+ * Changelog : 27 Apr 2019: Created demo program
+ : 02 May 2019: Update pin mappings for FRDM-KL25Z Board
+ : 02 May 2019: Added set and reset for a latched circuit
*/
/*Connect as follows:
(should be connected to board standard pins)
- RFID pins -> Nucleo header CN5 (Arduino-compatible header)
- ----------------------------------------
+ RFID pins -> Board pinName L432KC FRDM-KL25Z
+ ---------------------------------------------------------------------
RFID IRQ = pin5 -> Not used. Leave open
- RFID MISO = pin4 -> Nucleo SPI_MISO = PA_6 = D12
- RFID MOSI = pin3 -> Nucleo SPI_MOSI = PA_7 = D11
- RFID SCK = pin2 -> Nucleo SPI_SCK = PA_5 = D13
- RFID SDA = pin1 -> Nucleo SPI_CS = PB_6 = D10
- RFID RST = pin7 -> Nucleo = PA_9 = D8
+ RFID MISO = pin4 -> SPI_MISO PA_6=D12 PTD3
+ RFID MOSI = pin3 -> SPI_MOSI PA_7=D11 PTD2
+ RFID SCK = pin2 -> SPI_SCK PA_5=D13 PTD1
+ RFID SDA = pin1 -> SPI_CS PB_6=D10 PTD0
+ RFID RST = pin7 -> PA_9=D8 PTA13 (or map sth. else)
Power supply MUST BE 3.3V and GND to the respective pins.
*/
#include "mbed.h"
#include "MFRC522.h"
-// FRDM KL25Z Pins for MFRC522
-#define MF_RESET D8 //Or anything else
-#define SERIAL_TX D0 //UART0
-#define SERIAL_RX D1 //UART0
-#define SPI_MOSI D11 //PTC17
-#define SPI_MISO D12 //PTA16
-#define SPI_SCK D13 //PTA17
-#define SPI_CS D10 //Chip select can be any digital pin
+// FRDM KL25Z Pins
+#define MF_RESET PTA13 //D8 //Or anything else
+#define SERIAL_TX PTE0 //UART0
+#define SERIAL_RX PTE1 //UART0
+#define SPI_MOSI PTD2 //PTC17
+#define SPI_MISO PTD3 //PTA16
+#define SPI_SCK PTD1 //PTA17
+#define SPI_CS PTD0 //Chip select can be any digital pin
DigitalOut LedGreen(LED1); //for showing active signal on dev board
-DigitalOut LedPower(A2); //for toggling MOSFET
+DigitalOut LedPower(A1); //for toggling MOSFET ON
+DigitalOut LedPowerOff(A2); //for toggling MOSFET OFF
//Serial connection to PC for output
Serial pc(SERIAL_TX, SERIAL_RX);
@@ -49,7 +53,7 @@
MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET);
int main(void) {
- pc.printf("starting...\n");
+ printf("starting...\n");
LedPower = 0;
// Init. RC522 Chip
@@ -89,5 +93,9 @@
uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
pc.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
wait_ms(1000);
+
+ //Turn off latch (Jan's addition)
+ wait_ms(500);
+ LedPowerOff = !LedPower;
}
}
\ No newline at end of file