/*
 * charger_control.h
 *
 *  Created on: May 21, 2023
 *      Author: MaxMax
 */

#ifndef INC_CHARGER_CONTROL_H_
#define INC_CHARGER_CONTROL_H_

#include "stm32h7xx_hal.h"

#define CURRENT_DAC_ADR 0x58
#define VOLTAGE_DAC_ADR 0x5E
#define CHARGER_ADC_ADR 0x90

typedef struct{
	uint8_t acfail;
	uint8_t dcfail;
	uint8_t cc_status;
	uint8_t ot_status;
	uint8_t lim_status;
	uint16_t voltage;
	uint16_t current;
}ChargerStatusHandleTypeDef;

void charger_control_init(I2C_HandleTypeDef* hi2c);

ChargerStatusHandleTypeDef charger_control_get_state();
void charger_control_set_current(uint32_t current);
void charger_control_set_voltage(uint32_t voltage);
void charger_control_enable_charger_relay();
void charger_control_disable_charger_relay();
void charger_control_enable_remote();
void charger_control_disable_remote();
void charger_control_setup_DACs();


#endif /* INC_CHARGER_CONTROL_H_ */
