feat: 添加RC522站点匹配逻辑及到站提示功能

This commit is contained in:
2026-04-15 00:06:45 +08:00
parent a6359364fd
commit 9313675630
2 changed files with 98 additions and 25 deletions

View File

@@ -1,25 +1,4 @@
#include "bsp_rc522.h"
#include <string.h>
// 站点UID白名单可扩展
static const uint8_t g_station_1_uid[] = STATION_1_UID;
static const uint8_t g_station_2_uid[] = STATION_2_UID;
station_id_t rc522_match_station(const uint8_t *uid, uint8_t uid_len)
{
if (uid == NULL || uid_len == 0) return STATION_NONE;
// 匹配站点1
if (uid_len == sizeof(g_station_1_uid) && memcmp(uid, g_station_1_uid, uid_len) == 0) {
return STATION_1;
}
// 匹配站点2
if (uid_len == sizeof(g_station_2_uid) && memcmp(uid, g_station_2_uid, uid_len) == 0) {
return STATION_2;
}
// 可继续添加更多站点匹配
return STATION_NONE;
}
#include "bsp_rc522.h"
#include "spi.h"
#include <string.h>
@@ -630,3 +609,24 @@ void rc522_irq_callback(uint16_t GPIO_Pin)
g_irq_pending = 1U;
}
}
/* 站点UID白名单可扩展 */
static const uint8_t g_station_1_uid[] = STATION_1_UID;
static const uint8_t g_station_2_uid[] = STATION_2_UID;
station_id_t rc522_match_station(const uint8_t *uid, uint8_t uid_len)
{
if (uid == NULL || uid_len == 0U) {
return STATION_NONE;
}
if (uid_len == sizeof(g_station_1_uid) && memcmp(uid, g_station_1_uid, uid_len) == 0) {
return STATION_1;
}
if (uid_len == sizeof(g_station_2_uid) && memcmp(uid, g_station_2_uid, uid_len) == 0) {
return STATION_2;
}
return STATION_NONE;
}