Skip to content

Commit

Permalink
Fixed Macros for ESP32-S3
Browse files Browse the repository at this point in the history
  • Loading branch information
thankthemaker committed Sep 9, 2023
1 parent f66706b commit c4397b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ board_build.partitions = default.csv
lib_deps = ${common_env_data.lib_deps_external}
build_flags=
-D PIN_NEOPIXEL=3 ; DIN of WS28xx stripe for front- / backlight, only needed if WS28xx is used
-D MOSFET_PIN_1= ; PWM signal for MOSFET 1 (front white, back red), only needed if COB is used
-D MOSFET_PIN_2= ; PWM signal for MOSFET 2 (front red, back white), only needed if COB is used
; -D MOSFET_PIN_1= ; PWM signal for MOSFET 1 (front white, back red), only needed if COB is used
; -D MOSFET_PIN_2= ; PWM signal for MOSFET 2 (front red, back white), only needed if COB is used
-D PIN_FORWARD=11 ; digital signal from Cheap Focer 2 if direction is forward
-D PIN_BACKWARD=12 ; digital signal from Cheap Focer 2 if direction is backward
-D PIN_BRAKE=13 ; digital signal from Cheap Focer 2 if electric motor brakes is on
Expand All @@ -130,6 +130,7 @@ build_flags=
-D VESC_TX_PIN=10 ; UART TX to Cheap Focer 2, connent to RX on CF2
-D CAN_TX_PIN=16
-D CAN_RX_PIN=17
-D ESP32S3
monitor_filters =
time
esp32_exception_decoder
Expand Down
15 changes: 11 additions & 4 deletions src/CanDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
#endif //CAN_RX_PIN

//Macros to fix actually being able to map the CAN GPIO pins in platformio.ini instead of them being hard coded in init() for TWAI_GENERAL_CONFIG_DEFAULT();
#define GPIO_NUM_HELPER(x) GPIO_NUM##x
#define GPIO_NUM(x) GPIO_NUM_HELPER(x)
#define GPIO_CAN_TX_PIN GPIO_NUM(CAN_TX_PIN)
#define GPIO_CAN_RX_PIN GPIO_NUM(CAN_RX_PIN)
#ifndef ESP32S3
#define GPIO_NUM_HELPER(x) GPIO_NUM##x
#define GPIO_NUM(x) GPIO_NUM_HELPER(x)
#define GPIO_CAN_TX_PIN GPIO_NUM(CAN_TX_PIN)
#define GPIO_CAN_RX_PIN GPIO_NUM(CAN_RX_PIN)
#else
#define GPIO_NUM_HELPER(x) GPIO_NUM_##x
#define GPIO_NUM_(x) GPIO_NUM_HELPER(x)
#define GPIO_CAN_TX_PIN GPIO_NUM_(CAN_TX_PIN)
#define GPIO_CAN_RX_PIN GPIO_NUM_(CAN_RX_PIN)
#endif

class CanDevice {
private:
Expand Down

0 comments on commit c4397b5

Please sign in to comment.