1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| uint8_t KeyValue[]={0xFF ,0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
void IC_test ( void ) { uint8_t ucArray_ID [ 4 ]; uint8_t ucStatusReturn; u8 ID1[]={0xA9,0x37,0x71,0xe4}; while ( 1 ) { if ( ( ucStatusReturn = PcdRequest ( PICC_REQIDL, ucArray_ID ) ) != MI_OK ) ucStatusReturn = PcdRequest ( PICC_REQIDL, ucArray_ID ); if ( ucStatusReturn == MI_OK ) { if ( PcdAnticoll ( ucArray_ID ) == MI_OK ) { PcdSelect(ucArray_ID); PcdAuthState( PICC_AUTHENT1A, 0x11, KeyValue, ucArray_ID ); GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); if(ID1[0]==ucArray_ID[0]) { TIM_SetCompare1(TIM4,75); Delay_ms(1000); TIM_SetCompare1(TIM4,50); GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN); } else { TIM_SetCompare1(TIM4,50); GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN); Delay_ms(1000); GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); Delay_ms(1000); GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN); Delay_ms(1000); GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); Delay_ms(1000); GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN); Delay_ms(1000); GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); Delay_ms(1000); GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN); Delay_ms(1000); GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); Delay_ms(1000); } PcdHalt(); } } } }
int main(void) { SysTick_Init (); RC522_Init (); TIM4_PWM_Init(999,1439); TIM_SetCompare1(TIM4,50); LED_GPIO_Config(); GPIO_SetBits(LED1_GPIO_PORT,LED1_GPIO_PIN); PcdReset(); M500PcdConfigISOType ( 'A' ); while(1) { IC_test(); } }
|