Mercurial > public > ostc4
annotate Discovery/Src/ostc.c @ 619:8fa2de4414a8
Added t3 quick menu for marker synchronisation:
By selecting the "Check" optin of the quickmenu available in the T3_Profile view only, the live profile data may be syncronised with the marker data stored in the log profile. The implementation does not mentain a history storage. In case all markes have been checked the next check will cause the live data to be shown. another check will then map the profile again to the first marker.
To support this functionality menu infra structures have been added to the menu handling functions.
author | Ideenmodellierer |
---|---|
date | Wed, 27 Jan 2021 22:10:11 +0100 |
parents | 37ee61f93124 |
children | bc6c90e20d9e |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/ostc.c | |
5 /// \brief Hardware specific configuration | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 05-Dec-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include "ostc.h" | |
31 #include "stm32f4xx_hal.h" | |
32 | |
33 #ifndef BOOTLOADER_STANDALONE | |
34 #include "tCCR.h" | |
35 #endif | |
36 | |
37 /* Exported variables --------------------------------------------------------*/ | |
38 SPI_HandleTypeDef hspiDisplay; | |
39 SPI_HandleTypeDef cpu2DmaSpi; | |
40 | |
41 | |
42 UART_HandleTypeDef UartHandle; | |
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
140
diff
changeset
|
43 #ifdef USART_PIEZO |
38 | 44 UART_HandleTypeDef UartPiezoTxHandle; |
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
140
diff
changeset
|
45 #endif |
38 | 46 UART_HandleTypeDef UartIR_HUD_Handle; |
47 | |
48 __IO ITStatus UartReady = RESET; | |
49 | |
50 /* Private types -------------------------------------------------------------*/ | |
51 | |
52 /* Private variables ---------------------------------------------------------*/ | |
53 | |
54 /* Private variables with external access via get_xxx() function -------------*/ | |
55 | |
56 /* Private function prototypes -----------------------------------------------*/ | |
57 | |
58 /* Exported functions --------------------------------------------------------*/ | |
59 | |
60 /** SPI init function | |
61 * called from HAL | |
62 */ | |
63 void MX_SPI_Init(void) | |
64 { | |
65 hspiDisplay.Instance = SPI5; | |
66 hspiDisplay.Init.Mode = SPI_MODE_MASTER; | |
67 hspiDisplay.Init.Direction = SPI_DIRECTION_2LINES; | |
68 hspiDisplay.Init.DataSize = SPI_DATASIZE_8BIT; | |
69 hspiDisplay.Init.CLKPolarity = SPI_POLARITY_LOW; | |
70 hspiDisplay.Init.CLKPhase = SPI_PHASE_1EDGE; | |
71 hspiDisplay.Init.NSS = SPI_NSS_SOFT; | |
72 hspiDisplay.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;//SPI_BAUDRATEPRESCALER_4;//SPI_BAUDRATEPRESCALER_256; | |
73 hspiDisplay.Init.FirstBit = SPI_FIRSTBIT_MSB; | |
74 hspiDisplay.Init.TIMode = SPI_TIMODE_DISABLED; | |
75 hspiDisplay.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; | |
76 HAL_SPI_Init(&hspiDisplay); | |
77 | |
78 cpu2DmaSpi.Instance = SPI1; | |
79 cpu2DmaSpi.Init.Mode = SPI_MODE_MASTER; | |
80 cpu2DmaSpi.Init.Direction = SPI_DIRECTION_2LINES; | |
81 cpu2DmaSpi.Init.DataSize = SPI_DATASIZE_8BIT; | |
82 cpu2DmaSpi.Init.CLKPolarity = SPI_POLARITY_LOW; | |
83 cpu2DmaSpi.Init.CLKPhase = SPI_PHASE_1EDGE; | |
84 cpu2DmaSpi.Init.NSS = SPI_NSS_SOFT;//SPI_NSS_HARD_OUTPUT;//SPI_NSS_SOFT; | |
140
f6c52eb0e25d
Increase prescalar => frame takes about 4ms.
Ideenmodellierer
parents:
104
diff
changeset
|
85 cpu2DmaSpi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; |
38 | 86 cpu2DmaSpi.Init.FirstBit = SPI_FIRSTBIT_MSB; |
87 cpu2DmaSpi.Init.TIMode = SPI_TIMODE_DISABLED; | |
88 cpu2DmaSpi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; | |
89 cpu2DmaSpi.Init.CRCPolynomial = 7; | |
90 | |
91 HAL_SPI_Init(&cpu2DmaSpi); | |
92 } | |
93 | |
94 void MX_GPIO_Init(void) | |
95 { | |
96 GPIO_InitTypeDef GPIO_InitStruct; | |
97 | |
98 DISPLAY_CSB_GPIO_ENABLE(); | |
99 DISPLAY_RESETB_GPIO_ENABLE(); | |
100 EXTFLASH_CSB_GPIO_ENABLE(); | |
101 SMALLCPU_CSB_GPIO_ENABLE(); | |
102 OSCILLOSCOPE_GPIO_ENABLE(); | |
103 OSCILLOSCOPE2_GPIO_ENABLE(); | |
104 | |
105 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
106 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
107 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
108 | |
109 GPIO_InitStruct.Pin = DISPLAY_CSB_PIN; | |
110 HAL_GPIO_Init(DISPLAY_CSB_GPIO_PORT, &GPIO_InitStruct); | |
111 | |
112 GPIO_InitStruct.Pin = DISPLAY_RESETB_PIN; | |
113 HAL_GPIO_Init(DISPLAY_RESETB_GPIO_PORT, &GPIO_InitStruct); | |
114 | |
115 GPIO_InitStruct.Pin = EXTFLASH_CSB_PIN; | |
116 HAL_GPIO_Init(EXTFLASH_CSB_GPIO_PORT, &GPIO_InitStruct); | |
117 | |
118 GPIO_InitStruct.Pin = OSCILLOSCOPE_PIN; | |
119 HAL_GPIO_Init(OSCILLOSCOPE_GPIO_PORT, &GPIO_InitStruct); | |
120 | |
121 GPIO_InitStruct.Pin = OSCILLOSCOPE2_PIN; | |
122 HAL_GPIO_Init(OSCILLOSCOPE2_GPIO_PORT, &GPIO_InitStruct); | |
123 | |
124 #ifdef DISPLAY_BACKLIGHT_PIN | |
125 DISPLAY_BACKLIGHT_GPIO_ENABLE(); | |
126 GPIO_InitStruct.Pin = DISPLAY_BACKLIGHT_PIN; | |
127 HAL_GPIO_Init(DISPLAY_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct); | |
128 HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_PORT,DISPLAY_BACKLIGHT_PIN,GPIO_PIN_SET); | |
129 #endif | |
130 | |
131 #ifdef SMALLCPU_CSB_PIN | |
132 SMALLCPU_CSB_GPIO_ENABLE(); | |
133 GPIO_InitStruct.Pin = SMALLCPU_CSB_PIN; | |
134 HAL_GPIO_Init(SMALLCPU_CSB_GPIO_PORT, &GPIO_InitStruct); | |
135 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET); | |
136 #endif | |
137 | |
138 #ifdef SMALLCPU_BOOT0_PIN | |
139 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
140 SMALLCPU_BOOT0_GPIO_ENABLE(); | |
141 GPIO_InitStruct.Pin = SMALLCPU_BOOT0_PIN; | |
142 HAL_GPIO_Init(SMALLCPU_BOOT0_GPIO_PORT, &GPIO_InitStruct); | |
143 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | |
144 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
145 #endif | |
146 | |
147 #ifdef IR_HUD_ENABLE_PIN | |
148 IR_HUD_ENABLE_GPIO_ENABLE(); | |
149 GPIO_InitStruct.Pin = IR_HUD_ENABLE_PIN; | |
150 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
151 HAL_GPIO_Init(IR_HUD_ENABLE_GPIO_PORT, &GPIO_InitStruct); | |
152 HAL_GPIO_WritePin(IR_HUD_ENABLE_GPIO_PORT,IR_HUD_ENABLE_PIN,GPIO_PIN_SET); | |
153 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
154 #endif | |
155 | |
156 #ifdef BLE_NENABLE_PIN | |
157 BLE_NENABLE_GPIO_ENABLE(); | |
158 MX_Bluetooth_PowerOff(); | |
159 #endif | |
160 | |
161 #ifdef TESTPIN | |
162 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
163 TEST_GPIO_ENABLE(); | |
164 GPIO_InitStruct.Pin = TEST_PIN; | |
165 HAL_GPIO_Init(TEST_GPIO_PORT, &GPIO_InitStruct); | |
166 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_SET); | |
167 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
168 #endif | |
169 } | |
170 | |
171 | |
172 void MX_TestPin_High(void) | |
173 { | |
174 #ifdef TESTPIN | |
175 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_SET); | |
176 #endif | |
177 } | |
178 | |
179 | |
180 void MX_TestPin_Low(void) | |
181 { | |
182 #ifdef TESTPIN | |
183 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_RESET); | |
184 #endif | |
185 } | |
186 | |
187 void MX_Bluetooth_PowerOn(void) | |
188 { | |
189 GPIO_InitTypeDef GPIO_InitStruct; | |
190 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
191 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
192 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
193 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; | |
194 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); | |
195 HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); | |
196 } | |
197 | |
198 | |
199 void MX_Bluetooth_PowerOff(void) | |
200 { | |
201 GPIO_InitTypeDef GPIO_InitStruct; | |
202 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
203 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; | |
204 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
205 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); | |
206 } | |
207 | |
208 | |
209 void MX_SmallCPU_Reset_To_Boot(void) | |
210 { | |
211 #ifdef SMALLCPU_NRESET_PIN | |
212 GPIO_InitTypeDef GPIO_InitStruct; | |
213 | |
214 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
215 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
216 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
217 | |
218 SMALLCPU_NRESET_GPIO_ENABLE(); | |
219 GPIO_InitStruct.Pin = SMALLCPU_NRESET_PIN; | |
220 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
221 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_RESET); | |
222 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_SET); | |
223 HAL_Delay(2); | |
224 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
225 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
226 HAL_Delay(100); | |
227 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | |
228 #endif | |
229 } | |
230 | |
231 void MX_SmallCPU_Reset_To_Standard(void) | |
232 { | |
233 #ifdef SMALLCPU_NRESET_PIN | |
234 GPIO_InitTypeDef GPIO_InitStruct; | |
235 | |
236 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
237 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
238 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
239 | |
240 SMALLCPU_NRESET_GPIO_ENABLE(); | |
241 GPIO_InitStruct.Pin = SMALLCPU_NRESET_PIN; | |
242 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
243 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_RESET); | |
244 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | |
245 HAL_Delay(2); | |
246 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
247 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
248 #endif | |
249 } | |
250 | |
251 void MX_UART_Init(void) | |
252 { | |
253 /*##-1- Configure the UART peripheral ######################################*/ | |
254 /* Put the USART peripheral in the Asynchronous mode (UART Mode) */ | |
255 /* UART1 configured as follow: | |
256 - Word Length = 8 Bits | |
257 - Stop Bit = One Stop bit | |
258 - Parity = None | |
259 - BaudRate = 9600 baud | |
260 - Hardware flow control disabled (RTS and CTS signals) */ | |
261 | |
262 #ifdef USARTx_CTS_PIN | |
263 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS; | |
264 #else | |
265 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
266 #endif | |
267 UartHandle.Instance = USARTx; | |
268 UartHandle.Init.BaudRate = 115200; | |
269 UartHandle.Init.WordLength = UART_WORDLENGTH_8B; | |
270 UartHandle.Init.StopBits = UART_STOPBITS_1; | |
271 UartHandle.Init.Parity = UART_PARITY_NONE; | |
272 UartHandle.Init.Mode = UART_MODE_TX_RX; | |
273 HAL_UART_Init(&UartHandle); | |
274 | |
275 #ifdef USART_PIEZO | |
276 UartPiezoTxHandle.Instance = USART_PIEZO; | |
277 UartPiezoTxHandle.Init.BaudRate = 1200; | |
278 UartPiezoTxHandle.Init.WordLength = UART_WORDLENGTH_8B; | |
279 UartPiezoTxHandle.Init.StopBits = UART_STOPBITS_1; | |
280 UartPiezoTxHandle.Init.Parity = UART_PARITY_NONE; | |
281 UartPiezoTxHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
282 UartPiezoTxHandle.Init.Mode = UART_MODE_TX_RX; | |
283 | |
284 HAL_UART_Init(&UartPiezoTxHandle); | |
285 #endif | |
286 | |
287 #ifdef USART_IR_HUD | |
288 UartIR_HUD_Handle.Instance = USART_IR_HUD; | |
289 UartIR_HUD_Handle.Init.BaudRate = 2400; | |
290 UartIR_HUD_Handle.Init.WordLength = UART_WORDLENGTH_8B; | |
291 UartIR_HUD_Handle.Init.StopBits = UART_STOPBITS_1; | |
292 UartIR_HUD_Handle.Init.Parity = UART_PARITY_NONE; | |
293 UartIR_HUD_Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
294 UartIR_HUD_Handle.Init.Mode = UART_MODE_TX_RX; | |
295 | |
296 HAL_UART_Init(&UartIR_HUD_Handle); | |
297 #endif | |
298 } | |
299 | |
300 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) | |
301 { | |
302 if(huart == &UartHandle) | |
303 UartReady = SET; | |
304 } | |
305 | |
321
37ee61f93124
Moved indication variable for received HUD data to tCCR file.
ideenmodellierer
parents:
300
diff
changeset
|
306 |
38 | 307 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) |
308 { | |
309 if(huart == &UartHandle) | |
310 UartReady = SET; | |
311 else | |
312 if(huart == &UartIR_HUD_Handle) | |
313 { | |
321
37ee61f93124
Moved indication variable for received HUD data to tCCR file.
ideenmodellierer
parents:
300
diff
changeset
|
314 tCCR_SetRXIndication(); |
38 | 315 } |
316 } | |
317 | |
318 void MX_tell_reset_logik_alles_ok(void) | |
319 { | |
320 #ifdef RESET_LOGIC_ALLES_OK_PIN | |
321 GPIO_InitTypeDef GPIO_InitStruct; | |
322 | |
323 RESET_LOGIC_ALLES_OK_GPIO_ENABLE(); | |
324 | |
325 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
326 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
327 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
328 GPIO_InitStruct.Pin = RESET_LOGIC_ALLES_OK_PIN; | |
329 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); | |
330 | |
331 HAL_GPIO_WritePin(RESET_LOGIC_ALLES_OK_GPIO_PORT,RESET_LOGIC_ALLES_OK_PIN,GPIO_PIN_RESET); | |
332 HAL_Delay(1); | |
333 HAL_GPIO_WritePin(RESET_LOGIC_ALLES_OK_GPIO_PORT,RESET_LOGIC_ALLES_OK_PIN,GPIO_PIN_SET); | |
334 | |
335 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
336 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); | |
337 #endif | |
338 } | |
339 | |
340 | |
341 #ifndef BOOTLOADER_STANDALONE | |
342 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) | |
343 { | |
344 if(huart == &UartIR_HUD_Handle) | |
345 tCCR_restart(); | |
346 } | |
347 #endif |