From 926a427f7fb20741c12f655ceafb2e98cbbc1604 Mon Sep 17 00:00:00 2001 From: wt Date: Wed, 20 Dec 2023 17:03:29 +0100 Subject: [PATCH] First branch for OBPP60 V2 --- .vscode/settings.json | 3 ++ boards/obp60_s3.json | 51 +++++++++++++++++++++++ lib/obp60task/OBP60Hardware.h | 2 +- lib/obp60task/obp60task.h | 40 +++++++++--------- lib/obp60task/platformio.ini | 18 +++++---- variants/obp60s3/pins_arduino.h | 72 +++++++++++++++++++++++++++++++++ 6 files changed, 158 insertions(+), 28 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 boards/obp60_s3.json create mode 100644 variants/obp60s3/pins_arduino.h diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cad7657 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/boards/obp60_s3.json b/boards/obp60_s3.json new file mode 100644 index 0000000..b249da0 --- /dev/null +++ b/boards/obp60_s3.json @@ -0,0 +1,51 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_ESP32S3_DEV", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "obp60s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "OBP60 ESP32-S3-N8 (8 MB QD, No PSRAM)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://open-boat-projects.org/en/diy-multifunktionsdisplay-obp-60/", + "vendor": "Open Boat Projects" +} diff --git a/lib/obp60task/OBP60Hardware.h b/lib/obp60task/OBP60Hardware.h index bfd273c..ee2dc6f 100644 --- a/lib/obp60task/OBP60Hardware.h +++ b/lib/obp60task/OBP60Hardware.h @@ -1,5 +1,5 @@ // General hardware definitions - // CAN bus pin definitions see GwOBP60Task.h + // CAN bus pin definitions see obp60task.h // Direction pin for RS485 NMEA0183 #define OBP_DIRECTION_PIN 27 diff --git a/lib/obp60task/obp60task.h b/lib/obp60task/obp60task.h index c2cb2a5..4c7715e 100644 --- a/lib/obp60task/obp60task.h +++ b/lib/obp60task/obp60task.h @@ -1,26 +1,26 @@ #pragma once #include "GwApi.h" //we only compile for some boards -#ifdef BOARD_NODEMCU32S_OBP60 -// CAN NMEA2000 -#define ESP32_CAN_TX_PIN GPIO_NUM_13 -#define ESP32_CAN_RX_PIN GPIO_NUM_12 -// Bus load in 50mA steps -#define N2K_LOAD_LEVEL 5 // 5x50mA = 250mA max bus load with back light on -// RS485 NMEA0183 -#define GWSERIAL_TX 26 -#define GWSERIAL_RX 14 -#define GWSERIAL_MODE "UNI" -// Allowed to set a new password for access point -#define FORCE_AP_PWCHANGE +#ifdef BOARD_OBP60S3 + #define USBSerial Serial + // CAN NMEA2000 + #define ESP32_CAN_TX_PIN GPIO_NUM_13 + #define ESP32_CAN_RX_PIN GPIO_NUM_12 + // Bus load in 50mA steps + #define N2K_LOAD_LEVEL 5 // 5x50mA = 250mA max bus load with back light on + // RS485 NMEA0183 + #define GWSERIAL_TX 26 + #define GWSERIAL_RX 14 + #define GWSERIAL_MODE "UNI" + // Allowed to set a new password for access point + #define FORCE_AP_PWCHANGE -// Init OBP60 Task -void OBP60Init(GwApi *param); -DECLARE_INITFUNCTION(OBP60Init); - -// OBP60 Task -void OBP60Task(GwApi *param); -DECLARE_USERTASK_PARAM(OBP60Task, 8000) // Need 8k RAM as stack size -DECLARE_CAPABILITY(obp60,true); + // Init OBP60 Task + void OBP60Init(GwApi *param); + DECLARE_INITFUNCTION(OBP60Init); + // OBP60 Task + void OBP60Task(GwApi *param); + DECLARE_USERTASK_PARAM(OBP60Task, 8000) // Need 8k RAM as stack size + DECLARE_CAPABILITY(obp60,true); #endif \ No newline at end of file diff --git a/lib/obp60task/platformio.ini b/lib/obp60task/platformio.ini index 6a058e4..792bf7a 100644 --- a/lib/obp60task/platformio.ini +++ b/lib/obp60task/platformio.ini @@ -2,21 +2,24 @@ #if you want a pio run to only build #your special environments you can set this here #by uncommenting the next line -default_envs = nodemcu32s_obp60 -[env:nodemcu32s_obp60] +default_envs = obp60_s3 +[env:obp60_s3] platform = espressif32@6.3.2 -board_build.partitions = lib/obp60task/partitions_obp60.csv -board = nodemcu-32s +board = obp60_s3 +board_build.variants_dir = variants +framework = arduino lib_deps = ${env.lib_deps} lib_deps = Wire SPI + fastled/FastLED@^3.6.0 + robtillaart/PCF8574@^0.3.9 adafruit/Adafruit Unified Sensor @ 1.1.13 blemasle/MCP23017@2.0.0 adafruit/Adafruit BusIO@1.5.0 adafruit/Adafruit GFX Library@1.11.9 - zinggjm/GxEPD@3.1.0 + zinggjm/GxEPD@3.1.3 sstaub/Ticker@4.4.0 adafruit/Adafruit BMP280 Library@2.6.2 adafruit/Adafruit BME280 Library@2.2.2 @@ -25,8 +28,9 @@ lib_deps = robtillaart/INA226@0.2.0 signetica/SunRise@2.0.2 build_flags= - -D BOARD_NODEMCU32S_OBP60 + -DTIME=$UNIX_TIME + -D BOARD_OBP60S3 ${env.build_flags} -upload_port = //dev/ttyUSB0 +upload_port = /dev/ttyACM0 upload_protocol = esptool monitor_speed = 115200 \ No newline at end of file diff --git a/variants/obp60s3/pins_arduino.h b/variants/obp60s3/pins_arduino.h new file mode 100644 index 0000000..b2eaa0d --- /dev/null +++ b/variants/obp60s3/pins_arduino.h @@ -0,0 +1,72 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include +#include "soc/soc_caps.h" + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +// Multi Function Display OBP60 V2.0 +static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+48; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN +#define RGB_BUILTIN LED_BUILTIN +#define RGB_BRIGHTNESS 64 + +#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) +#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) +#define digitalPinHasPWM(p) (p < 46) + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 47; +static const uint8_t SCL = 21; + +static const uint8_t SS = 39; +static const uint8_t MOSI = 48; +static const uint8_t MISO = 11; +static const uint8_t SCK = 38; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +#endif /* Pins_Arduino_h */