Mercurial > public > ostc4
changeset 239:e4207f0aaa4b div-fixes-5
cleanup: factor out dataSendToSlaveStopEval
The global dataSendToSlaveStopEval was set all over the place, but never
tested, so useless to set it. And remove an unused piece of code. Trivial
cleanup.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Mon, 08 Apr 2019 10:35:29 +0200 |
parents | a9d798e8c11f |
children | 625d20070261 |
files | Small_CPU/Inc/scheduler.h Small_CPU/Src/baseCPU2.c Small_CPU/Src/i2c.c Small_CPU/Src/spi.c |
diffstat | 4 files changed, 2 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/Small_CPU/Inc/scheduler.h Mon Apr 08 10:16:17 2019 +0200 +++ b/Small_CPU/Inc/scheduler.h Mon Apr 08 10:35:29 2019 +0200 @@ -60,7 +60,6 @@ _Bool demo_mode; uint8_t dataSendToSlaveIsValid; uint8_t dataSendToSlavePending; - uint8_t dataSendToSlaveStopEval; uint32_t sync_error_count; uint32_t check_sync_not_running; uint8_t ButtonResponsiveness[4];
--- a/Small_CPU/Src/baseCPU2.c Mon Apr 08 10:16:17 2019 +0200 +++ b/Small_CPU/Src/baseCPU2.c Mon Apr 08 10:35:29 2019 +0200 @@ -48,7 +48,7 @@ [..] HAL_SPI_TxRxCpltCallback() restarts DMA and will call scheduleSpecial_Evaluate_DataSendToSlave() only if it is not blocked - by I2C for example by setting global.dataSendToSlaveStopEval to 0. + by I2C. If the evaluation is blocked it has to be tested and executed afterwards. I2C is executed _without_ the usage of interrupts.
--- a/Small_CPU/Src/i2c.c Mon Apr 08 10:16:17 2019 +0200 +++ b/Small_CPU/Src/i2c.c Mon Apr 08 10:35:29 2019 +0200 @@ -68,16 +68,11 @@ I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; I2cHandle.Init.OwnAddress1 = 0x01; - - global.dataSendToSlaveStopEval = 1; global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle); HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED); HAL_I2CEx_ConfigDigitalFilter(&I2cHandle,0x0F); - - - global.dataSendToSlaveStopEval = 0; if(global.dataSendToSlavePending) { scheduleSpecial_Evaluate_DataSendToSlave(); @@ -91,51 +86,23 @@ HAL_I2C_DeInit(&I2cHandle); } - -uint8_t i2c_errors = 0; +static uint8_t i2c_errors = 0; void I2C_Error_count(void) { i2c_errors++; } -//TODO: not used, remove -HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size) -{ - if(global.I2C_SystemStatus != HAL_OK) - return (HAL_StatusTypeDef)global.I2C_SystemStatus; - - global.dataSendToSlaveStopEval = 1; - - global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 0); - if(global.I2C_SystemStatus != HAL_OK) - { - I2C_Error_count(); - } - global.dataSendToSlaveStopEval = 0; - //TODO: REMOVE. -// if(global.dataSendToSlavePending) -// { -// scheduleSpecial_Evaluate_DataSendToSlave(); -// } - return (HAL_StatusTypeDef)global.I2C_SystemStatus; -} - - HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size) { if(global.I2C_SystemStatus != HAL_OK) return global.I2C_SystemStatus; - - global.dataSendToSlaveStopEval = 1; global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 2); if(global.I2C_SystemStatus != HAL_OK) { I2C_Error_count(); } - - global.dataSendToSlaveStopEval = 0; return (HAL_StatusTypeDef)global.I2C_SystemStatus; } @@ -146,16 +113,11 @@ if(global.I2C_SystemStatus != HAL_OK) return global.I2C_SystemStatus; - global.dataSendToSlaveStopEval = 1; - global.I2C_SystemStatus = HAL_I2C_Master_Receive(&I2cHandle, DevAddress, pData, Size, 10); if(global.I2C_SystemStatus != HAL_OK) { I2C_Error_count(); } - global.dataSendToSlaveStopEval = 0; - return global.I2C_SystemStatus; } -
--- a/Small_CPU/Src/spi.c Mon Apr 08 10:16:17 2019 +0200 +++ b/Small_CPU/Src/spi.c Mon Apr 08 10:35:29 2019 +0200 @@ -382,10 +382,6 @@ global.dataSendToMaster.power_on_reset = 0; global.deviceDataSendToMaster.power_on_reset = 0; - //TODO:REMOVE - // if ( !global.dataSendToSlaveStopEval ) { - // scheduleSpecial_Evaluate_DataSendToSlave(); - // } scheduleSpecial_Evaluate_DataSendToSlave(); SPI_Start_single_TxRx_with_Master();