-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# For more information about build system see | ||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html | ||
# The following five lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(basic) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
idf_component_register(SRCS "basic.c" | ||
INCLUDE_DIRS ".") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <esp_log.h> | ||
#include <inttypes.h> | ||
#include "rc522.h" | ||
|
||
static const char *TAG = "rc522-demo"; | ||
static rc522_handle_t scanner; | ||
|
||
static void rc522_handler(void *arg, esp_event_base_t base, int32_t event_id, void *event_data) | ||
{ | ||
rc522_event_data_t *data = (rc522_event_data_t *)event_data; | ||
|
||
switch (event_id) { | ||
case RC522_EVENT_TAG_SCANNED: { | ||
rc522_tag_t *tag = (rc522_tag_t *)data->ptr; | ||
ESP_LOGI(TAG, "Tag scanned (sn: %" PRIu64 ")", tag->serial_number); | ||
} break; | ||
} | ||
} | ||
|
||
void app_main() | ||
{ | ||
rc522_config_t config = { | ||
.spi.host = VSPI_HOST, | ||
.spi.miso_gpio = 25, | ||
.spi.mosi_gpio = 23, | ||
.spi.sck_gpio = 19, | ||
.spi.sda_gpio = 22, | ||
}; | ||
|
||
rc522_create(&config, &scanner); | ||
rc522_register_events(scanner, RC522_EVENT_ANY, rc522_handler, NULL); | ||
rc522_start(scanner); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies: | ||
abobija/rc522: | ||
version: "*" | ||
override_path: '../../../' |