Browse Source

Merge pull request #101 from kkloesener/master

rework actual codebase for rfid via i2c
master
biologist79 4 years ago
committed by GitHub
parent
commit
84d88d920d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/main.cpp
  2. 12
      src/settings-espa1s.h
  3. 4
      src/settings.h

8
src/main.cpp

@ -266,7 +266,7 @@ TaskHandle_t fileStorageTaskHandle;
static TwoWire i2cBusTwo = TwoWire(1); static TwoWire i2cBusTwo = TwoWire(1);
#endif #endif
#ifdef RFID_READER_TYPE_MFRC522_I2C #ifdef RFID_READER_TYPE_MFRC522_I2C
static MFRC522 mfrc522(MFRC522_ADDR, MFRC522_RST_PIN, i2cBusTwo);
static MFRC522 mfrc522(MFRC522_ADDR, MFRC522_RST_PIN, &i2cBusTwo);
#endif #endif
#ifdef PORT_EXPANDER_ENABLE #ifdef PORT_EXPANDER_ENABLE
@ -276,7 +276,7 @@ TaskHandle_t fileStorageTaskHandle;
#if (HAL == 2) #if (HAL == 2)
#include "AC101.h" #include "AC101.h"
static TwoWire i2cBusOne = TwoWire(0); static TwoWire i2cBusOne = TwoWire(0);
static AC101 ac(i2cBusOne);
static AC101 ac(&i2cBusOne);
#endif #endif
#ifdef RFID_READER_TYPE_MFRC522_SPI #ifdef RFID_READER_TYPE_MFRC522_SPI
static MFRC522 mfrc522(RFID_CS, RST_PIN); static MFRC522 mfrc522(RFID_CS, RST_PIN);
@ -4746,7 +4746,8 @@ void setup() {
loggerNl(serialDebug, (char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG); loggerNl(serialDebug, (char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
#endif #endif
#ifdef RFID_READER_TYPE_MFRC522_SPI
// Init RC522 Card-Reader
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(RFID_READER_TYPE_MFRC522_SPI)
mfrc522.PCD_Init(); mfrc522.PCD_Init();
mfrc522.PCD_SetAntennaGain(rfidGain); mfrc522.PCD_SetAntennaGain(rfidGain);
delay(50); delay(50);
@ -5061,6 +5062,7 @@ void setup() {
#ifdef BUTTON_5_ENABLE #ifdef BUTTON_5_ENABLE
pinMode(BUTTON_5, INPUT_PULLUP); pinMode(BUTTON_5, INPUT_PULLUP);
#endif #endif
unsigned long currentTimestamp = millis(); unsigned long currentTimestamp = millis();
// Init rotary encoder // Init rotary encoder

12
src/settings-espa1s.h

@ -22,14 +22,18 @@
#endif #endif
// RFID (via SPI; currently not supported) // RFID (via SPI; currently not supported)
#if defined(RFID_READER_TYPE_MFRC522_SPI)
#define RST_PIN 99 // Not necessary but has to be set anyway; so let's use a dummy-number #define RST_PIN 99 // Not necessary but has to be set anyway; so let's use a dummy-number
#define RFID_CS 21 // GPIO for chip select (RFID) #define RFID_CS 21 // GPIO for chip select (RFID)
#define RFID_MOSI 23 // GPIO for master out slave in (RFID) #define RFID_MOSI 23 // GPIO for master out slave in (RFID)
#define RFID_MISO 19 // GPIO for master in slave out (RFID) #define RFID_MISO 19 // GPIO for master in slave out (RFID)
#define RFID_SCK 18 // GPIO for clock-signal (RFID) #define RFID_SCK 18 // GPIO for clock-signal (RFID)
#endif
// RFID (via I2C) // RFID (via I2C)
#define MFRC522_RST_PIN 12 // needed for i2c-comm MTDI on JTAG
#if defined(RFID_READER_TYPE_MFRC522_I2C)
#define MFRC522_RST_PIN 12 // needed for initialisation -> MTDI on JTAG header
#endif
// I2C-configuration (necessary for RC522 [only via i2c - not spi!] or port-expander) // I2C-configuration (necessary for RC522 [only via i2c - not spi!] or port-expander)
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE) #if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
@ -59,7 +63,7 @@
// Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) // Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander)
#define NEXT_BUTTON 199 // Button 0: GPIO to detect next #define NEXT_BUTTON 199 // Button 0: GPIO to detect next
#define PREVIOUS_BUTTON 198 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode)
#define PREVIOUS_BUTTON 198 // Button 1: GPIO to detect previous
#define PAUSEPLAY_BUTTON 36 // Button 2: GPIO to detect pause/play #define PAUSEPLAY_BUTTON 36 // Button 2: GPIO to detect pause/play
#define BUTTON_4 99 // Button 4: unnamed optional button #define BUTTON_4 99 // Button 4: unnamed optional button
#define BUTTON_5 99 // Button 5: unnamed optional button #define BUTTON_5 99 // Button 5: unnamed optional button
@ -67,13 +71,15 @@
// Wake-up button => this also is the interrupt-pin if port-expander is enabled! // Wake-up button => this also is the interrupt-pin if port-expander is enabled!
// Please note: only RTC-GPIOs (0, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 39, 99) can be used! Set to 99 to DISABLE. // Please note: only RTC-GPIOs (0, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 39, 99) can be used! Set to 99 to DISABLE.
// Please note #2: this button can be used as interrupt-pin for port-expander. If so, all pins connected to port-expander can wake up ESPuino. // Please note #2: this button can be used as interrupt-pin for port-expander. If so, all pins connected to port-expander can wake up ESPuino.
#define WAKEUP_BUTTON DREHENCODER_BUTTON // Defines the button that is used to wake up ESPuino from deepsleep.
#define WAKEUP_BUTTON PAUSEPLAY_BUTTON // Defines the button that is used to wake up ESPuino from deepsleep.
// Power-control // Power-control
#define POWER 19 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep #define POWER 19 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep
// (optional) Neopixel // (optional) Neopixel
#if defined(NEOPIXEL_ENABLE)
#define LED_PIN 23 // GPIO for Neopixel-signaling #define LED_PIN 23 // GPIO for Neopixel-signaling
#endif
// (optinal) Headphone-detection // (optinal) Headphone-detection
#ifdef HEADPHONE_ADJUST_ENABLE #ifdef HEADPHONE_ADJUST_ENABLE

4
src/settings.h

@ -43,7 +43,7 @@
//################## select SD card mode ############################# //################## select SD card mode #############################
//#define SD_MMC_1BIT_MODE // run SD card in SD-MMC 1Bit mode //#define SD_MMC_1BIT_MODE // run SD card in SD-MMC 1Bit mode
//#define SINGLE_SPI_ENABLE // If only one SPI-instance should be used instead of two (not yet working!) (Works on ESP32-A1S with RFID via I2C)
//#define SINGLE_SPI_ENABLE // If only one SPI-instance should be used instead of two (not yet working!)
//################## select RFID reader ############################## //################## select RFID reader ##############################
@ -59,7 +59,7 @@
//#define PN5180_ENABLE_LPCD // Wakes up ESPuino if RFID-tag was applied while deepsleep is active. //#define PN5180_ENABLE_LPCD // Wakes up ESPuino if RFID-tag was applied while deepsleep is active.
#endif #endif
#ifdef RFID_READER_TYPE_MFRC522_SPI
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(RFID_READER_TYPE_MFRC522_SPI)
uint8_t rfidGain = 0x07 << 4; // Sensitivity of RC522. For possible values see reference: https://forum.espuino.de/uploads/default/original/1X/9de5f8d35cbc123c1378cad1beceb3f51035cec0.png uint8_t rfidGain = 0x07 << 4; // Sensitivity of RC522. For possible values see reference: https://forum.espuino.de/uploads/default/original/1X/9de5f8d35cbc123c1378cad1beceb3f51035cec0.png
#endif #endif

Loading…
Cancel
Save