mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-07-10 07:38:55 +02:00
Do not hardcode SNIFFER_LED pin
This commit is contained in:
parent
48908c99a8
commit
113a01de43
29
Sniffer.cpp
29
Sniffer.cpp
@ -17,17 +17,24 @@
|
|||||||
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
#define DIAG_LED 33
|
|
||||||
#include "Sniffer.h"
|
#include "Sniffer.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
//extern Sniffer *DCCSniffer;
|
//extern Sniffer *DCCSniffer;
|
||||||
|
|
||||||
static void packeterror() {
|
static void packeterror() {
|
||||||
digitalWrite(DIAG_LED,HIGH);
|
#ifndef WIFI_LED
|
||||||
|
#ifdef SNIFFER_LED
|
||||||
|
digitalWrite(SNIFFER_LED,HIGH);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_packeterror() {
|
static void clear_packeterror() {
|
||||||
digitalWrite(DIAG_LED,LOW);
|
#ifndef WIFI_LED
|
||||||
|
#ifdef SNIFFER_LED
|
||||||
|
digitalWrite(SNIFFER_LED,LOW);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool halfbits2byte(uint16_t b, byte *dccbyte) {
|
static bool halfbits2byte(uint16_t b, byte *dccbyte) {
|
||||||
@ -61,13 +68,17 @@ static bool halfbits2byte(uint16_t b, byte *dccbyte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void IRAM_ATTR blink_diag(int limit) {
|
static void IRAM_ATTR blink_diag(int limit) {
|
||||||
|
#ifndef WIFI_LED
|
||||||
|
#ifdef SNIFFER_LED
|
||||||
delay(500);
|
delay(500);
|
||||||
for (int n=0 ; n<limit; n++) {
|
for (int n=0 ; n<limit; n++) {
|
||||||
digitalWrite(DIAG_LED,HIGH);
|
digitalWrite(SNIFFER_LED,HIGH);
|
||||||
delay(200);
|
delay(200);
|
||||||
digitalWrite(DIAG_LED,LOW);
|
digitalWrite(SNIFFER_LED,LOW);
|
||||||
delay(200);
|
delay(200);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IRAM_ATTR cap_ISR_cb(mcpwm_unit_t mcpwm, mcpwm_capture_channel_id_t cap_channel, const cap_event_data_t *edata,void *user_data) {
|
static bool IRAM_ATTR cap_ISR_cb(mcpwm_unit_t mcpwm, mcpwm_capture_channel_id_t cap_channel, const cap_event_data_t *edata,void *user_data) {
|
||||||
@ -97,8 +108,12 @@ Sniffer::Sniffer(byte snifferpin) {
|
|||||||
.capture_cb = cap_ISR_cb, // user defined ISR/callback
|
.capture_cb = cap_ISR_cb, // user defined ISR/callback
|
||||||
.user_data = (void *)this // user defined argument to callback
|
.user_data = (void *)this // user defined argument to callback
|
||||||
};
|
};
|
||||||
pinMode(DIAG_LED ,OUTPUT);
|
#ifndef WIFI_LED
|
||||||
blink_diag(3); // so that we know we have DIAG_LED
|
#ifdef SNIFFER_LED
|
||||||
|
pinMode(SNIFFER_LED ,OUTPUT);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
blink_diag(3); // so that we know we have SNIFFER_LED
|
||||||
DIAG(F("Init sniffer on pin %d"), snifferpin);
|
DIAG(F("Init sniffer on pin %d"), snifferpin);
|
||||||
ESP_ERROR_CHECK(mcpwm_capture_enable_channel(MCPWM_UNIT_0, MCPWM_SELECT_CAP0, &MCPWM_cap_config));
|
ESP_ERROR_CHECK(mcpwm_capture_enable_channel(MCPWM_UNIT_0, MCPWM_SELECT_CAP0, &MCPWM_cap_config));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user