/******************************************************************************
*
* @file    ltc_current.c
* @author  ECS, Falko Jahn
* @version V1.0.0
* @date    2026-03-21
* @brief       
*
******************************************************************************/

//	--- INCLUDES -----------------------------------------------------------------
#include "sysdata.h"
#include "ltc_current.h"

//	--- EXTERNE VARIABLEN -------------------------------------------------------- 

//	--- LOKALE DEFINES - bitte hier dokumentieren --------------------------------

//	--- LOKALE TYPE DEFS - bitte hier dokumentieren-------------------------------

//	--- DEFINITIONEN GLOBALER VARIABLEN - Bitte in Header dokumentieren ----------

//	--- LOKALE VARIABLEN - bitte hier dokumentieren ------------------------------

//	--- LOKALE FUNKTIONS PROTOTYPEN ---------------------------------------------- 

//	--- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------

/*
* @brief
* @param	kein
* @retval	kein
*/

//	--- GLOBALE FUNKTIONEN - bitte in Header dokumentieren------------------------

void LTC_CURRENT_Exec(int32_t adcval, int32_t adcval2)
{
  double temp1, temp2;


  //Umrechnung Spannung in mV
  temp1 =  (adcval * VREF ) / 65536.0; 
  temp2 =  (adcval2 * VREF ) / 65536.0; 


  //Umrechnung in °C mit LM61 Sensor
  temp1 = temp1 * 600; //6 / 20 / 0.0005; 
  temp2 = temp2 * 600; //6 / 20 / 0.0005;

  //2Nackommastellen
  //milli grad in grad * 100 /festkomma
  sys_data.s.values.ltc_discharge_current = temp1; 
  sys_data.s.values.ltc_charge_current = temp2; 


  if(sys_data.s.values.ltc_discharge_current > sys_data.s.values.ltc_discharge_current_max)
  {
    sys_data.s.values.ltc_discharge_current_max = sys_data.s.values.ltc_discharge_current;
  }

    if(sys_data.s.values.ltc_charge_current > sys_data.s.values.ltc_charge_current_max)
  {
    sys_data.s.values.ltc_charge_current_max = sys_data.s.values.ltc_charge_current;
  }



}
/*************************** End of file ****************************/