interrupt handling
Diff: readerComm.cpp
- Revision:
- 10:98a58968dc7d
- Parent:
- 9:9266e0109d26
- Child:
- 11:d5e8f47880f1
--- a/readerComm.cpp Wed Apr 08 20:48:05 2015 +0000 +++ b/readerComm.cpp Thu Apr 09 22:09:35 2015 +0000 @@ -57,6 +57,10 @@ uint8_t temp; uint8_t command[2]; +//standby +//powerdown +//sleep +// void trf797xDirectCommand(uint8_t *buffer) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // trf797xDirectCommand() @@ -179,7 +183,7 @@ } -void PowerUpNFC(void) +void PowerUpNFC2(void) {//CS = 1; // wait_ms(4); // EN = 1; @@ -193,26 +197,41 @@ wait_ms(1); EN = 1; } -void PowerUpNFC2(void) +void PowerUpNFC(void) {//CS = 1; // wait_ms(4); // EN = 1; // EN2=1; - -EN = 1; +//CS=1; //wait_ms(1); -EN2=0; +//EN = 1; +NFC_ON; +//wait_ms(1); +//EN2=0; //wait_ms(1); //EN2= 0; } void PowerDownNFC(void) -{EN = 0; +{///CS=1; + NFC_OFF; //wait_ms(1); - EN2= 0; - + //EN2= 0; PowerDown Mode + //EN2=1; SleepMode + //CS=0; } +void StandByNFC(void) +{//NFC_ON; + turnRFOn[0] = CHIP_STATUS_CONTROL; +turnRFOn[1] = CHIP_STATUS_CONTROL; +turnRFOn[1] &= 0x3F; +//#if NFC_STANDBY//standby +//turnRFOn[1] |= 0xA0; +//#elif NFC_ACTIVE//active mode +turnRFOn[1] |= 0x80; +//#endif +trf797xWriteSingle(turnRFOn, 2);} void SpiInit1(void) { spi.format(8, 1); // 8 bit data, mode = 1 (transition on rising edge, sample on falling edge) @@ -244,11 +263,11 @@ turnRFOn[1] = CHIP_STATUS_CONTROL; turnRFOn[1] &= 0x3F; turnRFOn[1] |= 0x20; + // Oroiginal code has 0x20 !!! trf797xReadSingle(turnRFOn, 1); turnRFOn[0] = CHIP_STATUS_CONTROL; turnRFOn[1] = CHIP_STATUS_CONTROL; - turnRFOn[1] &= 0x3F; turnRFOn[1] |= 0x20; trf797xWriteSingle(turnRFOn, 2); @@ -257,6 +276,9 @@ testcommand[0] = ISO_CONTROL; testcommand[1] = 0x02; // 6.78 MHz, OOK 100% trf797xWriteSingle(testcommand, 2); +testcommand[0] = IRQ_MASK; +testcommand[1] = 0x3F; +trf797xWriteSingle(testcommand, 2); //wait_ms(6); testPin=0;} @@ -289,7 +311,10 @@ void RegistersReadNFC(void) -{ +{turnRFOn[0] = CHIP_STATUS_CONTROL; +trf797xReadSingle(turnRFOn, 1); +testcommand[0] = ISO_CONTROL; +trf797xReadSingle(testcommand, 1); testcommand[0] = TX_TIMER_EPC_HIGH; //0xC1; trf797xReadSingle(testcommand, 1); testcommand[0] = TX_TIMER_EPC_LOW ; //0xC1; @@ -352,9 +377,11 @@ void PollNFC(uint8_t *irqStatus) {// printf - if(*irqStatus==0x40) - { found=1;} - else found=0; + if(*irqStatus==BIT6) + { found=1;} + //else if (*irqStatus==BIT1) +// found=3; +else {found=3;} } void handlerNFC(void) {