reorganize HW defs again, add generic boards, allow undefined CAN rx/tx
This commit is contained in:
parent
5dc2c98642
commit
ac91aeb491
|
@ -48,68 +48,62 @@
|
||||||
#define BOARD_LEFT2 GPIO_NUM_6
|
#define BOARD_LEFT2 GPIO_NUM_6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//serial adapter at the M5 groove pins
|
//M5Stick C
|
||||||
#define SERIAL_GROOVE(SMODE) \
|
#ifdef PLATFORM_BOARD_M5STICK_C
|
||||||
static const gpio_num_t GWSERIAL_TX=GROOVE_PIN_1; \
|
#define GROOVE_PIN_1 GPIO_NUM_32
|
||||||
static const gpio_num_t GWSERIAL_RX=GROOVE_PIN_2; \
|
#define GROOVE_PIN_2 GPIO_NUM_31
|
||||||
static const char* GWSERIAL_MODE=SMODE;
|
#endif
|
||||||
|
|
||||||
//M5 Serial (Atomic RS232 Base)
|
|
||||||
#define SERIAL_KIT(SMODE) \
|
|
||||||
static const gpio_num_t GWSERIAL_TX=BOARD_LEFT2; \
|
|
||||||
static const gpio_num_t GWSERIAL_RX=BOARD_LEFT1; \
|
|
||||||
static const char* GWSERIAL_MODE=SMODE;
|
|
||||||
|
|
||||||
|
|
||||||
#define CANKIT \
|
|
||||||
static const gpio_num_t ESP32_CAN_TX_PIN=BOARD_LEFT1; \
|
|
||||||
static const gpio_num_t ESP32_CAN_RX_PIN=BOARD_LEFT2;
|
|
||||||
|
|
||||||
#define CANUNIT \
|
|
||||||
static const gpio_num_t ESP32_CAN_TX_PIN=GROOVE_PIN_1; \
|
|
||||||
static const gpio_num_t ESP32_CAN_RX_PIN=GROOVE_PIN_2;
|
|
||||||
//SERIAL_MODE can be: UNI (RX or TX only), BI (both), RX, TX
|
|
||||||
//board specific pins
|
|
||||||
#ifdef BOARD_M5ATOM
|
#ifdef BOARD_M5ATOM
|
||||||
CANKIT
|
#define M5_CAN_KIT
|
||||||
//150mA if we power from the bus
|
//150mA if we power from the bus
|
||||||
#define N2K_LOAD_LEVEL 3
|
#define N2K_LOAD_LEVEL 3
|
||||||
//if using tail485
|
//if using tail485
|
||||||
SERIAL_GROOVE("UNI")
|
#define SERIAL_GROOVE_485
|
||||||
|
//brightness 0...255
|
||||||
|
#define GWLED_BRIGHTNESS 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOARD_M5ATOMS3
|
||||||
|
#define M5_CAN_KIT
|
||||||
|
//150mA if we power from the bus
|
||||||
|
#define N2K_LOAD_LEVEL 3
|
||||||
|
//if using tail485
|
||||||
|
#define SERIAL_GROOVE_485
|
||||||
//brightness 0...255
|
//brightness 0...255
|
||||||
#define GWLED_BRIGHTNESS 64
|
#define GWLED_BRIGHTNESS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOARD_M5ATOM_CANUNIT
|
#ifdef BOARD_M5ATOM_CANUNIT
|
||||||
CANUNIT
|
#define M5_CANUNIT
|
||||||
#define GWLED_BRIGHTNESS 64
|
#define GWLED_BRIGHTNESS 64
|
||||||
//150mA if we power from the bus
|
//150mA if we power from the bus
|
||||||
#define N2K_LOAD_LEVEL 3
|
#define N2K_LOAD_LEVEL 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOARD_M5ATOMS3_CANUNIT
|
#ifdef BOARD_M5ATOMS3_CANUNIT
|
||||||
CANUNIT
|
#define M5_CANUNIT
|
||||||
#define GWLED_BRIGHTNESS 64
|
#define GWLED_BRIGHTNESS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOARD_M5ATOM_RS232_CANUNIT
|
#ifdef BOARD_M5ATOM_RS232_CANUNIT
|
||||||
CANUNIT
|
#define M5_CANUNIT
|
||||||
SERIALKIT("BI")
|
#define M5_SERIAL_KIT_232
|
||||||
#define GWLED_BRIGHTNESS 64
|
#define GWLED_BRIGHTNESS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOARD_M5ATOM_RS485_CANUNIT
|
#ifdef BOARD_M5ATOM_RS485_CANUNIT
|
||||||
SERIALKIT("UNI")
|
#define M5_SERIAL_KIT_485
|
||||||
CANUNIT
|
#define M5_CANUNIT
|
||||||
#define GWLED_BRIGHTNESS 64
|
#define GWLED_BRIGHTNESS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOARD_M5STICK_CANUNIT
|
#ifdef BOARD_M5STICK_CANUNIT
|
||||||
#define ESP32_CAN_TX_PIN GPIO_NUM_32
|
#define M5_CANUNIT
|
||||||
#define ESP32_CAN_RX_PIN GPIO_NUM_33
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOARD_HOMBERGER
|
#ifdef BOARD_HOMBERGER
|
||||||
#define ESP32_CAN_TX_PIN GPIO_NUM_5
|
#define ESP32_CAN_TX_PIN GPIO_NUM_5
|
||||||
#define ESP32_CAN_RX_PIN GPIO_NUM_4
|
#define ESP32_CAN_RX_PIN GPIO_NUM_4
|
||||||
|
@ -123,4 +117,44 @@ CANUNIT
|
||||||
#define GWBUTTON_PULLUPDOWN
|
#define GWBUTTON_PULLUPDOWN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//below we define the final device config based on the above
|
||||||
|
//boards and peripherals
|
||||||
|
//this allows us toe easily also set the from outside
|
||||||
|
//serial adapter at the M5 groove pins
|
||||||
|
#ifdef SERIAL_GROOVE_485
|
||||||
|
#define GWSERIAL_TX GROOVE_PIN_1
|
||||||
|
#define GWSERIAL_RX GROOVE_PIN_2
|
||||||
|
#define GWSERIAL_MODE "UNI"
|
||||||
|
#endif
|
||||||
|
#ifdef SERIAL_GROOVE_232
|
||||||
|
#define GWSERIAL_TX GROOVE_PIN_1
|
||||||
|
#define GWSERIAL_RX GROOVE_PIN_2
|
||||||
|
#define GWSERIAL_MODE "BI"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//M5 Serial (Atomic RS232 Base)
|
||||||
|
#ifdef M5_SERIAL_KIT_232
|
||||||
|
#define GWSERIAL_TX BOARD_LEFT2
|
||||||
|
#define GWSERIAL_RX BOARD_LEFT1
|
||||||
|
#define GWSERIAL_MODE "BI"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//M5 Serial (Atomic RS485 Base)
|
||||||
|
#ifdef M5_SERIAL_KIT_485
|
||||||
|
#define GWSERIAL_TX BOARD_LEFT2
|
||||||
|
#define GWSERIAL_RX BOARD_LEFT1
|
||||||
|
#define GWSERIAL_MODE "UNI"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//can kit for M5 Atom
|
||||||
|
#ifdef M5_CAN_KIT
|
||||||
|
#define ESP32_CAN_TX_PIN BOARD_LEFT1
|
||||||
|
#define ESP32_CAN_RX_PIN BOARD_LEFT2
|
||||||
|
#endif
|
||||||
|
//CAN via groove
|
||||||
|
#ifdef M5_CANUNIT
|
||||||
|
#define ESP32_CAN_TX_PIN GROOVE_PIN_1
|
||||||
|
#define ESP32_CAN_RX_PIN GROOVE_PIN_2
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,6 +54,14 @@ build_flags =
|
||||||
upload_port = /dev/esp32
|
upload_port = /dev/esp32
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
|
|
||||||
|
[env:m5stack-atom-generic]
|
||||||
|
board = m5stack-atom
|
||||||
|
lib_deps = ${env.lib_deps}
|
||||||
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
|
upload_port = /dev/esp32
|
||||||
|
upload_protocol = esptool
|
||||||
|
|
||||||
[env:m5stack-atoms3]
|
[env:m5stack-atoms3]
|
||||||
board = m5stack-atoms3
|
board = m5stack-atoms3
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
|
@ -63,6 +71,14 @@ build_flags =
|
||||||
upload_port = /dev/esp32s3
|
upload_port = /dev/esp32s3
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
|
|
||||||
|
[env:m5stack-atoms3-generic]
|
||||||
|
board = m5stack-atoms3
|
||||||
|
lib_deps = ${env.lib_deps}
|
||||||
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
|
upload_port = /dev/esp32s3
|
||||||
|
upload_protocol = esptool
|
||||||
|
|
||||||
[env:m5stack-atom-canunit]
|
[env:m5stack-atom-canunit]
|
||||||
board = m5stack-atom
|
board = m5stack-atom
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
|
@ -118,3 +134,11 @@ build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
upload_port = /dev/esp32
|
upload_port = /dev/esp32
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
|
|
||||||
|
[env:nodemcu-generic]
|
||||||
|
board = nodemcu-32s
|
||||||
|
lib_deps = ${env.lib_deps}
|
||||||
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
|
upload_port = /dev/esp32
|
||||||
|
upload_protocol = esptool
|
||||||
|
|
|
@ -127,6 +127,14 @@ class Nmea2kTwaiLog : public Nmea2kTwai{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef ESP32_CAN_TX_PIN
|
||||||
|
#pragma message "WARNING: ESP32_CAN_TX_PIN not defined"
|
||||||
|
#define ESP32_CAN_TX_PIN GPIO_NUM_NC
|
||||||
|
#endif
|
||||||
|
#ifndef ESP32_CAN_RX_PIN
|
||||||
|
#pragma message "WARNING: ESP32_CAN_RX_PIN not defined"
|
||||||
|
#define ESP32_CAN_RX_PIN GPIO_NUM_NC
|
||||||
|
#endif
|
||||||
|
|
||||||
Nmea2kTwai &NMEA2000=*(new Nmea2kTwaiLog(ESP32_CAN_TX_PIN,ESP32_CAN_RX_PIN,CAN_RECOVERY_PERIOD,&logger));
|
Nmea2kTwai &NMEA2000=*(new Nmea2kTwaiLog(ESP32_CAN_TX_PIN,ESP32_CAN_RX_PIN,CAN_RECOVERY_PERIOD,&logger));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue