83 lines
2.0 KiB
C
83 lines
2.0 KiB
C
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "driver/gpio.h"
|
|
#include "esp_log.h"
|
|
|
|
#include "inputs.h"
|
|
|
|
static const char *TAG = "smart-oil-heater-control-system-inputs";
|
|
const uint8_t uBurnerFaultPin = 19U;
|
|
static eBurnerErrorState sBurnerErrorState;
|
|
void loop(void *pvParameters);
|
|
|
|
void initInputs(void)
|
|
{
|
|
|
|
gpio_config_t ioConfBurnerFault = {
|
|
.pin_bit_mask = (1ULL << uBurnerFaultPin), // Pin mask
|
|
.mode = GPIO_MODE_INPUT, // Set as inout
|
|
.pull_up_en = GPIO_PULLUP_ENABLE, // Enable pull-up
|
|
.pull_down_en = GPIO_PULLDOWN_DISABLE, // Disable pull-down
|
|
.intr_type = GPIO_INTR_DISABLE // Disable interrupts
|
|
};
|
|
|
|
gpio_config(&ioConfBurnerFault);
|
|
|
|
BaseType_t taskCreated = xTaskCreate(
|
|
loop, // Function to implement the task
|
|
"loop_inputs", // Task name
|
|
2048, // Stack size (in words, not bytes)
|
|
NULL, // Parameters to the task function (none in this case)
|
|
5, // Task priority (higher number = higher priority)
|
|
NULL // Task handle (optional)
|
|
);
|
|
|
|
if (taskCreated == pdPASS)
|
|
{
|
|
ESP_LOGI(TAG, "Task created successfully!");
|
|
}
|
|
else
|
|
{
|
|
ESP_LOGE(TAG, "Failed to create task");
|
|
}
|
|
}
|
|
|
|
void loop(void *pvParameters)
|
|
{
|
|
// This task will run in a loop
|
|
while (1)
|
|
{
|
|
ESP_LOGI(TAG, "Running task Input...");
|
|
vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay for 1 second
|
|
|
|
if (gpio_get_level(uBurnerFaultPin) == 1)
|
|
{
|
|
sBurnerErrorState = FAULT;
|
|
}
|
|
else
|
|
{
|
|
sBurnerErrorState = NO_ERROR;
|
|
}
|
|
}
|
|
}
|
|
|
|
float getChamberTemperature(void)
|
|
{
|
|
return 42.42;
|
|
}
|
|
float getOutdoorTemperature(void)
|
|
{
|
|
return 42.42;
|
|
}
|
|
float getInletFlowTemperature(void)
|
|
{
|
|
return 42.42;
|
|
}
|
|
float getReturnFlowTemperature(void)
|
|
{
|
|
return 42.42;
|
|
}
|
|
eBurnerErrorState getBurnerError(void)
|
|
{
|
|
return sBurnerErrorState;
|
|
} |