Merge pull request #406 from dalathegreat/feature/stark-can-refactor

Feature: Stark CMR introduction
This commit is contained in:
Daniel Öster 2024-08-15 00:10:42 +03:00 committed by GitHub
commit d7da39b528
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 46 additions and 46 deletions

View file

@ -1,8 +1,22 @@
#ifndef __HW_STARK06_H__
#define __HW_STARK06_H__
#ifndef __HW_STARK_H__
#define __HW_STARK_H__
/*
Stark CMR v1 - DIN-rail module with 4 power outputs, 1 x rs485, 1 x can and 1 x can-fd channel.
For more information on this board visit the project discord or contact johan@redispose.se
GPIOs on extra header
* GPIO 2
* GPIO 17 (only available if can channel 2 is inactive)
* GPIO 19
* GPIO 14 (JTAG TMS)
* GPIO 12 (JTAG TDI)
* GPIO 13 (JTAG TCK)
* GPIO 15 (JTAG TDO)
*/
// Board boot-up time
#define BOOTUP_TIME 1000 // Time in ms it takes before system is considered fully started up
#define BOOTUP_TIME 5000 // Time in ms it takes before system is considered fully started up
// Core assignment
#define CORE_FUNCTION_CORE 1
@ -10,13 +24,13 @@
#define WIFI_CORE 0
// RS485
// #define PIN_5V_EN 16 // No function, GPIO 16 used instead as MCP_SCK
// #define RS485_EN_PIN 17 // RE, No function, GPIO 17 is instead available as extra GPIO via pin header
// #define PIN_5V_EN 16 // Not needed, GPIO 16 has hardware pullup for PSRAM compatibility
// #define RS485_EN_PIN 17 // Not needed, GPIO 17 is used as SCK input of MCP2517
#define RS485_TX_PIN 22
#define RS485_RX_PIN 21
// #define RS485_SE_PIN 19 // No function, GPIO 19 is instead available as extra GPIO via pin header
// #define RS485_SE_PIN 19 // Not needed, GPIO 19 is available as extra GPIO via pin header
// CAN settings. CAN_2 is not defined as it can be either MCP2515 or MCP2517, defined by the user settings
// CAN settings
#define CAN_1_TYPE ESP32CAN
// CAN1 PIN mappings, do not change these unless you are adding on extra hardware to the PCB
@ -24,33 +38,18 @@
#define CAN_RX_PIN GPIO_NUM_26
// #define CAN_SE_PIN 23 // (No function, GPIO 23 used instead as MCP_SCK)
// CAN2 defines below
// DUAL_CAN defines
//#define MCP2515_SCK 12 // SCK input of MCP2515
//#define MCP2515_MOSI 5 // SDI input of MCP2515
//#define MCP2515_MISO 34 // SDO output of MCP2515 | Pin 34 is input only, without pullup/down resistors
//#define MCP2515_CS 18 // CS input of MCP2515
//#define MCP2515_INT 35 // INT output of MCP2515 | | Pin 35 is input only, without pullup/down resistors
// CAN_FD defines
#define MCP2517_SCK 16 // SCK input of MCP2517 (Changed from 12 to 16 since 12 can be used for JTAG TDI)
#define MCP2517_SDI 5 // SDI input of MCP2517
#define MCP2517_SCK 17 // SCK input of MCP2517
#define MCP2517_SDI 5 // SDI input of MCP2517
#define MCP2517_SDO 34 // SDO output of MCP2517
#define MCP2517_CS 18 // CS input of MCP2517
#define MCP2517_CS 18 // CS input of MCP2517
#define MCP2517_INT 35 // INT output of MCP2517
// Contactor handling
#define POSITIVE_CONTACTOR_PIN 32
#define NEGATIVE_CONTACTOR_PIN 33
#define PRECHARGE_PIN 25
#define BMS_POWER 23 // Also connected to MCP_SCK
// SD card
//#define SD_MISO_PIN 2
//#define SD_MOSI_PIN 15
//#define SD_SCLK_PIN 14
//#define SD_CS_PIN 13
#define BMS_POWER 23
// LED
#define LED_PIN 4

View file

@ -212,28 +212,24 @@ String settings_processor(const String& var) {
}
const char* getCANInterfaceName(CAN_Interface interface) {
#ifdef HW_LILYGO
switch (interface) {
case CAN_NATIVE:
return "CAN";
case CANFD_NATIVE:
#ifdef USE_CANFD_INTERFACE_AS_CLASSIC_CAN
return "CAN-FD Native (Classic CAN)";
#else
return "CAN-FD Native";
#endif
case CAN_ADDON_MCP2515:
return "Add-on CAN via GPIO MCP2515";
case CAN_ADDON_FD_MCP2518:
#ifdef USE_CANFD_INTERFACE_AS_CLASSIC_CAN
return "Add-on CAN-FD via GPIO MCP2518 (Classic CAN)";
#else
return "Add-on CAN-FD via GPIO MCP2518";
#endif
default:
return "UNKNOWN";
}
#endif
#ifdef HW_STARK
switch (interface) {
case CAN_NATIVE:
return "CAN";
case CAN_ADDON_MCP2515:
return "CAN_ADDON_MCP2515";
case CAN_ADDON_FD_MCP2518:
return "CAN_ADDON_FD_MCP2518";
default:
return "UNKNOWN";
}
#endif
}

View file

@ -27,6 +27,13 @@
#error CAN-FD AND DUAL-CAN CANNOT BE USED SIMULTANEOUSLY
#endif
#ifdef USE_CANFD_INTERFACE_AS_CLASSIC_CAN
#if !defined(CAN_FD)
// Check that user did not try to use classic CAN over FD, without FD component
#error PLEASE ENABLE CAN_FD TO USE CLASSIC CAN OVER CANFD INTERFACE
#endif
#endif
#ifdef MODBUS_INVERTER_SELECTED
#if defined(SERIAL_LINK_RECEIVER) || defined(SERIAL_LINK_TRANSMITTER)
// Check that Dual LilyGo via RS485 option isn't enabled, this collides with Modbus!