Generic driver for the RWD RFID Modules from IB Technology.
Revision 1:e96aaf4d5c55, committed 2010-07-13
- Comitter:
- donatien
- Date:
- Tue Jul 13 10:37:26 2010 +0000
- Parent:
- 0:a893227b988a
- Child:
- 2:37fafd1e1a20
- Commit message:
Changed in this revision
RWDModule.cpp | Show annotated file Show diff for this revision Revisions of this file |
RWDModule.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/RWDModule.cpp Mon Jul 12 09:31:45 2010 +0000 +++ b/RWDModule.cpp Tue Jul 13 10:37:26 2010 +0000 @@ -54,6 +54,7 @@ void RWDModule::intClearToSend() { + //Start sending command when Clear To Send falls if(m_state == CMD_QUEUED) { m_state = SENDING_CMD; @@ -66,8 +67,8 @@ { if(m_state != SENDING_CMD) return; - m_serial.putc((char)m_cmd); -// printf("%02x ",(char)m_cmd); + if(m_pos==0) //Must send command-byte first + m_serial.putc((char)m_cmd); while(true) { if(m_pos >= m_paramsLen) @@ -77,14 +78,13 @@ return; } m_serial.putc((char)m_paramsBuf[m_pos]); -// printf("%02x ",(char)m_paramsBuf[m_pos]); m_pos++; } } void RWDModule::intRx() { - if(m_state == WAITING_FOR_ACK) + if(m_state == WAITING_FOR_ACK) //Get answer { m_ack = m_serial.getc(); if( (m_ack & m_ackOkMask) != m_ackOk ) @@ -102,13 +102,13 @@ return; } } - if(m_state != RECEIVING_ACK) + if(m_state != RECEIVING_ACK) //Error { while(m_serial.readable()) m_serial.getc(); //Dump these bytes return; } - while(m_serial.readable()) + while(m_serial.readable()) //Read payload { m_respBuf[m_pos] = (byte) m_serial.getc(); m_pos++;
--- a/RWDModule.h Mon Jul 12 09:31:45 2010 +0000 +++ b/RWDModule.h Tue Jul 13 10:37:26 2010 +0000 @@ -12,23 +12,20 @@ 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 ready(); //Ready for a command / response is available - bool result(byte* pAck = NULL); + bool result(byte* pAck = NULL); //Get wether last command was succesful, and complete ack byte if a ptr is provided private: - void intClearToSend(); - void intTx(); - void intRx(); + 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_buf[64]; byte m_cmd; byte* m_paramsBuf; byte* m_respBuf;