# HG changeset patch # User Jan Mulder # Date 1554715120 -7200 # Node ID 2b9775f71e30f7ffcd3cf0666bfdb899b1459e19 # Parent 625d200702612de1a4e6c85993e0b53bafab13de cleanup: factor out I2C1_Status() and cleanup type Having a function that returns global data is rather useless. Further, use HAL_StatusTypeDef directly, instead of typecasting between a HAL defined enum and our uint_8t. Cleanup only. Signed-off-by: Jan Mulder diff -r 625d20070261 -r 2b9775f71e30 Small_CPU/Inc/scheduler.h --- a/Small_CPU/Inc/scheduler.h Mon Apr 08 11:49:13 2019 +0200 +++ b/Small_CPU/Inc/scheduler.h Mon Apr 08 11:18:40 2019 +0200 @@ -69,7 +69,7 @@ uint8_t accidentFlag; uint32_t accidentRemainingSeconds; uint8_t sensorError[MAX_SENSORS]; - uint8_t I2C_SystemStatus; + HAL_StatusTypeDef I2C_SystemStatus; } SGlobal; typedef struct diff -r 625d20070261 -r 2b9775f71e30 Small_CPU/Src/i2c.c --- a/Small_CPU/Src/i2c.c Mon Apr 08 11:49:13 2019 +0200 +++ b/Small_CPU/Src/i2c.c Mon Apr 08 11:18:40 2019 +0200 @@ -23,13 +23,6 @@ } */ -//TODO: remove this function. Why return a global variable? -HAL_StatusTypeDef I2C1_Status(void) -{ -return (HAL_StatusTypeDef)global.I2C_SystemStatus; -} - - GPIO_PinState HAL_I2C_Read_Data_PIN(void) { return HAL_GPIO_ReadPin(I2Cx_SDA_GPIO_PORT,I2Cx_SDA_PIN); @@ -57,7 +50,6 @@ return HAL_I2C_Read_Data_PIN(); } -//TODO: make this void. return is never used HAL_StatusTypeDef MX_I2C1_Init(void) { I2cHandle.Instance = I2Cx; @@ -77,7 +69,7 @@ { scheduleSpecial_Evaluate_DataSendToSlave(); } - return (HAL_StatusTypeDef)global.I2C_SystemStatus; + return global.I2C_SystemStatus; } @@ -104,10 +96,9 @@ I2C_Error_count(); } - return (HAL_StatusTypeDef)global.I2C_SystemStatus; + return global.I2C_SystemStatus; } -// TODO: return value never used HAL_StatusTypeDef I2C_Master_Receive( uint16_t DevAddress, uint8_t *pData, uint16_t Size) { if(global.I2C_SystemStatus != HAL_OK) diff -r 625d20070261 -r 2b9775f71e30 Small_CPU/Src/pressure.c --- a/Small_CPU/Src/pressure.c Mon Apr 08 11:49:13 2019 +0200 +++ b/Small_CPU/Src/pressure.c Mon Apr 08 11:18:40 2019 +0200 @@ -29,7 +29,7 @@ at the beginning of a dive the oldest value will be used */ - +#include "scheduler.h" #include "pressure.h" #include "i2c.h" #include "rtc.h" @@ -261,7 +261,7 @@ C2_x_2p16 = C[2] * 65536; C1_x_2p15 = C[1] * 32768; - if(I2C1_Status() == HAL_OK) + if(global.I2C_SystemStatus == HAL_OK) { pressureSensorInitSuccess = 1; } @@ -360,7 +360,7 @@ void pressure_calculation(void) { - if(I2C1_Status() != HAL_OK) + if(global.I2C_SystemStatus != HAL_OK) return; pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015();