esp32: replace port with PlatformIO implementation and add CI build (#1292)

This commit is contained in:
Kato Gangstad
2026-04-06 15:33:17 +02:00
committed by GitHub
parent 3d668f2f96
commit 589a61b287
38 changed files with 2926 additions and 4708 deletions
+57
View File
@@ -0,0 +1,57 @@
/**
* @file
* @brief BACnet MS/TP application entry point for M5StamPLC
* @author Kato Gangstad
*/
#include <Arduino.h>
#include <M5StamPLC.h>
#ifndef PLC_INPUT_ACTIVE_LOW
#define PLC_INPUT_ACTIVE_LOW 0
#endif
extern "C" {
#include "bacnet_app.h"
}
/**
* @brief Initialize the MS/TP application and PLC hardware
*/
void setup(void)
{
Serial.begin(115200);
delay(100);
Serial.println("[BOOT] Mode: BACnet MS/TP");
Serial.println("[BOOT] Init M5StamPLC...");
M5StamPLC.begin();
Serial.println("[BOOT] Init BACnet app...");
bacnet_app_init();
Serial.println("[BOOT] BACnet MS/TP ready");
}
/**
* @brief Run the main MS/TP application loop
*/
void loop(void)
{
M5StamPLC.update();
for (uint8_t i = 0; i < bacnet_app_input_count(); i++) {
bool state = M5StamPLC.readPlcInput(i);
#if PLC_INPUT_ACTIVE_LOW
state = !state;
#endif
bacnet_app_input_set(i, state);
}
for (uint8_t i = 0; i < bacnet_app_relay_count(); i++) {
M5StamPLC.writePlcRelay(i, bacnet_app_relay_get(i));
}
bacnet_app_temperature_set(M5StamPLC.getTemp());
bacnet_app_free_heap_kb_set((float)ESP.getFreeHeap() / 1024.0f);
bacnet_app_tick();
delay(1);
}