Generic driver for the RWD RFID Modules from IB Technology.

Dependents:   RSEDP_DPDemo

RWDModule.h

Committer:
donatien
Date:
2010-07-13
Revision:
1:e96aaf4d5c55
Parent:
0:a893227b988a
Child:
2:37fafd1e1a20

File content as of revision 1:e96aaf4d5c55:


#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();
  
  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(); //Ready for a command / response is available
  
  bool result(byte* pAck = NULL); //Get wether last command was succesful, and complete ack byte if a ptr is provided

private:
  void intClearToSend(); //Called on interrupt when CTS line falls
  void intTx(); //Called on interrupt when TX buffer is not full anymore (bytes sent)
  void intRx(); //Called on interrrupt when RX buffer is not empty anymore (bytes received)

  Serial m_serial;
  InterruptIn m_cts;  
  
  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