#ifndef POWER_METER_H #define POWER_METER_H #include #include "bsp_can.h" #include "daemon.h" #define POWER_METER_DEFAULT_CAN_ID 0x213u #define POWER_METER_DEFAULT_SCALE 100.0f typedef struct { CAN_Init_Config_s can_config; float scale; } PowerMeter_Init_Config_s; typedef struct { CANInstance *can_ins; DaemonInstance *daemon; float voltage; float current; float power; float scale; uint16_t raw_voltage; uint16_t raw_current; uint32_t update_count; float last_update_time_ms; uint8_t online; } PowerMeterInstance; PowerMeterInstance *PowerMeterInit(PowerMeter_Init_Config_s *config); PowerMeterInstance *PowerMeterInitCan(CAN_HandleTypeDef *can_handle, uint32_t rx_id); const PowerMeterInstance *PowerMeterGetData(PowerMeterInstance *meter); uint8_t PowerMeterIsOnline(PowerMeterInstance *meter); #endif