annotate Small_CPU/Inc/i2c.h @ 238:a9d798e8c11f div-fixes-5

cleanup, bugfix: do not mask I2C_SystemStatus with local variable This commit is partly cleanup, and partly possible bugfix. Masking the global I2C_SystemStatus with a local variable is (very) bad practice, but more importantly, dangerous, as other code uses this I2C_SystemStatus to base decisions on. So, this is definitely non-trivial, as it can possibly change the flow of control. This said, its tested and seems to have no negative effects (but also no positive, as I sort of hoped for), so that is why I mark it cleanup as well. Constructs like this shall be heavily documented in the code, when there is a reason to do things like this. Further, remove a 2nd rather useless construct. There is no reason to & 0x03 the output of I2C_SystemStatus. This is the only location in the entire code base where this is done, so, its not only useless but also inconsistent and confusing the true intentions here. Finally, littered to code with todo's that I will take care of in next commits. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 08 Apr 2019 10:16:17 +0200
parents 9ecc2e60418d
children cb3870f79e9d
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 */
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
6 #define DEVICE_PRESSURE 0xEE // 2019 hardware (gen 3) will use 0xEC (MS5837), all other use 0xEE (MS5803)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
8 /* Compass/Accelerometer */
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
9 #define DEVICE_ACCELARATOR_MMA8452Q 0x38 // Hardware gen 1 (Two chip solution with MMA8452Q and HMC5883L)
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
10 #define DEVICE_COMPASS_HMC5883L 0x3C // Hardware gen 1
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
12 #define DEVICE_COMPASS_303D 0x3C // Hardware gen 2 (Single chip solution LSM303D)
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
13 #define DEVICE_COMPASS_303AGR 0x3C // Hardware gen 3 (Single chip solution LSM303AGR)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /* Battery Gas Gauge */
165
e9cce686fe41 Minor: Some documentation for new hardware
heinrichsweikamp
parents: 38
diff changeset
16 #define DEVICE_BATTERYGAUGE 0xC8 // LTC2941 battery gauge
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 HAL_StatusTypeDef I2C_Master_Receive( uint16_t DevAddress, uint8_t *pData, uint16_t Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 HAL_StatusTypeDef MX_I2C1_Init(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 void I2C_DeInit(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 HAL_StatusTypeDef I2C1_Status(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 GPIO_PinState MX_I2C1_TestAndClear(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 //void I2C_Error(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #endif /* I2C_H */