Merge pull request #1454 from dalathegreat/feature/stark-hw-autodetect

Hardware: Add autodetection method for Stark V1 / V2
This commit is contained in:
Daniel Öster 2025-08-22 22:57:14 +03:00 committed by GitHub
commit 817d0ed7e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 1 deletions

View file

@ -38,7 +38,16 @@ class StarkHal : public Esp32Hal {
virtual gpio_num_t CAN_SE_PIN() { return GPIO_NUM_NC; }
// CANFD_ADDON defines for MCP2517
virtual gpio_num_t MCP2517_SCK() { return GPIO_NUM_17; }
// Stark CMR v1 has GPIO pin 16 for SCK, CMR v2 has GPIO pin 17. Only diff between the two boards
bool isStarkVersion1() {
size_t flashSize = ESP.getFlashChipSize();
if (flashSize == 4 * 1024 * 1024) {
return true;
} else { //v2
return false;
}
}
virtual gpio_num_t MCP2517_SCK() { return isStarkVersion1() ? GPIO_NUM_16 : GPIO_NUM_17; }
virtual gpio_num_t MCP2517_SDI() { return GPIO_NUM_5; }
virtual gpio_num_t MCP2517_SDO() { return GPIO_NUM_34; }
virtual gpio_num_t MCP2517_CS() { return GPIO_NUM_18; }

View file

@ -14,3 +14,5 @@ void pinMode(uint8_t pin, uint8_t mode) {}
int max(int a, int b) {
return (a > b) ? a : b;
}
ESPClass ESP;

View file

@ -24,4 +24,15 @@ void delay(unsigned long ms);
void delayMicroseconds(unsigned long us);
int max(int a, int b);
class ESPClass {
public:
size_t getFlashChipSize() {
// This is a placeholder for the actual implementation
// that retrieves the flash chip size.
return 4 * 1024 * 1024; // Example: returning 4MB
}
};
extern ESPClass ESP;
#endif