diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..af4531b --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/device/components/*" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6deb23f --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Kidsbox + +### RFID + +_The MISO/MOSI pins are not inverted on host/chip_ + +Connection Table: + +|RC522 Pin|ESP32 Lyrat v4.3 Pin|GPIO Number| +|-|-|-| +|3.3v|3.3v|-| +|RST|3.3v|-| +|GND|GND|-| +|SDA|SCLK|5| +|SCK|SCK (I2C header)|23| +|MOSI|LRCK|25| +|MISO|DSDIN|26| \ No newline at end of file diff --git a/device/main/CMakeLists.txt b/device/main/CMakeLists.txt index d3b02df..8391ded 100644 --- a/device/main/CMakeLists.txt +++ b/device/main/CMakeLists.txt @@ -1,2 +1,2 @@ -idf_component_register(SRCS "Networking.cpp" "main.cpp" "WebInterface.cpp" +idf_component_register(SRCS "Networking.cpp" "main.cpp" "WebInterface.cpp" "RFIDInterface.cpp" INCLUDE_DIRS ".") diff --git a/device/main/RFIDInterface.cpp b/device/main/RFIDInterface.cpp new file mode 100644 index 0000000..7fee9a6 --- /dev/null +++ b/device/main/RFIDInterface.cpp @@ -0,0 +1,26 @@ +#include "RFIDInterface.hpp" + +#include + +static const char* TAG = "rfid"; + +void tag_handler(uint8_t* sn) { // serial number is always 5 bytes long + ESP_LOGI(TAG, "Tag: %#x %#x %#x %#x %#x", + sn[0], sn[1], sn[2], sn[3], sn[4] + ); +} + +RFIDInterface::RFIDInterface() { + startConfig = (rc522_start_args_t){ + .miso_io = 26, + .mosi_io = 25, + .sck_io = 23, + .sda_io = 5, + .callback = &tag_handler + }; +} + +void RFIDInterface::start() { + rc522_start(startConfig); +} + diff --git a/device/main/RFIDInterface.hpp b/device/main/RFIDInterface.hpp new file mode 100644 index 0000000..eff497c --- /dev/null +++ b/device/main/RFIDInterface.hpp @@ -0,0 +1,14 @@ +#ifndef _RFID_INTERFACE_HPP +#define _RFID_INTERFACE_HPP + +#include + +class RFIDInterface { + rc522_start_args_t startConfig; + + public: + RFIDInterface(); + void start(); +}; + +#endif \ No newline at end of file diff --git a/device/main/main.cpp b/device/main/main.cpp index 76184f6..d18e276 100644 --- a/device/main/main.cpp +++ b/device/main/main.cpp @@ -4,6 +4,7 @@ #include "Networking.hpp" #include "WebInterface.hpp" +#include "RFIDInterface.hpp" extern "C" { void app_main(); @@ -11,6 +12,7 @@ extern "C" { Networking networking; WebInterface webInterface; +RFIDInterface rfid; void app_main(void) { initArduino(); @@ -18,6 +20,6 @@ void app_main(void) { Serial.begin(115200); networking.connectWifi(); - webInterface.start(); + rfid.start(); }