add orno driver

This commit is contained in:
2025-06-08 18:35:32 +01:00
parent 03de00b93f
commit 12dfa85820
17 changed files with 1689 additions and 673 deletions

View File

@@ -1,30 +1,13 @@
#include "evsemeter.h"
#include "esp_event.h"
#include "esp_log.h"
#include "ade7758.h"
#define PIN_NUM_CLK 15
#define PIN_NUM_MOSI 2
#define PIN_NUM_MISO 4
#define PIN_NUM_CS 23
#define EEPROM_HOST HSPI_HOST
#define IRMS_CAL 53416.0f
#include "meter_ade7758.h"
static const char *TAG = "evsemeter_ade7758";
esp_err_t evsemeter_init(void)
{
ESP_LOGI(TAG, "Initializing EVSE meter (ADE7758)");
ESP_ERROR_CHECK(Init(EEPROM_HOST, PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK));
ESP_ERROR_CHECK(InitSpi(PIN_NUM_CS));
gainSetup(INTEGRATOR_OFF, FULLSCALESELECT_0_5V, GAIN_1, GAIN_1);
setupDivs(1, 1, 1);
setLcycMode(0x00);
resetStatus();
return ESP_OK;
}
@@ -33,8 +16,7 @@ esp_err_t evsemeter_read_current(float *current)
if (!current) {
return ESP_ERR_INVALID_ARG;
}
*current = airms() / IRMS_CAL;
esp_event_post(EVSEMETER_EVENT, EVSEMETER_EVENT_UPDATE, current, sizeof(float), portMAX_DELAY);
return ESP_OK;
}