Generic driver for the RWD RFID Modules from IB Technology.

Dependents:   RSEDP_DPDemo

Committer:
donatien
Date:
Tue Jul 13 10:37:26 2010 +0000
Revision:
1:e96aaf4d5c55
Parent:
0:a893227b988a
Child:
2:37fafd1e1a20

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:a893227b988a 1
donatien 0:a893227b988a 2 #ifndef RWD_MODULE_H
donatien 0:a893227b988a 3 #define RWD_MODULE_H
donatien 0:a893227b988a 4
donatien 0:a893227b988a 5 #include "mbed.h"
donatien 0:a893227b988a 6
donatien 0:a893227b988a 7 typedef unsigned char byte;
donatien 0:a893227b988a 8
donatien 0:a893227b988a 9 class RWDModule
donatien 0:a893227b988a 10 {
donatien 0:a893227b988a 11 public:
donatien 0:a893227b988a 12 RWDModule(PinName tx, PinName rx, PinName cts);
donatien 0:a893227b988a 13 virtual ~RWDModule();
donatien 0:a893227b988a 14
donatien 0:a893227b988a 15 void command(byte cmd, const byte* params, int paramsLen, byte* resp, int respLen, byte ackOk, byte ackOkMask); //Ack Byte is not included in the resp buf
donatien 0:a893227b988a 16
donatien 1:e96aaf4d5c55 17 bool ready(); //Ready for a command / response is available
donatien 0:a893227b988a 18
donatien 1:e96aaf4d5c55 19 bool result(byte* pAck = NULL); //Get wether last command was succesful, and complete ack byte if a ptr is provided
donatien 0:a893227b988a 20
donatien 0:a893227b988a 21 private:
donatien 1:e96aaf4d5c55 22 void intClearToSend(); //Called on interrupt when CTS line falls
donatien 1:e96aaf4d5c55 23 void intTx(); //Called on interrupt when TX buffer is not full anymore (bytes sent)
donatien 1:e96aaf4d5c55 24 void intRx(); //Called on interrrupt when RX buffer is not empty anymore (bytes received)
donatien 0:a893227b988a 25
donatien 0:a893227b988a 26 Serial m_serial;
donatien 0:a893227b988a 27 InterruptIn m_cts;
donatien 0:a893227b988a 28
donatien 0:a893227b988a 29 byte m_cmd;
donatien 0:a893227b988a 30 byte* m_paramsBuf;
donatien 0:a893227b988a 31 byte* m_respBuf;
donatien 0:a893227b988a 32 int m_pos;
donatien 0:a893227b988a 33 int m_paramsLen;
donatien 0:a893227b988a 34 int m_respLen;
donatien 0:a893227b988a 35
donatien 0:a893227b988a 36 byte m_ackOk;
donatien 0:a893227b988a 37 byte m_ackOkMask;
donatien 0:a893227b988a 38
donatien 0:a893227b988a 39 byte m_ack;
donatien 0:a893227b988a 40
donatien 0:a893227b988a 41 enum
donatien 0:a893227b988a 42 {
donatien 0:a893227b988a 43 READY,
donatien 0:a893227b988a 44 CMD_QUEUED,
donatien 0:a893227b988a 45 SENDING_CMD,
donatien 0:a893227b988a 46 WAITING_FOR_ACK,
donatien 0:a893227b988a 47 RECEIVING_ACK
donatien 0:a893227b988a 48 } m_state;
donatien 0:a893227b988a 49
donatien 0:a893227b988a 50 };
donatien 0:a893227b988a 51
donatien 0:a893227b988a 52 #endif