/******************************************************************************
*
* @file    battery_voltage.c
* @author  ECS, Falko Jahn
* @version V1.0.0
* @date    2020-05-01
* @brief
*
******************************************************************************/

//	--- INCLUDES -----------------------------------------------------------------
#include "battery_voltage_fast.h"
#include "main.h"
#include "sysdata.h"
#include "stdlib.h"
#include "stdio.h"
#include "tim.h"
//	--- EXTERNE VARIABLEN --------------------------------------------------------

//	--- LOKALE DEFINES - bitte hier dokumentieren --------------------------------



//	--- LOKALE TYPE DEFS - bitte hier dokumentieren-------------------------------

//	--- DEFINITIONEN GLOBALER VARIABLEN - Bitte in Header dokumentieren ----------
extern ADC_HandleTypeDef hadc2;
extern __IO int32_t adc2Data[SAMPLE_ARRAY_SIZE] __attribute__((section(".RAM1_CRC")));
//	--- LOKALE VARIABLEN - bitte hier dokumentieren ------------------------------



//	--- LOKALE FUNKTIONS PROTOTYPEN ----------------------------------------------

//	--- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------

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


void BATTERY_VOLTAGE_FAST_Exec(int32_t newVal)
{
  //Umrechung auf Eingangsspannung am Gerät mit Teiler
  sys_data.s.values.batteryVoltageFast = ((newVal - BATTERY_VOLTAGE_FAST_ADC_OFFSET) * (int64_t)VREF * BATTERY_VOLTAGE_VOLTAGE_DIVIDER / BATTERY_VOLTAGE_FAST_ADC_RESOLUTION) - sys_data.s.parameter.batteryVoltageFastOffset;

 }


void BATTERY_VOLTAGE_FAST_ZeroCal(void)
{
  sys_data.s.parameter.batteryVoltageFastOffset = sys_data.s.values.batteryVoltageFast + sys_data.s.parameter.batteryVoltageFastOffset ;
}




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