#include "main.h" #include "rfid.h" int cards[][5] = {{117, 222, 140, 171, 140},{163, 134, 92, 178, 203}}; bool acces = false ; extern uint8_t rec_buf2[NB_CAR_TO_RECEIVE+1]; // defined in drv_uart.c //========================================================= // >>>>>>>>>>>> MAIN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //========================================================= int main(void) { HAL_Init(); SystemClock_Config(); uart2_Init(); spi1Init(); RFID_powerOn(); HAL_Delay(500); RFID_init(); while(1) { if( RFID_isCard() ) { if(RFID_readCardSerial()) { term_printf("SERIAL NUMBER : %d %d %d %d %d \n\r", serNum[0],serNum[1],serNum[2],serNum[3],serNum[4]); for ( uint8_t x = 0; x < sizeof(cards); x++) { for (uint8_t i = 0; i < sizeof(serNum); i++ ) { if (serNum[i] != cards[x][i]) { acces = false; break; } else { acces = true; } } if (acces) break; } } } if (acces) { term_printf(" WELCOME \n\r"); HAL_Delay(3000); acces = false; } else { } HAL_Delay(200); RFID_halt(); } // END WHILE return 0; } //================================================================= // UART RECEIVE CALLBACK5 //================================================================= void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) { if(UartHandle -> Instance == USART2) { HAL_UART_Receive_IT(&Uart2Handle, (uint8_t *)rec_buf2, NB_CAR_TO_RECEIVE); } }