Skip to content

Commit

Permalink
2020-08-18 Add RFID_RC522 for ESP32
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhongv committed Aug 18, 2020
1 parent 428a06a commit 6f000ef
Show file tree
Hide file tree
Showing 10 changed files with 521 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 20_RFID_rc522/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The following 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.5)

set(EXTRA_COMPONENTS_DIRS "./components")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

project(lcd)


9 changes: 9 additions & 0 deletions 20_RFID_rc522/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#

PROJECT_NAME := lcd

include $(IDF_PATH)/make/project.mk

13 changes: 13 additions & 0 deletions 20_RFID_rc522/README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# RFID-RC522 ESP32示范

此工程展示了 ESP32 驱动 RFID-RC522 的驱动示范!

IDF工程:`origin/release/v4.2`

commit:`cd4fa46f5372a552a67452313d246d4d09d2b39f`

* ESP32 -- RC522连接

RC522|MISO|MOSI|SCK|SDA
---|---| ---|---| ---
ESP32 |GPIO25|GPIO23|GPIO19|GPIO22
4 changes: 4 additions & 0 deletions 20_RFID_rc522/components/RC522/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(COMPONENT_SRCS "rc522.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")

register_component()
5 changes: 5 additions & 0 deletions 20_RFID_rc522/components/RC522/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

42 changes: 42 additions & 0 deletions 20_RFID_rc522/components/RC522/include/rc522.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "driver/spi_master.h"
#include "driver/spi_common_internal.h"

typedef void(*rc522_tag_callback_t)(uint8_t*);

typedef struct {
int miso_io;
int mosi_io;
int sck_io;
int sda_io;
rc522_tag_callback_t callback;
} rc522_start_args_t;

esp_err_t rc522_spi_init(int miso_io, int mosi_io, int sck_io, int sda_io);
esp_err_t rc522_write_n(uint8_t addr, uint8_t n, uint8_t *data);
esp_err_t rc522_write(uint8_t addr , uint8_t val);
uint8_t* rc522_read_n(uint8_t addr, uint8_t n) ;
uint8_t rc522_read(uint8_t addr);
#define rc522_fw_version() rc522_read(0x37)
esp_err_t rc522_init();

esp_err_t rc522_set_bitmask(uint8_t addr, uint8_t mask);
esp_err_t rc522_clear_bitmask(uint8_t addr, uint8_t mask);
esp_err_t rc522_antenna_on();
uint8_t* rc522_calculate_crc(uint8_t *data, uint8_t n);
uint8_t* rc522_card_write(uint8_t cmd, uint8_t *data, uint8_t n, uint8_t* res_n);
uint8_t* rc522_request(uint8_t* res_n);
uint8_t* rc522_anticoll();
uint8_t* rc522_get_tag();
esp_err_t rc522_start(rc522_start_args_t start_args);
esp_err_t rc522_resume();
esp_err_t rc522_pause();

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 6f000ef

Please sign in to comment.