new meter
This commit is contained in:
@@ -23,9 +23,6 @@ bool evse_is_available(void);
|
||||
void evse_set_available(bool value);
|
||||
bool evse_is_require_auth(void);
|
||||
void evse_set_require_auth(bool value);
|
||||
void evse_authorize(void);
|
||||
bool evse_is_pending_auth(void);
|
||||
void evse_set_authorized(bool value);
|
||||
|
||||
// Corrente
|
||||
uint16_t evse_get_charging_current(void);
|
||||
@@ -35,10 +32,6 @@ esp_err_t evse_set_default_charging_current(uint16_t value);
|
||||
uint8_t evse_get_max_charging_current(void);
|
||||
esp_err_t evse_set_max_charging_current(uint8_t value);
|
||||
|
||||
// Grid
|
||||
uint8_t grid_get_max_current(void);
|
||||
esp_err_t grid_set_max_current(uint8_t value);
|
||||
|
||||
// Temperatura
|
||||
uint8_t evse_get_temp_threshold(void);
|
||||
esp_err_t evse_set_temp_threshold(uint8_t value);
|
||||
|
||||
@@ -17,10 +17,6 @@ extern "C" {
|
||||
#define MIN_CHARGING_CURRENT_LIMIT 6 // A
|
||||
#define MAX_CHARGING_CURRENT_LIMIT 32 // A
|
||||
|
||||
// Corrente máxima da rede elétrica (grid)
|
||||
#define MIN_GRID_CURRENT_LIMIT 6 // A
|
||||
#define MAX_GRID_CURRENT_LIMIT 100 // A
|
||||
|
||||
// Corrente via cabo (proximity) — se configurável
|
||||
#define MIN_CABLE_CURRENT_LIMIT 6 // A
|
||||
#define MAX_CABLE_CURRENT_LIMIT 63 // A
|
||||
@@ -43,14 +39,14 @@ esp_err_t evse_set_charging_current(uint16_t value);
|
||||
uint16_t evse_get_default_charging_current(void);
|
||||
esp_err_t evse_set_default_charging_current(uint16_t value);
|
||||
|
||||
// Corrente da rede elétrica
|
||||
uint8_t grid_get_max_current(void);
|
||||
esp_err_t grid_set_max_current(uint8_t value);
|
||||
|
||||
// Configuração de socket outlet
|
||||
bool evse_get_socket_outlet(void);
|
||||
esp_err_t evse_set_socket_outlet(bool socket_outlet);
|
||||
|
||||
void evse_set_runtime_charging_current(uint16_t value);
|
||||
uint16_t evse_get_runtime_charging_current(void);
|
||||
|
||||
|
||||
// RCM
|
||||
bool evse_is_rcm(void);
|
||||
esp_err_t evse_set_rcm(bool rcm);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "pilot.h"
|
||||
#include "evse_pilot.h"
|
||||
|
||||
|
||||
#define EVSE_ERR_AUTO_CLEAR_BITS ( \
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
#ifndef EVSE_EVENTS_H
|
||||
#define EVSE_EVENTS_H
|
||||
|
||||
#include "evse_api.h"
|
||||
#include "esp_event_base.h"
|
||||
#pragma once
|
||||
#include "esp_event.h"
|
||||
|
||||
// Certifique-se de que ESP_EVENT_DECLARE_BASE seja corretamente reconhecido
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Declaração da base de eventos EVSE (será definida em evse_events.c)
|
||||
ESP_EVENT_DECLARE_BASE(EVSE_EVENT);
|
||||
ESP_EVENT_DECLARE_BASE(EVSE_EVENTS);
|
||||
|
||||
typedef enum {
|
||||
EVSE_EVENT_INIT,
|
||||
EVSE_EVENT_STATE_CHANGED,
|
||||
EVSE_EVENT_ERROR,
|
||||
EVSE_EVENT_ERROR_CLEARED,
|
||||
EVSE_EVENT_LIMIT_REACHED,
|
||||
EVSE_EVENT_AUTH_GRANTED
|
||||
// Outros eventos possíveis futuramente
|
||||
} evse_event_id_t;
|
||||
|
||||
// Estrutura do evento de mudança de estado
|
||||
typedef struct {
|
||||
evse_state_t previous;
|
||||
evse_state_t current;
|
||||
} evse_event_state_changed_t;
|
||||
typedef enum {
|
||||
EVSE_STATE_EVENT_IDLE,
|
||||
EVSE_STATE_EVENT_WAITING,
|
||||
EVSE_STATE_EVENT_CHARGING,
|
||||
EVSE_STATE_EVENT_FAULT
|
||||
} evse_state_event_t;
|
||||
|
||||
typedef struct {
|
||||
evse_state_event_t state;
|
||||
} evse_state_event_data_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // EVSE_EVENTS_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "evse_api.h"
|
||||
#include "pilot.h"
|
||||
#include "evse_pilot.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
#ifndef EVSE_MANAGER_H
|
||||
#define EVSE_MANAGER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
|
||||
/**
|
||||
* @brief Inicializa os módulos internos do EVSE (hardware, estado, erros, etc.)
|
||||
* e inicia a tarefa de supervisão periódica (tick).
|
||||
* e inicia a tarefa de supervisão periódica (tick).
|
||||
*/
|
||||
void evse_manager_init(void);
|
||||
|
||||
/**
|
||||
* @brief Inicia a tarefa que processa eventos de autenticação recebidos via fila.
|
||||
*
|
||||
* @param queue Fila de eventos do tipo auth_event_t enviada pelo módulo auth.
|
||||
*/
|
||||
void evse_manager_start(QueueHandle_t queue);
|
||||
|
||||
/**
|
||||
* @brief Executa uma iteração do ciclo de controle do EVSE.
|
||||
*
|
||||
@@ -66,4 +62,5 @@ bool evse_manager_is_enabled(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // EVSE_MANAGER_H
|
||||
|
||||
69
components/evse/include/evse_pilot.h
Executable file
69
components/evse/include/evse_pilot.h
Executable file
@@ -0,0 +1,69 @@
|
||||
#ifndef PILOT_H_
|
||||
#define PILOT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Níveis categóricos de tensão no sinal CP (Control Pilot)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PILOT_VOLTAGE_12, ///< Estado A: +12V
|
||||
PILOT_VOLTAGE_9, ///< Estado B: +9V
|
||||
PILOT_VOLTAGE_6, ///< Estado C: +6V
|
||||
PILOT_VOLTAGE_3, ///< Estado D: +3V
|
||||
PILOT_VOLTAGE_1 ///< Estado E/F: abaixo de 3V
|
||||
} pilot_voltage_t;
|
||||
|
||||
/**
|
||||
* @brief Inicializa o driver do sinal Pilot
|
||||
*/
|
||||
void pilot_init(void);
|
||||
|
||||
/**
|
||||
* @brief Define o nível do Pilot: +12V ou -12V
|
||||
*
|
||||
* @param level true = +12V, false = -12V
|
||||
*/
|
||||
void pilot_set_level(bool level);
|
||||
|
||||
/**
|
||||
* @brief Ativa o PWM do Pilot com corrente limitada
|
||||
*
|
||||
* @param amps Corrente em décimos de ampère (ex: 160 = 16A)
|
||||
*/
|
||||
void pilot_set_amps(uint16_t amps);
|
||||
|
||||
/**
|
||||
* @brief Mede o nível de tensão do Pilot e detecta -12V
|
||||
*
|
||||
* @param up_voltage Valor categórico da tensão positiva
|
||||
* @param down_voltage_n12 true se o nível negativo atingir -12V
|
||||
*/
|
||||
void pilot_measure(pilot_voltage_t *up_voltage, bool *down_voltage_n12);
|
||||
|
||||
/**
|
||||
* @brief Retorna o estado lógico atual do Pilot (nível alto = +12V)
|
||||
*
|
||||
* @return true se nível atual for +12V, false se for -12V
|
||||
*/
|
||||
bool pilot_get_state(void);
|
||||
|
||||
/**
|
||||
* @brief Cache interno opcional dos níveis de tensão reais do Pilot
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t high_mv; ///< Pico positivo medido (mV)
|
||||
uint16_t low_mv; ///< Pico negativo medido (mV)
|
||||
} pilot_voltage_cache_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PILOT_H_ */
|
||||
@@ -1,6 +1,9 @@
|
||||
#ifndef EVSE_STATE_H
|
||||
#define EVSE_STATE_H
|
||||
|
||||
#include "evse_events.h"
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// Estado do EVSE (pilot signal)
|
||||
@@ -41,4 +44,6 @@ bool evse_state_is_charging(evse_state_t state);
|
||||
// Retorna true se o estado representa veículo conectado
|
||||
bool evse_state_is_plugged(evse_state_t state);
|
||||
|
||||
//evse_state_event_t map_state_to_event(evse_state_t state);
|
||||
|
||||
#endif // EVSE_STATE_H
|
||||
|
||||
Reference in New Issue
Block a user