Created
January 28, 2012 17:13
-
-
Save arttuladhar/1695070 to your computer and use it in GitHub Desktop.
Gets Data from RFID Reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <18F4455.h> | |
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN | |
#use delay(clock=48000000) | |
#rom int 0xf00000={1,2,3,4} | |
#include <usb_cdc.h> | |
#include <usb_bootloader.h> | |
#include <lcd.c> //This LCD will e changed to <lcd420.c> | |
#include <kbd.c> | |
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=RFID) | |
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_B7, stream=XBEE) | |
#include <string.h> | |
int i; | |
char kbd_selection; | |
/* | |
Frame | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | | |
0 - Control Bit | |
1-10 - Data | |
11-12 - Checksum | |
13 - \n | |
*/ | |
char header; // 1 Bit Header | |
char data[20]; | |
char frame[15]; // 14 Bit Fram Size | |
char dump; | |
char control[5]={'A','B','C','D','E'}; //Control Protocol Data Unit (CPDU) | |
char xbee_data_control; | |
int sys_state=0; | |
int RFID_DATA_READY=0; | |
int XBEE_RECEIVE = 0; | |
INT FLAG_DISPLAY =0; | |
int RFID_DATA_ACK = 0; | |
char user[9]; //10-Bit User | |
void main() | |
{ | |
/* System Initializations */ | |
usb_cdc_init(); | |
usb_init(); | |
lcd_init(); | |
kbd_init(); | |
//Boot Delay | |
delay_ms(100); | |
PRINTF(LCD_PUTC,"\f RFID SHOPPING \n"); | |
PRINTF(LCD_PUTC,"1 - Enter ID"); | |
/* | |
sys_state = 0 : Not Logged In | |
sys_staet = 1 : Logged In | |
*/ | |
while(1) | |
{ | |
//Check Data @ RFID | |
while (kbhit(RFID)){ | |
header = getc(); | |
for (i=0;i<15;i++) | |
{ | |
data[i]=getc(RFID); | |
} | |
RFID_DATA_READY = 1; | |
} | |
// **** DATA @ XBEE **** <= DATA FROM XBEE | |
while ( kbhit(XBEE) ){ | |
i=0; | |
dump = getc(XBEE); | |
while (dump != '_') | |
{ | |
data[i++]=dump; | |
dump = getc(XBEE); | |
} | |
printf(USB_CDC_PUTC,"%s",data); | |
printf(LCD_PUTC,"%s",data); | |
} | |
// ***** Making Frames ******** | |
if (RFID_DATA_READY == 1){ | |
frame[0]='A'; | |
for (i=1;i<=12;i++) | |
{ | |
frame[i] = data[i-1]; | |
} | |
frame[13] = '\n'; | |
// ***** Sending Frame ******* | |
for (i=0;i<=13;i++) | |
{ | |
putc(frame[i]); | |
} | |
RFID_DATA_READY = 0; | |
} //END OF RFID_DATA_READY | |
// Display Module | |
if ( FLAG_DISPLAY == 1) | |
{ | |
FLAG_DISPLAY == 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment