# HG changeset patch
# User ideenmodellierer
# Date 1563396196 -7200
# Node ID 2defc8cd93ce992d4d13760ee6101e2059d09d6f
# Parent  da5b91b1e20ec8951c768255b5b9d454377168e6
Added check of configuration.
In case of a problem in I2C communication the initialization of the battery gauge may have failed. To detect this a check of configuration of I2C reinitialization have been added

diff -r da5b91b1e20e -r 2defc8cd93ce Small_CPU/Inc/batteryGasGauge.h
--- a/Small_CPU/Inc/batteryGasGauge.h	Wed Jul 17 22:42:55 2019 +0200
+++ b/Small_CPU/Inc/batteryGasGauge.h	Wed Jul 17 22:43:16 2019 +0200
@@ -29,6 +29,8 @@
 
 /* Includes ------------------------------------------------------------------*/
 
+#include <stdint.h>
+
 void init_battery_gas_gauge(void);
 
 float get_voltage(void);
@@ -37,6 +39,7 @@
 void battery_gas_gauge_get_data(void);
 void battery_gas_gauge_set_charge_full(void);
 void battery_gas_gauge_set(float percentage);
+uint8_t battery_gas_gauge_CheckConfigOK(void);
 
 #ifdef __cplusplus
 }
diff -r da5b91b1e20e -r 2defc8cd93ce Small_CPU/Src/batteryGasGauge.c
--- a/Small_CPU/Src/batteryGasGauge.c	Wed Jul 17 22:42:55 2019 +0200
+++ b/Small_CPU/Src/batteryGasGauge.c	Wed Jul 17 22:43:16 2019 +0200
@@ -22,6 +22,7 @@
   ******************************************************************************
   */ 
 /* Includes ------------------------------------------------------------------*/
+#include <string.h>	/* memset */
 #include "batteryGasGauge.h"
 #include "baseCPU2.h"
 #include "stm32f4xx_hal.h"
@@ -71,6 +72,25 @@
 	I2C_Master_Transmit(DEVICE_BATTERYGAUGE, buffer, 2);
 }
 
+uint8_t battery_gas_gauge_CheckConfigOK(void)
+{
+	#ifdef OSTC_ON_DISCOVERY_HARDWARE
+		return;
+	#endif
+
+	uint8_t retval = 0;
+	uint8_t bufferReceive[10];
+
+	memset(bufferReceive,0,sizeof(bufferReceive));
+
+	I2C_Master_Receive(DEVICE_BATTERYGAUGE, bufferReceive, 10);
+	if(bufferReceive[1] == 0xf8)
+	{
+		retval = 1;
+	}
+	return retval;
+}
+
 static void disable_adc(void)
 {
 	uint8_t buffer[2];