Mercurial > public > ostc4
comparison Small_CPU/Src/uart.c @ 921:eb4109d7d1e9 Evo_2_23
Improved mix mode ADC conversion:
Activity of UART sensors may have an impact to ADC measurement. To avoid the ADC trigger was moved into a time window ~300ms after last UART command request => After UART sensor performed measurement but before next measurement is requested. In addition the general ADC measurement cycle has been changed to one second to avoid jitter in the value updates on the display.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Nov 2024 18:19:51 +0100 |
parents | f72613a152dd |
children | 7c996354b8ac |
comparison
equal
deleted
inserted
replaced
920:c4c9850a2039 | 921:eb4109d7d1e9 |
---|---|
52 static uint8_t rxReadIndex; /* Index at which new data is stared */ | 52 static uint8_t rxReadIndex; /* Index at which new data is stared */ |
53 static uint8_t lastCmdIndex; /* Index of last command which has not been completely received */ | 53 static uint8_t lastCmdIndex; /* Index of last command which has not been completely received */ |
54 static uint8_t dmaRxActive; /* Indicator if DMA reception needs to be started */ | 54 static uint8_t dmaRxActive; /* Indicator if DMA reception needs to be started */ |
55 static uint8_t dmaTxActive; /* Indicator if DMA reception needs to be started */ | 55 static uint8_t dmaTxActive; /* Indicator if DMA reception needs to be started */ |
56 | 56 |
57 static uint32_t LastCmdRequestTick = 0; /* Used by ADC handler to avoid interferance with UART communication */ | |
57 | 58 |
58 static uint8_t isEndIndication(uint8_t index); | 59 static uint8_t isEndIndication(uint8_t index); |
59 | 60 |
60 /* Exported functions --------------------------------------------------------*/ | 61 /* Exported functions --------------------------------------------------------*/ |
61 | 62 |
295 } | 296 } |
296 memcpy(txBuffer, cmdString, cmdLength); | 297 memcpy(txBuffer, cmdString, cmdLength); |
297 if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,cmdLength)) | 298 if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,cmdLength)) |
298 { | 299 { |
299 dmaTxActive = 1; | 300 dmaTxActive = 1; |
301 LastCmdRequestTick = HAL_GetTick(); | |
300 } | 302 } |
301 } | 303 } |
302 } | 304 } |
303 else | 305 else |
304 { | 306 { |
317 } | 319 } |
318 memcpy(txBuffer, cmd, len); | 320 memcpy(txBuffer, cmd, len); |
319 if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,len)) | 321 if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,len)) |
320 { | 322 { |
321 dmaTxActive = 1; | 323 dmaTxActive = 1; |
324 LastCmdRequestTick = HAL_GetTick(); | |
322 } | 325 } |
323 } | 326 } |
324 } | 327 } |
325 | 328 |
326 | 329 |
542 { | 545 { |
543 uint8_t active = 1; | 546 uint8_t active = 1; |
544 | 547 |
545 uint8_t ComState = externalInterface_GetSensorState(sensorId + EXT_INTERFACE_MUX_OFFSET); | 548 uint8_t ComState = externalInterface_GetSensorState(sensorId + EXT_INTERFACE_MUX_OFFSET); |
546 | 549 |
547 if((ComState == UART_COMMON_INIT) || (ComState == UART_COMMON_IDLE) || (ComState == UART_COMMON_ERROR) || (ComState == COMMON_SENSOR_STATE_INVALID)) | 550 if(time_elapsed_ms(LastCmdRequestTick, HAL_GetTick()) > 300) /* UART activity should be inactive 300ms after last command */ |
548 { | 551 { |
549 active = 0; | 552 active = 0; |
550 } | 553 } |
551 return active; | 554 return active; |
552 } | 555 } |
553 | 556 |
557 | |
554 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ | 558 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |