view Small_CPU/Inc/i2c.h @ 173:05c770dc2911 max-depth

Bugfix: make max depth move with current depth (part 1) The display in dive mode of the max depth was updated before the actual depth, which looks very strange. The reason for this was conceptually simple. The depth value was averaged over a set of depth samples, but the current depth was only taken from the current sample. So, per definition, on an initial descend, the current depth is always bigger (deeper) than any average from previous shallower samples. This part 1 commit introduces a new function that is used immediate after reception of the new sample from the RTE. This function does the trivial average of a set of samples. Notice that also the surface and ambient mbar pressures are taken into account (which are used heavily over the entire code). This is a consistency thing. We should base any further calculation from the data presented in the UI, instead of presenting A, and use A' for further calculations. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 11 Mar 2019 19:48:57 +0100
parents e9cce686fe41
children 9ecc2e60418d
line wrap: on
line source

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef I2C_H
#define I2C_H

/* Pressure Sensor */
#define DEVICE_PRESSURE        			0xEE 	// 2019 hardware (gen 3) will use 0xEC (MS5837), all other use 0xEE (MS5803)

/* Compass/Accelerometer */
#define DEVICE_ACCELARATOR_MMA8452Q 	0x38	// Hardware gen 1 (Two chip solution with MMA8452Q and HMC5883L)
#define DEVICE_COMPASS_HMC5883L			0x3C	// Hardware gen 1

#define DEVICE_COMPASS_303D				0x3C 	// Hardware gen 2 (Single chip solution LSM303D)
#define DEVICE_ACCELARATOR_303DLHC 		0x32 	// Hardware gen 2 (Single chip solution LSM303DLHC)
#define	DEVICE_COMPASS_303AGR			0x3C	// Hardware gen 3 (Single chip solution LSM303AGR)

/* Battery Gas Gauge */
#define DEVICE_BATTERYGAUGE 			0xC8 	// LTC2941 battery gauge


/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"

HAL_StatusTypeDef I2C_Master_Transmit(  uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef I2C_Master_TransmitNoStop(  uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef I2C_Master_Receive(  uint16_t DevAddress, uint8_t *pData, uint16_t Size);
HAL_StatusTypeDef MX_I2C1_Init(void);
void I2C_DeInit(void);
HAL_StatusTypeDef I2C1_Status(void);

GPIO_PinState MX_I2C1_TestAndClear(void);

//void I2C_Error(void);


#endif /* I2C_H */