Subversion Repositories Code-Repo

Rev

Rev 128 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 128 Rev 129
Line 10... Line 10...
10
// Const value arrays for comparison use
10
// Const value arrays for comparison use
11
static char pn532response_firmwarevers[] = {0x01, 0x00, 0x00, 0xFF, 0x06, 0xFA, 0xD5, 0x03};
11
static char pn532response_firmwarevers[] = {0x01, 0x00, 0x00, 0xFF, 0x06, 0xFA, 0xD5, 0x03};
12
static char pn532ack[] = {0x01, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00};
12
static char pn532ack[] = {0x01, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00};
13
 
13
 
14
void NFC_Init() {
14
void NFC_Init() {
15
    TRISCbits.TRISC1 = 1; // IRQ Pin is RC5
15
    NFC_IRQ_TRIS = 1; // IRQ Pin is RC5
16
    TRISCbits.TRISC2 = 0; // Reset Pin is RC2
16
    NFC_RESET_TRIS = 0; // Reset Pin is RC2
17
 
17
 
18
    // Reset the PN532
18
    // Reset the PN532
19
    LATCbits.LATC2 = 1;
19
    NFC_RESET_LAT = 1;
20
    LATCbits.LATC2 = 0;
20
    NFC_RESET_LAT = 0;
21
    Delay10TCYx(1);
21
    Delay10TCYx(1);
22
    LATCbits.LATC2 = 1;
22
    NFC_RESET_LAT = 1;
23
}
23
}
24
 
24
 
25
// Configures the SAM (Secure Access Module)
25
// Configures the SAM (Secure Access Module)
26
unsigned char NFC_SAMConfig() {
26
unsigned char NFC_SAMConfig() {
27
    nfc_data_p->packetbuffer[0] = PN532_COMMAND_SAMCONFIGURATION;
27
    nfc_data_p->packetbuffer[0] = PN532_COMMAND_SAMCONFIGURATION;
Line 404... Line 404...
404
    return (strncmp((char *) buffer, (char *) pn532ack, 7) == 0);
404
    return (strncmp((char *) buffer, (char *) pn532ack, 7) == 0);
405
}
405
}
406
 
406
 
407
// Checks the IRQ pin to know if the PN532 is ready
407
// Checks the IRQ pin to know if the PN532 is ready
408
unsigned char NFC_I2C_Read_Status() {
408
unsigned char NFC_I2C_Read_Status() {
409
    if (PORTCbits.RC1 == 1) {
409
    if (NFC_IRQ_PORT == 1) {
410
        return PN532_I2C_BUSY;
410
        return PN532_I2C_BUSY;
411
    } else {
411
    } else {
412
        return PN532_I2C_READY;
412
        return PN532_I2C_READY;
413
    }
413
    }
414
}
414
}