view Small_CPU/Inc/i2c.h @ 425:86fcac4cc43a ImprovmentNVM_2

Added function to analyse the sampel ringbuffer: The function will show 0 for used sectors, 4 for the sector currently in use and 5 for empty sectors. This allows identification of log sample index position and identification of a buffer corruption (more than 2 sectors have state 4) The repair function writes dummy bytes to the end of the active buffer with the lower sector number. This decision is based on the fact that corruption results typically in a reset of index to buffer start address. After repair the writing will be continued using the hugher buffer marked as used.
author ideenmodellierer
date Sat, 15 Feb 2020 20:50:20 +0100
parents c3d511365552
children e595d2d1f77f
line wrap: on
line source

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

/* Pressure Sensor */
#define DEVICE_PRESSURE_MS5803     		0xEE 	// gen 1 and gen 2 use 0xEE (MS5803)
#define	DEVICE_PRESSURE_MS5837   		0xEC	// end-2019 hardware (gen 3) uses 0xEC (MS5837)

/* Compass/Accelerometer */
#define COMPASS_NOT_RECOGNIZED  		0xAA	///< id used with hardwareCompass
#define	compass_generation1				0x01	// Hardware gen 1 (Two chip solution with MMA8452Q and HMC5883L)
#define	compass_generation2				0x02	// Hardware gen 2 (Single chip solution LSM303D)
#define	compass_generation3				0x03	// Hardware gen 3 (Single chip solution LSM303AGR)

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

#define DEVICE_COMPASS_303D				0x3C 	// Hardware gen 2 (Single chip solution LSM303D)

#define	DEVICE_COMPASS_303AGR			0x3C	// Hardware gen 3 (Single chip solution LSM303AGR)
#define	DEVICE_ACCELARATOR_303AGR		0x32	// Hardware gen 3 (Single chip solution LSM303AGR)

// Compass 3 defines (Can move in separate .h file...)
#define WHOIAM_VALUE_LSM303AGR			0x33

/* 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 */