Generic driver for the RWD RFID Modules from IB Technology.

Dependents:   RSEDP_DPDemo

RWDModule.h

Committer:
donatien
Date:
2010-07-12
Revision:
0:a893227b988a
Child:
1:e96aaf4d5c55

File content as of revision 0:a893227b988a:


#ifndef RWD_MODULE_H
#define RWD_MODULE_H

#include "mbed.h"

typedef unsigned char byte;

class RWDModule
{
public:
  RWDModule(PinName tx, PinName rx, PinName cts);
  virtual ~RWDModule();
  
  
//protected:
  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
  
  bool ready(); //Rady for a command / response is available
  
  bool result(byte* pAck = NULL);

private:
  void intClearToSend();
  void intTx();
  void intRx();

  Serial m_serial;
  InterruptIn m_cts;  
  
//  byte m_buf[64];
  byte m_cmd;
  byte* m_paramsBuf;
  byte* m_respBuf;
  int m_pos;
  int m_paramsLen;
  int m_respLen;
    
  byte m_ackOk;
  byte m_ackOkMask;
  
  byte m_ack;
  
  enum
  {
    READY,
    CMD_QUEUED,
    SENDING_CMD,
    WAITING_FOR_ACK,
    RECEIVING_ACK
  } m_state;

};

#endif