/******************************************************************************
*
* @file    fast_current.c
* @author  ECS, Falko Jahn
* @version V1.0.0
* @date    2022-01-16
* @brief       
*
******************************************************************************/

//	--- INCLUDES -----------------------------------------------------------------
#include "fast_current.h"
#include "main.h"
#include "sysdata.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 -----------------------------

//	--- GLOBALE FUNKTIONEN - bitte in Header dokumentieren------------------------


void FAST_CURRENT_Exec(uint32_t newVal )
{
 
  //Umrechung auf Strom
  double temp_current;
  temp_current = ((int32_t) newVal - FAST_CURRENT_ADC_OFFSET) * VREF ;
  temp_current = temp_current / FAST_CURRENT_ADC_RESOLUTION;
  temp_current = temp_current / FAST_CURRENT_I_SENSE_GAIN ;
  temp_current = temp_current / FAST_CURRENT_SHUNT_RESISTOR ;
  sys_data.s.values.fast_current = temp_current * (sys_data.s.parameter.batteryCurrentGainCorrectionFaktor / 1000000.0);
 
}

/*************************** End of file ****************************/