interrupt handling
Diff: readerComm.cpp
- Revision:
- 7:96baf1b2fd07
- Parent:
- 6:3c510c297e2f
- Child:
- 9:9266e0109d26
--- a/readerComm.cpp Thu Apr 02 21:10:48 2015 +0000 +++ b/readerComm.cpp Tue Apr 07 20:06:51 2015 +0000 @@ -38,43 +38,24 @@ #include "mbed.h" #include "readerComm.h" -#include "interruptStuff.h" -//#include "main.h" -DigitalOut enable(p4); // Control EN pin on TRF7970 + +DigitalOut enable(p4); // Control EN pin on TRF7970 //DigitalOut enable2(p3); // Control EN2 pin on TRF7970 DigitalOut CS(p19); uint8_t turnRFOn[2]; uint8_t testcommand[2]; -uint8_t afi = 0; -uint8_t flags = 0; // Stores the mask value (used in anticollision) -uint8_t command[2]; -uint8_t temp; - +extern uint8_t noBytes; extern SPI spi; // main.cpp extern Serial pc; // main.cpp -//extern DigitalOut CS; // main.cpp -extern InterruptIn readerInt; // main.cpp -extern int8_t rxtxState; // Transmit/Receive byte count (main.cpp) extern uint8_t buf[300]; // main.cpp -extern uint8_t irqRegister; // Interrupt register (main.cpp) -volatile extern uint8_t irqFlag; // main.cpp -extern uint8_t rxErrorFlag; // main.cpp -extern uint8_t readerMode; // Determines how interrupts will be handled (main.cpp) -extern uint8_t buffer[2]; - -extern uint8_t tagFlag; -extern DigitalIn irqPin; +extern uint8_t found; extern DigitalOut debug1LED; extern DigitalOut debug2LED; extern DigitalOut ISO15693LED; extern DigitalOut heartbeatLED; - extern DigitalOut testPin; - -extern uint8_t debugBuffer[1000]; // Capture data for analysis -extern uint8_t bufIdx; - - +uint8_t temp; +uint8_t command[2]; void trf797xDirectCommand(uint8_t *buffer) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -320,11 +301,12 @@ testcommand[0] = IRQ_STATUS; trf797xReadSingle(testcommand,1); wait_ms(5); +/*====================================read tag ID testcommand[0] = IRQ_STATUS; trf797xReadSingle(testcommand,1); testcommand[0] = IRQ_STATUS; trf797xReadSingle(testcommand,1); -testcommand[0] = FIFO_CONTROL; //Read FIFO Status Register(0x1C/0x5C) +testcommand[0] = FIFO_COUNTER; //Read FIFO Status Register(0x1C/0x5C) trf797xReadSingle(testcommand, 1); testcommand[0] = 0x7F & testcommand[0]; // Determine the number of bytes left in FIFO buf[0] = FIFO; @@ -338,14 +320,28 @@ testcommand[0] = RESET; //Reset FIFO(0x0F/0x8F) trf797xDirectCommand(testcommand); trf797xStopDecoders(); -trf797xRunDecoders(); +trf797xRunDecoders(); */ +//=====================================read Tag ID //wait(1); +} + +void PollNFC(uint8_t *irqStatus) +{// printf + if(*irqStatus==0x40) + { found=1;} + else found=0; } -//void PollNFC(void) -//{ -//} +void handlerNFC(void) +{ +testcommand[0] = IRQ_STATUS; +trf797xReadSingle(testcommand,1); +PollNFC(testcommand); +testcommand[0] = IRQ_STATUS; +trf797xReadSingle(testcommand,1); +} -void ReadNFC(void) + +void MemReadReqNFC(void) {testcommand[0] = RX_NO_RESPONSE_WAIT_TIME ; testcommand[1] = 0xFF; trf797xWriteSingle(testcommand, 2); @@ -366,21 +362,27 @@ testcommand[0] = IRQ_STATUS; trf797xReadSingle(testcommand,1); wait_ms(5); -testcommand[0] = IRQ_STATUS; -trf797xReadSingle(testcommand,1); -testcommand[0] = IRQ_STATUS; -trf797xReadSingle(testcommand,1); -testcommand[0] = FIFO_CONTROL; //Read FIFO Status Register(0x1C/0x5C) -trf797xReadSingle(testcommand, 1); -testcommand[0] = 0x7F & testcommand[0]; // Determine the number of bytes left in FIFO +} +void ReadNFC(void) +{/*========================================== read irqstatus reg. of trf7970a +//testcommand[0] = IRQ_STATUS; clear irqstatus reg of trf7970a +//trf797xReadSingle(testcommand,1); +//testcommand[0] = IRQ_STATUS; +//trf797xReadSingle(testcommand,1); +===========================================*/ + +noBytes = FIFO_COUNTER; //Read FIFO Status Register(0x1C/0x5C) +trf797xReadSingle(&noBytes, 1); +noBytes = 0x7F & noBytes; // Determine the number of bytes left in FIFO buf[0] = FIFO; -trf797xReadContinuous(&buf[0], testcommand[0]); -testPin=0; +trf797xReadContinuous(&buf[0],noBytes); +//testPin=0; testcommand[0] = IRQ_STATUS; trf797xReadSingle(testcommand,1); testcommand[0] = IRQ_STATUS; trf797xReadSingle(testcommand,1); testcommand[0] = RESET; //Reset FIFO(0x0F/0x8F) trf797xDirectCommand(testcommand); + //wait(1); } \ No newline at end of file