/******************************************************************************
*
* @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; 


  #if DEVICETYPE == 125
  temp1 = temp1 * 600; //6 / 20 / 0.0005; 
  temp2 = temp2 * 600; //6 / 20 / 0.0005;
  #elif DEVICETYPE == 250
  temp1 = temp1 /  20;
  temp1 = temp1 * 6;
  temp1 = temp1 / 0.000250;
  temp2 = temp2 /  20;
  temp2 = temp2 * 6;
  temp2 = temp2 / 0.000250;
  #endif


  //Nur Amperere
  //
  sys_data.s.values.ltc_discharge_current = temp1/1000; 
  sys_data.s.values.ltc_charge_current = temp2/1000; 


  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 ****************************/