annotate Discovery/Src/ostc.c @ 870:bc6c90e20d9e Evo_2_23

Instrument code for Bootloader: the Bootloader was reactivated. Because some functions have changed in the past years an instrumentation had to be done to avoid compile issues (e.g. no multilanguage in Bootloader, no special fonts)
author Ideenmodellierer
date Mon, 12 Aug 2024 22:25:46 +0200
parents 37ee61f93124
children fe955104901c
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 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/ostc.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief Hardware specific configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 05-Dec-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "ostc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #ifndef BOOTLOADER_STANDALONE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "tCCR.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 /* Exported variables --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 SPI_HandleTypeDef hspiDisplay;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 SPI_HandleTypeDef cpu2DmaSpi;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 UART_HandleTypeDef UartIR_HUD_Handle;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 __IO ITStatus UartReady = RESET;
870
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
49 __IO ITStatus UartReadyHUD = RESET;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 /* Private variables with external access via get_xxx() function -------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 /** SPI init function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 * called from HAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 void MX_SPI_Init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 hspiDisplay.Instance = SPI5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 hspiDisplay.Init.Mode = SPI_MODE_MASTER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 hspiDisplay.Init.Direction = SPI_DIRECTION_2LINES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 hspiDisplay.Init.DataSize = SPI_DATASIZE_8BIT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 hspiDisplay.Init.CLKPolarity = SPI_POLARITY_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 hspiDisplay.Init.CLKPhase = SPI_PHASE_1EDGE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 hspiDisplay.Init.NSS = SPI_NSS_SOFT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 hspiDisplay.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;//SPI_BAUDRATEPRESCALER_4;//SPI_BAUDRATEPRESCALER_256;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 hspiDisplay.Init.FirstBit = SPI_FIRSTBIT_MSB;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 hspiDisplay.Init.TIMode = SPI_TIMODE_DISABLED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 hspiDisplay.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 HAL_SPI_Init(&hspiDisplay);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 cpu2DmaSpi.Instance = SPI1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 cpu2DmaSpi.Init.Mode = SPI_MODE_MASTER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 cpu2DmaSpi.Init.Direction = SPI_DIRECTION_2LINES;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 cpu2DmaSpi.Init.DataSize = SPI_DATASIZE_8BIT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 cpu2DmaSpi.Init.CLKPolarity = SPI_POLARITY_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 cpu2DmaSpi.Init.CLKPhase = SPI_PHASE_1EDGE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 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
86 cpu2DmaSpi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 cpu2DmaSpi.Init.FirstBit = SPI_FIRSTBIT_MSB;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 cpu2DmaSpi.Init.TIMode = SPI_TIMODE_DISABLED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 cpu2DmaSpi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 cpu2DmaSpi.Init.CRCPolynomial = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 HAL_SPI_Init(&cpu2DmaSpi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
870
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
95
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
96 void MX_GPIO_Backlight_max_static_only_Init(void)
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
97 {
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
98 GPIO_InitTypeDef GPIO_InitStruct;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
99 TIM_BACKLIGHT_GPIO_ENABLE();
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
100
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
101 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
102 GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
103 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
104
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
105 GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
106 HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
107
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
108 HAL_GPIO_WritePin(TIM_BACKLIGHT_GPIO_PORT,TIM_BACKLIGHT_PIN,GPIO_PIN_SET);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
109 }
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
110
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
111
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
112 void MX_GPIO_One_Button_only_Init(void)
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
113 {
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
114 GPIO_InitTypeDef GPIO_InitStruct;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
115 BUTTON_NEXT_GPIO_ENABLE();
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
116
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
117 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
118 GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
119 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
120
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
121 GPIO_InitStruct.Pin = BUTTON_NEXT_PIN;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
122 HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStruct);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
123 }
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
124
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
125
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
126 GPIO_PinState MX_GPIO_Read_The_One_Button(void)
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
127 {
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
128 return HAL_GPIO_ReadPin(BUTTON_NEXT_GPIO_PORT, BUTTON_NEXT_PIN);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
129 }
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
130
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 void MX_GPIO_Init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 DISPLAY_CSB_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 DISPLAY_RESETB_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 EXTFLASH_CSB_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 SMALLCPU_CSB_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 OSCILLOSCOPE_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 OSCILLOSCOPE2_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 GPIO_InitStruct.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 GPIO_InitStruct.Pin = DISPLAY_CSB_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 HAL_GPIO_Init(DISPLAY_CSB_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 GPIO_InitStruct.Pin = DISPLAY_RESETB_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 HAL_GPIO_Init(DISPLAY_RESETB_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 GPIO_InitStruct.Pin = EXTFLASH_CSB_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 HAL_GPIO_Init(EXTFLASH_CSB_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 GPIO_InitStruct.Pin = OSCILLOSCOPE_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 HAL_GPIO_Init(OSCILLOSCOPE_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 GPIO_InitStruct.Pin = OSCILLOSCOPE2_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 HAL_GPIO_Init(OSCILLOSCOPE2_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 #ifdef DISPLAY_BACKLIGHT_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 DISPLAY_BACKLIGHT_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 GPIO_InitStruct.Pin = DISPLAY_BACKLIGHT_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 HAL_GPIO_Init(DISPLAY_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_PORT,DISPLAY_BACKLIGHT_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 #ifdef SMALLCPU_CSB_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 SMALLCPU_CSB_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 GPIO_InitStruct.Pin = SMALLCPU_CSB_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 HAL_GPIO_Init(SMALLCPU_CSB_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 #ifdef SMALLCPU_BOOT0_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 SMALLCPU_BOOT0_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 GPIO_InitStruct.Pin = SMALLCPU_BOOT0_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 HAL_GPIO_Init(SMALLCPU_BOOT0_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 GPIO_InitStruct.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 #ifdef IR_HUD_ENABLE_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 IR_HUD_ENABLE_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 GPIO_InitStruct.Pin = IR_HUD_ENABLE_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 HAL_GPIO_Init(IR_HUD_ENABLE_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 HAL_GPIO_WritePin(IR_HUD_ENABLE_GPIO_PORT,IR_HUD_ENABLE_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 GPIO_InitStruct.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 #ifdef BLE_NENABLE_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 BLE_NENABLE_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 MX_Bluetooth_PowerOff();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 #ifdef TESTPIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 GPIO_InitStruct.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 TEST_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 GPIO_InitStruct.Pin = TEST_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 HAL_GPIO_Init(TEST_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 GPIO_InitStruct.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 void MX_TestPin_High(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 #ifdef TESTPIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 void MX_TestPin_Low(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 #ifdef TESTPIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 void MX_Bluetooth_PowerOn(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 GPIO_InitStruct.Pin = BLE_NENABLE_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 void MX_Bluetooth_PowerOff(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 GPIO_InitStruct.Pin = BLE_NENABLE_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 void MX_SmallCPU_Reset_To_Boot(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 #ifdef SMALLCPU_NRESET_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 SMALLCPU_NRESET_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 GPIO_InitStruct.Pin = SMALLCPU_NRESET_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 HAL_Delay(2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 HAL_Delay(100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267
870
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
268
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
269 void MX_SmallCPU_NO_Reset_Helper(void)
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
270 {
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
271 #ifdef SMALLCPU_NRESET_PIN
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
272 GPIO_InitTypeDef GPIO_InitStruct;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
273
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
274 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
275 GPIO_InitStruct.Pull = GPIO_NOPULL;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
276 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
277
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
278 SMALLCPU_NRESET_GPIO_ENABLE();
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
279 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
280 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_SET);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
281 // HAL_Delay(100);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
282 // GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
283 // HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
284 #endif
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
285 }
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
286
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
287
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 void MX_SmallCPU_Reset_To_Standard(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 #ifdef SMALLCPU_NRESET_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 SMALLCPU_NRESET_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 GPIO_InitStruct.Pin = SMALLCPU_NRESET_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 HAL_Delay(2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307
870
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
308
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
309 uint8_t MX_UART_ButtonAdjust(uint8_t *array)
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
310 {
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
311 #ifdef USART_PIEZO
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
312 uint8_t answer[4];
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
313 HAL_UART_Transmit(&UartPiezoTxHandle,array,4,1000);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
314 HAL_UART_Receive(&UartPiezoTxHandle,answer,4,2000);
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
315 if( (answer[0] == array[0])
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
316 &&(answer[1] == array[1])
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
317 &&(answer[2] == array[2])
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
318 &&(answer[3] == array[3]))
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
319 return 1;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
320 #endif
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
321 return 0;
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
322 }
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
323
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
324
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 void MX_UART_Init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 /*##-1- Configure the UART peripheral ######################################*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 /* UART1 configured as follow:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 - Word Length = 8 Bits
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 - Stop Bit = One Stop bit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 - Parity = None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 - BaudRate = 9600 baud
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 - Hardware flow control disabled (RTS and CTS signals) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 #ifdef USARTx_CTS_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 #else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 UartHandle.Instance = USARTx;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 UartHandle.Init.BaudRate = 115200;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 UartHandle.Init.StopBits = UART_STOPBITS_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 UartHandle.Init.Parity = UART_PARITY_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 UartHandle.Init.Mode = UART_MODE_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 HAL_UART_Init(&UartHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 #ifdef USART_PIEZO
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 UartPiezoTxHandle.Instance = USART_PIEZO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 UartPiezoTxHandle.Init.BaudRate = 1200;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 UartPiezoTxHandle.Init.WordLength = UART_WORDLENGTH_8B;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 UartPiezoTxHandle.Init.StopBits = UART_STOPBITS_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 UartPiezoTxHandle.Init.Parity = UART_PARITY_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 UartPiezoTxHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 UartPiezoTxHandle.Init.Mode = UART_MODE_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 HAL_UART_Init(&UartPiezoTxHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 #ifdef USART_IR_HUD
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 UartIR_HUD_Handle.Instance = USART_IR_HUD;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 UartIR_HUD_Handle.Init.BaudRate = 2400;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 UartIR_HUD_Handle.Init.WordLength = UART_WORDLENGTH_8B;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 UartIR_HUD_Handle.Init.StopBits = UART_STOPBITS_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 UartIR_HUD_Handle.Init.Parity = UART_PARITY_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 UartIR_HUD_Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 UartIR_HUD_Handle.Init.Mode = UART_MODE_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 HAL_UART_Init(&UartIR_HUD_Handle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 if(huart == &UartHandle)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 UartReady = SET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379
321
37ee61f93124 Moved indication variable for received HUD data to tCCR file.
ideenmodellierer
parents: 300
diff changeset
380
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 if(huart == &UartHandle)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 UartReady = SET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 if(huart == &UartIR_HUD_Handle)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 {
870
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
388 #ifndef BOOTLOADER_STANDALONE
321
37ee61f93124 Moved indication variable for received HUD data to tCCR file.
ideenmodellierer
parents: 300
diff changeset
389 tCCR_SetRXIndication();
870
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
390 #endif
bc6c90e20d9e Instrument code for Bootloader:
Ideenmodellierer
parents: 321
diff changeset
391 UartReadyHUD = SET;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 void MX_tell_reset_logik_alles_ok(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 #ifdef RESET_LOGIC_ALLES_OK_PIN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 RESET_LOGIC_ALLES_OK_GPIO_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 GPIO_InitStruct.Pin = RESET_LOGIC_ALLES_OK_PIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 HAL_GPIO_WritePin(RESET_LOGIC_ALLES_OK_GPIO_PORT,RESET_LOGIC_ALLES_OK_PIN,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 HAL_Delay(1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 HAL_GPIO_WritePin(RESET_LOGIC_ALLES_OK_GPIO_PORT,RESET_LOGIC_ALLES_OK_PIN,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 #ifndef BOOTLOADER_STANDALONE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 if(huart == &UartIR_HUD_Handle)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 tCCR_restart();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 #endif