ARM

Committer:
Toby_Chen
Date:
Sat Oct 14 12:58:38 2017 +0000
Revision:
0:f266ca250f98
TRAY+

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Toby_Chen 0:f266ca250f98 1 #include<vector>
Toby_Chen 0:f266ca250f98 2 #include "MFRC522.h"
Toby_Chen 0:f266ca250f98 3 #include"mbed.h"
Toby_Chen 0:f266ca250f98 4
Toby_Chen 0:f266ca250f98 5 #define MF_RESET A0//RST
Toby_Chen 0:f266ca250f98 6 #define SPI_MOSI D11
Toby_Chen 0:f266ca250f98 7 #define SPI_MISO D12
Toby_Chen 0:f266ca250f98 8 #define SPI_SCK D13
Toby_Chen 0:f266ca250f98 9 #define SPI_CS D10
Toby_Chen 0:f266ca250f98 10
Toby_Chen 0:f266ca250f98 11 enum CardName{
Toby_Chen 0:f266ca250f98 12 tray_station_0, //0
Toby_Chen 0:f266ca250f98 13 tray_station_1, //1
Toby_Chen 0:f266ca250f98 14 seat_0, //2
Toby_Chen 0:f266ca250f98 15 seat_1, //3
Toby_Chen 0:f266ca250f98 16 seat_2, //4
Toby_Chen 0:f266ca250f98 17 seat_3, //5
Toby_Chen 0:f266ca250f98 18 seat_4, //6
Toby_Chen 0:f266ca250f98 19 seat_5, //7
Toby_Chen 0:f266ca250f98 20 seat_6, //8
Toby_Chen 0:f266ca250f98 21 seat_7, //9
Toby_Chen 0:f266ca250f98 22 seat_8, //10
Toby_Chen 0:f266ca250f98 23 seat_9, //11
Toby_Chen 0:f266ca250f98 24 ERR = 100
Toby_Chen 0:f266ca250f98 25 };
Toby_Chen 0:f266ca250f98 26
Toby_Chen 0:f266ca250f98 27 class Card{
Toby_Chen 0:f266ca250f98 28 public:
Toby_Chen 0:f266ca250f98 29 Card(int, int, int, int, CardName);
Toby_Chen 0:f266ca250f98 30 int UID[4];
Toby_Chen 0:f266ca250f98 31 CardName type;
Toby_Chen 0:f266ca250f98 32 };
Toby_Chen 0:f266ca250f98 33
Toby_Chen 0:f266ca250f98 34 class CardList{
Toby_Chen 0:f266ca250f98 35 public:
Toby_Chen 0:f266ca250f98 36 CardList() : RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET) { RfChip.PCD_Init(); }; // Initial RC522 Chip
Toby_Chen 0:f266ca250f98 37
Toby_Chen 0:f266ca250f98 38 bool reg_card(int, int, int, int, CardName ); //a、Nb、c、d --> UID type --> Card type
Toby_Chen 0:f266ca250f98 39 CardName read_card();
Toby_Chen 0:f266ca250f98 40 bool is_another_card();// return 1 if RFID read another card
Toby_Chen 0:f266ca250f98 41 void print_UID(); //print UID
Toby_Chen 0:f266ca250f98 42
Toby_Chen 0:f266ca250f98 43 private:
Toby_Chen 0:f266ca250f98 44 CardName _card_buf;
Toby_Chen 0:f266ca250f98 45 vector< Card > _card_list;
Toby_Chen 0:f266ca250f98 46 MFRC522 RfChip;
Toby_Chen 0:f266ca250f98 47 };
Toby_Chen 0:f266ca250f98 48