comparison Small_CPU/Src/batteryGasGauge.c @ 332:39f146ccdb1b

Merged in Ideenmodellierer/ostc4/I2C_Improvment (pull request #30) I2C Improvment
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Thu, 18 Jul 2019 14:26:56 +0000
parents 2defc8cd93ce
children 2fc08a0d1ec3
comparison
equal deleted inserted replaced
326:2559a3f0f1f2 332:39f146ccdb1b
20 * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> 20 * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
21 * 21 *
22 ****************************************************************************** 22 ******************************************************************************
23 */ 23 */
24 /* Includes ------------------------------------------------------------------*/ 24 /* Includes ------------------------------------------------------------------*/
25 #include <string.h> /* memset */
25 #include "batteryGasGauge.h" 26 #include "batteryGasGauge.h"
26 #include "baseCPU2.h" 27 #include "baseCPU2.h"
27 #include "stm32f4xx_hal.h" 28 #include "stm32f4xx_hal.h"
28 #include "i2c.h" 29 #include "i2c.h"
29 30
67 // Prescale M = 128 (111) 68 // Prescale M = 128 (111)
68 // AL/CC pin disable (0) 69 // AL/CC pin disable (0)
69 // Shutdown (0) 70 // Shutdown (0)
70 buffer[1] = 0xF8; 71 buffer[1] = 0xF8;
71 I2C_Master_Transmit(DEVICE_BATTERYGAUGE, buffer, 2); 72 I2C_Master_Transmit(DEVICE_BATTERYGAUGE, buffer, 2);
73 }
74
75 uint8_t battery_gas_gauge_CheckConfigOK(void)
76 {
77 #ifdef OSTC_ON_DISCOVERY_HARDWARE
78 return;
79 #endif
80
81 uint8_t retval = 0;
82 uint8_t bufferReceive[10];
83
84 memset(bufferReceive,0,sizeof(bufferReceive));
85
86 I2C_Master_Receive(DEVICE_BATTERYGAUGE, bufferReceive, 10);
87 if(bufferReceive[1] == 0xf8)
88 {
89 retval = 1;
90 }
91 return retval;
72 } 92 }
73 93
74 static void disable_adc(void) 94 static void disable_adc(void)
75 { 95 {
76 uint8_t buffer[2]; 96 uint8_t buffer[2];