Tue, 28 Mar 2023 22:13:06 +0200
Added begin of INA219 measurements. Added raw main state table.
/** * @file task_ina219.h * @brief The FreeRTOS task to query the INA219 sensors connected to * the I2C bus. * The task will update the sensor state structures. */ #ifndef _TASK_INA219_H #define _TASK_INA219_H /* * Error codes in this task */ #define INA219_ERR_NONE 0 ///< No errors #define INA219_ERR_READ 1 #define I_MAX_LOOPS 32 #define I_MAX_CURRENT 5 ///< Max 5 Ampere #define I_SHUNT_RESISTOR_MILLI_OHM 100 ///< Shunt value typedef struct { bool valid; ///< Valid measurement bool fake; ///< Fake measurement uint8_t address; ///< Device i2c address float shunt; ///< Shunt voltage float volts; ///< Bus voltage float current; ///< Current mA int error; ///< Error result } INA219_tt; /** * @brief Structure containing the variables for the INA219 task. */ typedef struct { bool valid; ///< Valid measurement bool fake; ///< Fake measurement INA219_tt Battery; ///< Battery measurement INA219_tt Solar; ///< Solar measurement float s_Volts[I_MAX_LOOPS]; float s_Current[I_MAX_LOOPS]; float b_Volts[I_MAX_LOOPS]; float b_Current[I_MAX_LOOPS]; bool m_Valid[I_MAX_LOOPS]; time_t m_Time[I_MAX_LOOPS]; time_t gLastTime; uint8_t loopno; uint8_t loops; uint8_t tries; int error; ///< Error result } INA219_State; /** * @brief Request a new measurement from selected sensors. */ void request_ina219(void); /** * @brief Check if results are ready * @return true of results are ready, else false. */ bool ready_ina219(void); /** * @brief The FreeRTOS task to update the INA219 on request. * @param pvParameters Parameters for the task. */ void task_ina219(void *pvParameters); #endif