Classe de gestion du HTRC110
RFIDer.h@0:ec877e8509d0, 2017-05-02 (annotated)
- Committer:
- garivetm
- Date:
- Tue May 02 13:45:17 2017 +0000
- Revision:
- 0:ec877e8509d0
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garivetm | 0:ec877e8509d0 | 1 | #include "mbed.h" |
garivetm | 0:ec877e8509d0 | 2 | |
garivetm | 0:ec877e8509d0 | 3 | typedef enum |
garivetm | 0:ec877e8509d0 | 4 | { |
garivetm | 0:ec877e8509d0 | 5 | SYNC = 0, |
garivetm | 0:ec877e8509d0 | 6 | READY, |
garivetm | 0:ec877e8509d0 | 7 | }DecoderState; |
garivetm | 0:ec877e8509d0 | 8 | |
garivetm | 0:ec877e8509d0 | 9 | typedef enum |
garivetm | 0:ec877e8509d0 | 10 | { |
garivetm | 0:ec877e8509d0 | 11 | IDLE = 0, // Looking for '0111111111' |
garivetm | 0:ec877e8509d0 | 12 | READING, |
garivetm | 0:ec877e8509d0 | 13 | DONE, |
garivetm | 0:ec877e8509d0 | 14 | }TagReaderState; |
garivetm | 0:ec877e8509d0 | 15 | |
garivetm | 0:ec877e8509d0 | 16 | |
garivetm | 0:ec877e8509d0 | 17 | class RFIDer{ |
garivetm | 0:ec877e8509d0 | 18 | public : |
garivetm | 0:ec877e8509d0 | 19 | |
garivetm | 0:ec877e8509d0 | 20 | RFIDer(PinName clk, PinName mosi, PinName miso); |
garivetm | 0:ec877e8509d0 | 21 | |
garivetm | 0:ec877e8509d0 | 22 | void setSamplingTime(char ts); |
garivetm | 0:ec877e8509d0 | 23 | |
garivetm | 0:ec877e8509d0 | 24 | char getSamplingTime(); |
garivetm | 0:ec877e8509d0 | 25 | |
garivetm | 0:ec877e8509d0 | 26 | void setComPeriod(short half_period); |
garivetm | 0:ec877e8509d0 | 27 | |
garivetm | 0:ec877e8509d0 | 28 | short getComPeriod(); |
garivetm | 0:ec877e8509d0 | 29 | |
garivetm | 0:ec877e8509d0 | 30 | void setConfigPage(char mode, char data); |
garivetm | 0:ec877e8509d0 | 31 | |
garivetm | 0:ec877e8509d0 | 32 | char getConfigPage(char mode); |
garivetm | 0:ec877e8509d0 | 33 | |
garivetm | 0:ec877e8509d0 | 34 | void setClockFrequency(int frequency); |
garivetm | 0:ec877e8509d0 | 35 | |
garivetm | 0:ec877e8509d0 | 36 | int getClockFrequency(); |
garivetm | 0:ec877e8509d0 | 37 | |
garivetm | 0:ec877e8509d0 | 38 | int getAntennaStatus(); |
garivetm | 0:ec877e8509d0 | 39 | |
garivetm | 0:ec877e8509d0 | 40 | char readPhase(); |
garivetm | 0:ec877e8509d0 | 41 | |
garivetm | 0:ec877e8509d0 | 42 | void startReadingTag(); |
garivetm | 0:ec877e8509d0 | 43 | |
garivetm | 0:ec877e8509d0 | 44 | void stopReadingTag(); |
garivetm | 0:ec877e8509d0 | 45 | |
garivetm | 0:ec877e8509d0 | 46 | char* getTag(void); |
garivetm | 0:ec877e8509d0 | 47 | |
garivetm | 0:ec877e8509d0 | 48 | bool isTagAvailable(void); |
garivetm | 0:ec877e8509d0 | 49 | |
garivetm | 0:ec877e8509d0 | 50 | |
garivetm | 0:ec877e8509d0 | 51 | private : |
garivetm | 0:ec877e8509d0 | 52 | |
garivetm | 0:ec877e8509d0 | 53 | char sendCmd(char cmd); |
garivetm | 0:ec877e8509d0 | 54 | |
garivetm | 0:ec877e8509d0 | 55 | void ISR_tag_reading(void); |
garivetm | 0:ec877e8509d0 | 56 | |
garivetm | 0:ec877e8509d0 | 57 | char decodeBit(int delay); |
garivetm | 0:ec877e8509d0 | 58 | |
garivetm | 0:ec877e8509d0 | 59 | char checkDataIntegrity(void); |
garivetm | 0:ec877e8509d0 | 60 | |
garivetm | 0:ec877e8509d0 | 61 | void decodeTag(void); |
garivetm | 0:ec877e8509d0 | 62 | |
garivetm | 0:ec877e8509d0 | 63 | // Serial Interface (SPI like) |
garivetm | 0:ec877e8509d0 | 64 | DigitalOut mosi; // Ditital data ouput |
garivetm | 0:ec877e8509d0 | 65 | DigitalOut clk; // Digital clock output |
garivetm | 0:ec877e8509d0 | 66 | DigitalIn miso; // Digital data input |
garivetm | 0:ec877e8509d0 | 67 | InterruptIn data; // Interrupt on digital input (tag decoder purpose) |
garivetm | 0:ec877e8509d0 | 68 | int clock_frequency; // HTRC110 hardware crystal frequency |
garivetm | 0:ec877e8509d0 | 69 | short Tserial; // uC serial communication half period [us] |
garivetm | 0:ec877e8509d0 | 70 | |
garivetm | 0:ec877e8509d0 | 71 | // Tag interface (raw demodulated data) |
garivetm | 0:ec877e8509d0 | 72 | Timer timer; // Timer to decode data |
garivetm | 0:ec877e8509d0 | 73 | short Tdata; // Half data rate period [us] |
garivetm | 0:ec877e8509d0 | 74 | char lastBit; // 0/1/2(unknown) |
garivetm | 0:ec877e8509d0 | 75 | bool array[60]; // 64 bits minus 9 header bits are enough but decoder needs at least 55+1 bits. |
garivetm | 0:ec877e8509d0 | 76 | char tag[8]; // Last read tag (Id = 0xtag[i]) |
garivetm | 0:ec877e8509d0 | 77 | bool tagAvailable; // A tag has been read and not got |
garivetm | 0:ec877e8509d0 | 78 | }; |