annotate Small_CPU/Src/uart.c @ 902:d4622533271d Evo_2_23

VPM table mode: Because of the model maths, usage of float data type and so on it may happen that the TTS decreases during ascent and continues calculation of the vpm. To keep the values stable the vpm table mode has been introduces. Instead of continously calculation of the stops the stop time is decreased if the diver is close to a deco stop. If the table is violated (e.g. by not doing gas change) the table will be updated to the new, longer runtime. The table will not be switch back to a shorter version in case e.g. the missed gas change is performed
author Ideenmodellierer
date Wed, 02 Oct 2024 22:18:19 +0200
parents 9e2f9b91e827
children 4832981f9af8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file uart.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 27-March-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief button control
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 * <h2><center>&copy; COPYRIGHT(c) 2015 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 #include "uart.h"
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
23 #include "uartProtocol_O2.h"
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
24 #include "uartProtocol_Co2.h"
842
c3dd461ca3f9 Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents: 809
diff changeset
25 #include "uartProtocol_Sentinel.h"
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
26 #include "externalInterface.h"
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
27 #include "data_exchange.h"
704
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 690
diff changeset
28 #include <string.h> /* memset */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
30
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
33
787
aeb72882f30a Dev Bugfx Empty buffer indication and stability improvments:
Ideenmodellierer
parents: 785
diff changeset
34
781
01b3eb9d55c3 Update real multiplexer implementation:
Ideenmodellierer
parents: 779
diff changeset
35 #define CHUNK_SIZE (25u) /* the DMA will handle chunk size transfers */
01b3eb9d55c3 Update real multiplexer implementation:
Ideenmodellierer
parents: 779
diff changeset
36 #define CHUNKS_PER_BUFFER (5u)
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
37
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
38
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
39
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
40 DMA_HandleTypeDef hdma_usart1_rx, hdma_usart6_rx, hdma_usart6_tx;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
42 uint8_t rxBuffer[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
43 uint8_t rxBufferUart6[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
44 uint8_t txBufferUart6[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
45
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
46 static uint8_t rxWriteIndex; /* Index of the data item which is analysed */
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
47 static uint8_t rxReadIndex; /* Index at which new data is stared */
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
48 static uint8_t lastCmdIndex; /* Index of last command which has not been completely received */
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
49 static uint8_t dmaActive; /* Indicator if DMA reception needs to be started */
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
50
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
51
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
52
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
53
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
56
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
57 void MX_USART1_UART_Init(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
59 /* regular init */
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
60
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
61 huart1.Instance = USART1;
803
96ffad0a4e57 Cleanup initialisation / deinitialization:
Ideenmodellierer
parents: 798
diff changeset
62 huart1.Init.BaudRate = 19200;
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
63 huart1.Init.WordLength = UART_WORDLENGTH_8B;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
64 huart1.Init.StopBits = UART_STOPBITS_1;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
65 huart1.Init.Parity = UART_PARITY_NONE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
66 huart1.Init.Mode = UART_MODE_TX_RX;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
67 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
68 huart1.Init.OverSampling = UART_OVERSAMPLING_16;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
69
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
70 HAL_UART_Init(&huart1);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
71
704
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 690
diff changeset
72 MX_USART1_DMA_Init();
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 690
diff changeset
73
787
aeb72882f30a Dev Bugfx Empty buffer indication and stability improvments:
Ideenmodellierer
parents: 785
diff changeset
74 memset(rxBuffer,BUFFER_NODATA,sizeof(rxBuffer));
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
75 rxReadIndex = 0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
76 lastCmdIndex = 0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
77 rxWriteIndex = 0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
78 dmaActive = 0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
79 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
81
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
82
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
83 void MX_USART1_UART_DeInit(void)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
84 {
704
f1b40364b0af Added protocol functions for UART DiveO2 sensor:
Ideenmodellierer
parents: 690
diff changeset
85 HAL_DMA_Abort(&hdma_usart1_rx);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
86 HAL_DMA_DeInit(&hdma_usart1_rx);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
87 HAL_UART_DeInit(&huart1);
803
96ffad0a4e57 Cleanup initialisation / deinitialization:
Ideenmodellierer
parents: 798
diff changeset
88 dmaActive = 0;
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
89 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
90
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
91 void MX_USART1_DMA_Init()
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
92 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
93 /* DMA controller clock enable */
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
94 __DMA2_CLK_ENABLE();
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
95
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
96 /* Peripheral DMA init*/
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
97 hdma_usart1_rx.Instance = DMA2_Stream5;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
98 hdma_usart1_rx.Init.Channel = DMA_CHANNEL_4;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
99 hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; //DMA_MEMORY_TO_PERIPH;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
100 hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
101 hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
102 hdma_usart1_rx.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
103 hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
104 hdma_usart1_rx.Init.Mode = DMA_NORMAL;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
105 hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
106 hdma_usart1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
107 HAL_DMA_Init(&hdma_usart1_rx);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
108
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
109 __HAL_LINKDMA(&huart1,hdmarx,hdma_usart1_rx);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
110
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
111 /* DMA interrupt init */
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
112 HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 0, 0);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
113 HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
116
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
117 void GNSS_IO_init() {
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
118
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
119 GPIO_InitTypeDef GPIO_InitStruct = { 0 };
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
120 /* Peripheral clock enable */
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
121 __HAL_RCC_USART6_CLK_ENABLE()
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
122 ;
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
123
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
124 __HAL_RCC_GPIOA_CLK_ENABLE()
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
125 ;
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
126 /**USART6 GPIO Configuration
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
127 PA11 ------> USART6_TX
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
128 PA12 ------> USART6_RX
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
129 */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
130 GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
131 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
132 GPIO_InitStruct.Pull = GPIO_NOPULL;
894
9e2f9b91e827 GNSS UART DMA test
heinrichsweikamp
parents: 890
diff changeset
133 GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
134 GPIO_InitStruct.Alternate = GPIO_AF8_USART6;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
135 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
136
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
137 /* USART6 DMA Init */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
138 /* USART6_RX Init */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
139 hdma_usart6_rx.Instance = DMA2_Stream2;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
140 hdma_usart6_rx.Init.Channel = DMA_CHANNEL_5;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
141 hdma_usart6_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
142 hdma_usart6_rx.Init.PeriphInc = DMA_PINC_DISABLE;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
143 hdma_usart6_rx.Init.MemInc = DMA_MINC_ENABLE;
894
9e2f9b91e827 GNSS UART DMA test
heinrichsweikamp
parents: 890
diff changeset
144 hdma_usart6_rx.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
145 hdma_usart6_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
146 hdma_usart6_rx.Init.Mode = DMA_NORMAL;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
147 hdma_usart6_rx.Init.Priority = DMA_PRIORITY_LOW;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
148 hdma_usart6_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
149 HAL_DMA_Init(&hdma_usart6_rx);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
150
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
151 __HAL_LINKDMA(&huart6, hdmarx, hdma_usart6_rx);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
152
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
153 /* USART6_TX Init */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
154 hdma_usart6_tx.Instance = DMA2_Stream6;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
155 hdma_usart6_tx.Init.Channel = DMA_CHANNEL_5;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
156 hdma_usart6_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
157 hdma_usart6_tx.Init.PeriphInc = DMA_PINC_DISABLE;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
158 hdma_usart6_tx.Init.MemInc = DMA_MINC_ENABLE;
894
9e2f9b91e827 GNSS UART DMA test
heinrichsweikamp
parents: 890
diff changeset
159 hdma_usart6_tx.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
160 hdma_usart6_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
161 hdma_usart6_tx.Init.Mode = DMA_NORMAL;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
162 hdma_usart6_tx.Init.Priority = DMA_PRIORITY_LOW;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
163 hdma_usart6_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
164 HAL_DMA_Init(&hdma_usart6_tx);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
165
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
166 __HAL_LINKDMA(&huart6, hdmatx, hdma_usart6_tx);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
167
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
168 /* USART6 interrupt Init */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
169 HAL_NVIC_SetPriority(USART6_IRQn, 0, 0);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
170 HAL_NVIC_EnableIRQ(USART6_IRQn);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
171
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
172 MX_USART6_DMA_Init();
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
173
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
174 }
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
175
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
176 void MX_USART6_DMA_Init() {
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
177 /* DMA controller clock enable */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
178 __HAL_RCC_DMA2_CLK_ENABLE();
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
179
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
180 /* DMA interrupt init */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
181 /* DMA2_Stream2_IRQn interrupt configuration */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
182 HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 0, 0);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
183 HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
184 /* DMA2_Stream6_IRQn interrupt configuration */
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
185 HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 0, 0);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
186 HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
187 }
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
188
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
189
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
190 void MX_USART6_UART_DeInit(void)
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
191 {
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
192 HAL_DMA_Abort(&hdma_usart6_rx);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
193 HAL_DMA_DeInit(&hdma_usart6_rx);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
194 HAL_DMA_Abort(&hdma_usart6_tx);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
195 HAL_DMA_DeInit(&hdma_usart6_tx);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
196 HAL_UART_DeInit(&huart6);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
197 HAL_UART_DeInit(&huart6);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
198 }
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
199
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
200 void MX_USART6_UART_Init(void) {
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
201 huart6.Instance = USART6;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
202 huart6.Init.BaudRate = 9600;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
203 huart6.Init.WordLength = UART_WORDLENGTH_8B;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
204 huart6.Init.StopBits = UART_STOPBITS_1;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
205 huart6.Init.Parity = UART_PARITY_NONE;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
206 huart6.Init.Mode = UART_MODE_TX_RX;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
207 huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
208 huart6.Init.OverSampling = UART_OVERSAMPLING_16;
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
209 HAL_UART_Init(&huart6);
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
210 }
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 861
diff changeset
211
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
212 void UART_MUX_SelectAddress(uint8_t muxAddress)
779
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
213 {
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
214 uint8_t indexstr[4];
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
215
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
216 if(muxAddress <= MAX_MUX_CHANNEL)
779
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
217 {
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
218 indexstr[0] = '~';
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
219 indexstr[1] = muxAddress;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
220 indexstr[2] = 0x0D;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
221 indexstr[3] = 0x0A;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
222
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
223 HAL_UART_Transmit(&huart1,indexstr,4,10);
779
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
224 }
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
225 }
0b5f45448eb6 Added UART multiplexer support for DiveO2:
Ideenmodellierer
parents: 747
diff changeset
226
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
227
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
228 void UART_SendCmdString(uint8_t *cmdString)
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
229 {
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
230 uint8_t cmdLength = strlen((char*)cmdString);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
231
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
232 if(cmdLength < 20) /* A longer string is an indication for a missing 0 termination */
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
233 {
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
234 if(dmaActive == 0)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
235 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
236 UART_StartDMA_Receiption();
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
237 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
238 HAL_UART_Transmit(&huart1,cmdString,cmdLength,10);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
239 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
240 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
241
729
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
242
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
243 void StringToInt(char *pstr, uint32_t *puInt32)
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
244 {
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
245 uint8_t index = 0;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
246 uint32_t result = 0;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
247 while((pstr[index] >= '0') && (pstr[index] <= '9'))
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
248 {
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
249 result *=10;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
250 result += pstr[index] - '0';
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
251 index++;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
252 }
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
253 *puInt32 = result;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
254 }
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
255
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
256 void StringToUInt64(char *pstr, uint64_t *puint64)
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
257 {
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
258 uint8_t index = 0;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
259 uint64_t result = 0;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
260 while((pstr[index] >= '0') && (pstr[index] <= '9'))
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
261 {
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
262 result *=10;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
263 result += pstr[index] - '0';
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
264 index++;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
265 }
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
266 *puint64 = result;
d646a0f724a7 Added auto detection functionality for sensors connected to the external interface:
Ideenmodellierer
parents: 725
diff changeset
267 }
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
268
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 731
diff changeset
269 void UART_StartDMA_Receiption()
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 731
diff changeset
270 {
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
271 if(dmaActive == 0)
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 731
diff changeset
272 {
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
273 if(HAL_OK == HAL_UART_Receive_DMA (&huart1, &rxBuffer[rxWriteIndex], CHUNK_SIZE))
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
274 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
275 dmaActive = 1;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
276 }
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 731
diff changeset
277 }
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 731
diff changeset
278 }
690
fca2bd25e6e2 Added Sentinel protocoll support:
Ideenmodellierer
parents: 662
diff changeset
279
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
280 void UART_ChangeBaudrate(uint32_t newBaudrate)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 {
809
9602a7338f28 DevBugfix CO2 sensor in streaming mode:
Ideenmodellierer
parents: 803
diff changeset
282 uint8_t dmaWasActive = dmaActive;
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
283 // HAL_DMA_Abort(&hdma_usart1_rx);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
284 MX_USART1_UART_DeInit();
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
285 //HAL_UART_Abort(&huart1);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
286 //HAL_DMA_DeInit(&hdma_usart1_rx);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
287
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
288
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
289 // huart1.Instance->BRR = UART_BRR_SAMPLING8(HAL_RCC_GetPCLK2Freq()/2, newBaudrate);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
290 huart1.Init.BaudRate = newBaudrate;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
291 HAL_UART_Init(&huart1);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
292 MX_USART1_DMA_Init();
809
9602a7338f28 DevBugfix CO2 sensor in streaming mode:
Ideenmodellierer
parents: 803
diff changeset
293 if(dmaWasActive)
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
294 {
809
9602a7338f28 DevBugfix CO2 sensor in streaming mode:
Ideenmodellierer
parents: 803
diff changeset
295 memset(rxBuffer,BUFFER_NODATA,sizeof(rxBuffer));
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
296 rxReadIndex = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
297 rxWriteIndex = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
298 dmaActive = 0;
742
e23fe82cbf8c Update Sentinel protocol:
Ideenmodellierer
parents: 731
diff changeset
299 UART_StartDMA_Receiption();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
300 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 }
690
fca2bd25e6e2 Added Sentinel protocoll support:
Ideenmodellierer
parents: 662
diff changeset
302
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
303 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
305 if(huart == &huart1)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
306 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
307 dmaActive = 0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
308 rxWriteIndex+=CHUNK_SIZE;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
309 if(rxWriteIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
310 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
311 rxWriteIndex = 0;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
312 }
787
aeb72882f30a Dev Bugfx Empty buffer indication and stability improvments:
Ideenmodellierer
parents: 785
diff changeset
313 if((rxWriteIndex / CHUNK_SIZE) != (rxReadIndex / CHUNK_SIZE) || (rxWriteIndex == rxReadIndex)) /* start next transfer if we did not catch up with read index */
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
314 {
809
9602a7338f28 DevBugfix CO2 sensor in streaming mode:
Ideenmodellierer
parents: 803
diff changeset
315 UART_StartDMA_Receiption();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
316 }
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
317 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
320 void UART_ReadData(uint8_t sensorType)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
321 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
322 uint8_t localRX = rxReadIndex;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
324 while((rxBuffer[localRX]!=BUFFER_NODATA))
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
325 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
326 switch (sensorType)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
327 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
328 case SENSOR_MUX:
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
329 case SENSOR_DIGO2: uartO2_ProcessData(rxBuffer[localRX]);
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
330 break;
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
331 #ifdef ENABLE_CO2_SUPPORT
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
332 case SENSOR_CO2: uartCo2_ProcessData(rxBuffer[localRX]);
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
333 break;
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents: 794
diff changeset
334 #endif
842
c3dd461ca3f9 Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents: 809
diff changeset
335 #ifdef ENABLE_SENTINEL_MODE
c3dd461ca3f9 Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents: 809
diff changeset
336 case SENSOR_SENTINEL: uartSentinel_ProcessData(rxBuffer[localRX]);
c3dd461ca3f9 Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents: 809
diff changeset
337 break;
c3dd461ca3f9 Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents: 809
diff changeset
338 #endif
794
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
339 default:
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
340 break;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
341 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
342
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
343 rxBuffer[localRX] = BUFFER_NODATA;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
344 localRX++;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
345 rxReadIndex++;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
346 if(rxReadIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
347 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
348 localRX = 0;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
349 rxReadIndex = 0;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
350 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
351 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
352 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
353
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
354 void UART_FlushRxBuffer(void)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
355 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
356 while(rxBuffer[rxReadIndex] != BUFFER_NODATA)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
357 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
358 rxBuffer[rxReadIndex] = BUFFER_NODATA;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
359 rxReadIndex++;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
360 if(rxReadIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
361 {
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
362 rxReadIndex = 0;
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
363 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
364 }
bb37d4f3e50e Restructure UART based sensor handling:
Ideenmodellierer
parents: 787
diff changeset
365 }
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 38
diff changeset
366
861
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
367 uint8_t UART_isComActive(uint8_t sensorId)
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
368 {
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
369 uint8_t active = 1;
809
9602a7338f28 DevBugfix CO2 sensor in streaming mode:
Ideenmodellierer
parents: 803
diff changeset
370
861
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
371 uint8_t ComState = externalInterface_GetSensorState(sensorId + EXT_INTERFACE_MUX_OFFSET);
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
372
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
373 if((ComState == UART_COMMON_INIT) || (ComState == UART_COMMON_IDLE) || (ComState == UART_COMMON_ERROR))
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
374 {
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
375 active = 0;
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
376 }
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
377 return active;
ad96f99ebc78 Synchronize ADC and UART activities:
Ideenmodellierer
parents: 842
diff changeset
378 }
809
9602a7338f28 DevBugfix CO2 sensor in streaming mode:
Ideenmodellierer
parents: 803
diff changeset
379
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/