annotate Small_CPU/Inc/i2c.h @ 471:73da921869d9 fix-bat-2

bugfix: implement battery charge percentage in dive header This commit is (much) less trivial than the related 919e5cb51c92. First, rename the CCRmode attribute (corresponding to byte Ox59) of the SLogbookHeaderOSTC3. This byte (according to the hwOS interface document) does not contain any CCR related value, but it contains "battery information". Already since 2017, this byte is used from libdivecomputer to interface the charge percentage. So, its renamed from CCRmode to batteryCharge, to reflect its true purpose. Now, simply add a batteryCharge attribute to the SLogbookHeader (and see below why that is possible, without breaking things). The remaining changes are trivial to implement battery charge percentage in dive header. Caveat: do not get confused by the exact role of the individual logbook header types. SLogbookHeaderOSTC3 is the formal type of the logbook format that the OSTC4 produces. This format is supposed to identical to the format, as is used in hwOS for the series of small OSTCs. Only some values of attributes are different. For example, the OSTC4 supports VPM, so byte 0x79 (deco model used for this dive) also has a value for VPM. But the SLogbookHeader type, despite its name and structure, is *not* a true logbook header, as it includes attributes that are not available in the SLogbookHeaderOSTC3 formal header type. Signed-off-by: Jan Mulder <jan@jlmulder.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Wed, 22 Apr 2020 13:08:57 +0200
parents c3d511365552
children e595d2d1f77f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /* Define to prevent recursive inclusion -------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 #ifndef I2C_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 #define I2C_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
5 /* Pressure Sensor */
357
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
6 #define DEVICE_PRESSURE_MS5803 0xEE // gen 1 and gen 2 use 0xEE (MS5803)
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
7 #define DEVICE_PRESSURE_MS5837 0xEC // end-2019 hardware (gen 3) uses 0xEC (MS5837)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
9 /* Compass/Accelerometer */
357
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
10 #define COMPASS_NOT_RECOGNIZED 0xAA ///< id used with hardwareCompass
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
11 #define compass_generation1 0x01 // Hardware gen 1 (Two chip solution with MMA8452Q and HMC5883L)
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
12 #define compass_generation2 0x02 // Hardware gen 2 (Single chip solution LSM303D)
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
13 #define compass_generation3 0x03 // Hardware gen 3 (Single chip solution LSM303AGR)
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
14
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
15 #define DEVICE_ACCELARATOR_MMA8452Q 0x38 // Hardware gen 1 (Two chip solution with MMA8452Q and HMC5883L)
357
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
16 #define DEVICE_COMPASS_HMC5883L 0x3C // Hardware gen 1 (Two chip solution with MMA8452Q and HMC5883L)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
18 #define DEVICE_COMPASS_303D 0x3C // Hardware gen 2 (Single chip solution LSM303D)
357
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
19
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
20 #define DEVICE_COMPASS_303AGR 0x3C // Hardware gen 3 (Single chip solution LSM303AGR)
357
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
21 #define DEVICE_ACCELARATOR_303AGR 0x32 // Hardware gen 3 (Single chip solution LSM303AGR)
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
22
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
23 // Compass 3 defines (Can move in separate .h file...)
c3d511365552 Add Support for new end-2019 hardware:
heinrichsweikamp
parents: 356
diff changeset
24 #define WHOIAM_VALUE_LSM303AGR 0x33
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /* Battery Gas Gauge */
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
27 #define DEVICE_BATTERYGAUGE 0xC8 // LTC2941 battery gauge
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 HAL_StatusTypeDef I2C_Master_Receive( uint16_t DevAddress, uint8_t *pData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 HAL_StatusTypeDef MX_I2C1_Init(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 void I2C_DeInit(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 HAL_StatusTypeDef I2C1_Status(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 GPIO_PinState MX_I2C1_TestAndClear(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 //void I2C_Error(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 #endif /* I2C_H */