Advertisement
sanpai

RFID CARD COMPARE

Nov 6th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. /*****************************************************************************
  2. * uarttest.c: UART test C file for NXP LPC13xx Family Microprocessors
  3. *
  4. * Copyright(C) 2008, NXP Semiconductor
  5. * All rights reserved.
  6. *
  7. * History
  8. * 2008.08.20 ver 1.00 Preliminary version, first Release
  9. *
  10. ******************************************************************************/
  11. #include "LPC13xx.h"
  12. #include "uart.h"
  13. #include "stdio.h"
  14. #include "lcd.h"
  15. #include "string.h"
  16. #define ARR_LEN 2
  17. #define TAG_LEN 11
  18.  
  19.  
  20.  
  21. extern volatile uint32_t UARTCount;
  22. char UARTBuffer[BUFSIZE];
  23.  
  24. char TAG[ARR_LEN][TAG_LEN]={{0x24,0x30,0x30,0x31,0x32,0x38,0x31,0x35,0x36,0x38,0x30 },
  25. {0x24,0x30,0x30,0x31,0x32,0x38,0x31,0x32,0x38,0x36,0x39 }};
  26.  
  27. int main (void) {
  28. /* Basic chip initialization is taken care of in SystemInit() called
  29. * from the startup code. SystemInit() and chip settings are defined
  30. * in the CMSIS system_<part family>.c file.
  31. */
  32. SystemInit();
  33. init_lcd();
  34. /* NVIC is installed inside UARTInit file. */
  35. UARTInit(9600);
  36.  
  37. unsigned char count=0,i;
  38.  
  39. while (1)
  40. { /* Loop forever */
  41. if ( UARTCount != 0 )
  42. {
  43. LPC_UART->IER = IER_THRE | IER_RLS; /* Disable RBR */
  44. //UARTSend( ( char *)UARTBuffer, UARTCount );
  45. lcd_putstring(0,( char *)UARTBuffer);
  46. UARTCount = 0;
  47. LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR; /* Re-enable RBR */
  48. }
  49.  
  50. for(i=0; i<2; i++)
  51. {
  52. if(memcmp(UARTBuffer,TAG[ARR_LEN],TAG_LEN)==0)
  53. {
  54. lcd_putstring(1,"ACCESS GIVEN"); // compare 12 bytes of the card value
  55. count++;
  56. }
  57. else
  58. {
  59. lcd_putstring(1,"ACCESS DENIED");
  60. }
  61. }
  62. if(count>=2)
  63. {
  64. lcd_putstring(1,"NO SPACE");
  65. }
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement