Browse Source

Fixing some LPCD-issues without port-expander

master
Torsten Stauder 4 years ago
parent
commit
f6d806841a
  1. 24
      src/RfidPn5180.cpp
  2. 7
      src/main.cpp
  3. 2
      src/revision.h
  4. 19
      src/settings-lolin_d32_pro_sdmmc_pe.h

24
src/RfidPn5180.cpp

@ -51,6 +51,12 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
void Rfid_Init(void) { void Rfid_Init(void) {
#ifdef PN5180_ENABLE_LPCD #ifdef PN5180_ENABLE_LPCD
// Check if wakeup-reason was card-detection (PN5180 only)
// This only works if RFID.IRQ is connected to a GPIO and not to a port-expander
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT1) {
Rfid_WakeupCheck();
}
// disable pin hold from deep sleep // disable pin hold from deep sleep
gpio_deep_sleep_hold_dis(); gpio_deep_sleep_hold_dis();
gpio_hold_dis(gpio_num_t(RFID_CS)); // NSS gpio_hold_dis(gpio_num_t(RFID_CS)); // NSS
@ -328,22 +334,25 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
// wake up from LPCD, check card is present. This works only for ISO-14443 compatible cards // wake up from LPCD, check card is present. This works only for ISO-14443 compatible cards
void Rfid_WakeupCheck(void) { void Rfid_WakeupCheck(void) {
#ifdef PN5180_ENABLE_LPCD #ifdef PN5180_ENABLE_LPCD
// disable pin hold from deep sleep
gpio_deep_sleep_hold_dis();
gpio_hold_dis(gpio_num_t(RFID_CS)); // NSS
gpio_hold_dis(gpio_num_t(RFID_RST)); // RST
#if (RFID_IRQ >= 0 && RFID_IRQ <= 39)
pinMode(RFID_IRQ, INPUT);
#endif
static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST); static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST);
nfc14443.begin(); nfc14443.begin();
nfc14443.reset(); nfc14443.reset();
// enable RF field
nfc14443.setupRF(); nfc14443.setupRF();
if (!nfc14443.isCardPresent()) { if (!nfc14443.isCardPresent()) {
nfc14443.clearIRQStatus(0xffffffff);
Serial.print(F("Logic-level at PN5180's IRQ-PIN: "));
Serial.println(Port_Read(RFID_IRQ));
// turn on LPCD
nfc14443.reset();
uint16_t wakeupCounterInMs = 0x3FF; // needs to be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms. uint16_t wakeupCounterInMs = 0x3FF; // needs to be in the range of 0x0 - 0xA82. max wake-up time is 2960 ms.
if (nfc14443.switchToLPCD(wakeupCounterInMs)) { if (nfc14443.switchToLPCD(wakeupCounterInMs)) {
Log_Println((char *) FPSTR(lowPowerCardSuccess), LOGLEVEL_INFO); Log_Println((char *) FPSTR(lowPowerCardSuccess), LOGLEVEL_INFO);
// configure wakeup pin for deep-sleep wake-up, use ext1 // configure wakeup pin for deep-sleep wake-up, use ext1
#if (RFID_IRQ >= 0 && RFID_IRQ <= 39)
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ALL_LOW);
#endif
esp_sleep_enable_ext1_wakeup((1ULL << (RFID_IRQ)), ESP_EXT1_WAKEUP_ANY_HIGH);
// freeze pin states in deep sleep // freeze pin states in deep sleep
gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS gpio_hold_en(gpio_num_t(RFID_CS)); // CS/NSS
gpio_hold_en(gpio_num_t(RFID_RST)); // RST gpio_hold_en(gpio_num_t(RFID_RST)); // RST
@ -354,6 +363,7 @@ extern unsigned long Rfid_LastRfidCheckTimestamp;
Serial.println(F("switchToLPCD failed")); Serial.println(F("switchToLPCD failed"));
} }
} }
nfc14443.end();
#endif #endif
} }
#endif #endif

7
src/main.cpp

@ -131,12 +131,7 @@ void setup() {
#ifdef RFID_READER_TYPE_PN5180 #ifdef RFID_READER_TYPE_PN5180
Rfid_Init(); Rfid_Init();
#endif #endif
// Check if wakeup-reason was card-detection (PN5180 only)
// This only works if RFID.IRQ is connected to a GPIO and not to a port-expander
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT1) {
Rfid_WakeupCheck();
}
System_Init(); System_Init();
memset(&gPlayProperties, 0, sizeof(gPlayProperties)); memset(&gPlayProperties, 0, sizeof(gPlayProperties));

2
src/revision.h

@ -1,4 +1,4 @@
#ifndef __REVISION_H__ #ifndef __REVISION_H__
#define __REVISION_H__ #define __REVISION_H__
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211014-2";
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211015-1";
#endif #endif

19
src/settings-lolin_d32_pro_sdmmc_pe.h

@ -104,6 +104,23 @@
#endif #endif
#ifdef IR_CONTROL_ENABLE #ifdef IR_CONTROL_ENABLE
// not supported by PCB!
#define IRLED_PIN 5 // GPIO where IR-receiver is connected (only tested with VS1838B)
#define IR_DEBOUNCE 200 // Interval in ms to wait at least for next signal (not used for actions volume up/down)
// Actions available. Use your own remote control and have a look at the console for "Command=0x??". E.g. "Protocol=NEC Address=0x17F Command=0x68 Repeat gap=39750us"
// Make sure to define a hex-code not more than once as this will lead to a compile-error
// https://forum.espuino.de/t/neues-feature-fernsteuerung-per-infrarot-fernbedienung/265
#define RC_PLAY 0x68 // command for play
#define RC_PAUSE 0x67 // command for pause
#define RC_NEXT 0x6b // command for next track of playlist
#define RC_PREVIOUS 0x6a // command for previous track of playlist
#define RC_FIRST 0x6c // command for first track of playlist
#define RC_LAST 0x6d // command for last track of playlist
#define RC_VOL_UP 0x1a // Command for volume up (one step)
#define RC_VOL_DOWN 0x1b // Command for volume down (one step)
#define RC_MUTE 0x1c // Command to mute ESPuino
#define RC_SHUTDOWN 0x2a // Command for deepsleep
#define RC_BLUETOOTH 0x72 // Command to enable/disable bluetooth
#define RC_FTP 0x65 // Command to enable FTP-server
#endif #endif
#endif #endif
Loading…
Cancel
Save