Rev 59 | Rev 61 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 59 | Rev 60 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | 50 | ||
51 | TIM_HandleTypeDef htim2; |
51 | TIM_HandleTypeDef htim2; |
52 | TIM_HandleTypeDef htim3; |
52 | TIM_HandleTypeDef htim3; |
53 | TIM_HandleTypeDef htim9; |
53 | TIM_HandleTypeDef htim9; |
54 | 54 | ||
- | 55 | UART_HandleTypeDef huart4; |
|
55 | UART_HandleTypeDef huart1; |
56 | UART_HandleTypeDef huart1; |
56 | UART_HandleTypeDef huart2; |
57 | UART_HandleTypeDef huart2; |
57 | UART_HandleTypeDef huart3; |
58 | UART_HandleTypeDef huart3; |
58 | 59 | ||
59 | /* USER CODE BEGIN PV */ |
60 | /* USER CODE BEGIN PV */ |
Line 92... | Line 93... | ||
92 | static void MX_USART2_UART_Init(void); |
93 | static void MX_USART2_UART_Init(void); |
93 | static void MX_USART3_UART_Init(void); |
94 | static void MX_USART3_UART_Init(void); |
94 | static void MX_TIM3_Init(void); |
95 | static void MX_TIM3_Init(void); |
95 | static void MX_TIM9_Init(void); |
96 | static void MX_TIM9_Init(void); |
96 | static void MX_TIM2_Init(void); |
97 | static void MX_TIM2_Init(void); |
- | 98 | static void MX_UART4_Init(void); |
|
97 | /* USER CODE BEGIN PFP */ |
99 | /* USER CODE BEGIN PFP */ |
98 | 100 | ||
99 | // the dial is the switch number we are using. |
101 | // the dial is the switch number we are using. |
100 | // suppress is the ItemIndex we wish to suppress on this display |
102 | // suppress is the ItemIndex we wish to suppress on this display |
101 | int |
- | |
102 | DisplayCurrent (int dial, int suppress) |
103 | int DisplayCurrent(int dial, int suppress) |
103 | { |
104 | { |
104 | if (contexts[dial].knobPos < 0) |
105 | if (contexts[dial].knobPos < 0) |
105 | return -1; |
106 | return -1; |
106 | return cc_display (dial, suppress); |
107 | return cc_display(dial, suppress); |
107 | } |
108 | } |
108 | 109 | ||
109 | - | ||
110 | void |
- | |
111 | sendString (usart_ctl *ctl, char *string, int length) |
110 | void sendString(usart_ctl *ctl, char *string, int length) |
112 | { |
111 | { |
113 | int i; |
112 | int i; |
114 | for (i = 0; i < length; i++) |
113 | for (i = 0; i < length; i++) |
115 | PutCharSerial (ctl, string[i]); |
114 | PutCharSerial(ctl, string[i]); |
116 | - | ||
117 | } |
115 | } |
118 | 116 | ||
119 | /// \note this code doesnt work so it leaves speed as 9600. |
117 | /// \note this code doesnt work so it leaves speed as 9600. |
120 | /// \brief Setup Bluetooth module |
118 | /// \brief Setup Bluetooth module |
121 | void |
- | |
122 | initModule (usart_ctl *ctl, uint32_t baudRate) |
119 | void initModule(usart_ctl *ctl, uint32_t baudRate) |
123 | { |
120 | { |
124 | char initBuf[30]; |
121 | char initBuf[30]; |
125 | // switch to command mode |
122 | // switch to command mode |
126 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
123 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
127 | HAL_Delay (500); |
124 | HAL_Delay(500); |
128 | int initLen = small_sprintf (initBuf, "AT+UART=%ul,1,2\n", baudRate); |
125 | int initLen = small_sprintf(initBuf, "AT+UART=%ul,1,2\n", baudRate); |
129 | setBaud (ctl, 38400); |
126 | setBaud(ctl, 38400); |
130 | sendString (ctl, initBuf, initLen); |
127 | sendString(ctl, initBuf, initLen); |
131 | TxWaitEmpty (ctl); |
128 | TxWaitEmpty(ctl); |
132 | // switch back to normal comms at new baud rate |
129 | // switch back to normal comms at new baud rate |
133 | 130 | ||
134 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_SET); |
131 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_SET); |
135 | setBaud (ctl, baudRate); |
132 | setBaud(ctl, baudRate); |
136 | HAL_Delay (100); |
133 | HAL_Delay(100); |
- | 134 | } |
|
- | 135 | ||
- | 136 | // workspace for RMC data read from GPS module. |
|
- | 137 | uint8_t rmc_buff[80]; |
|
- | 138 | uint16_t rmc_length; |
|
137 | 139 | ||
- | 140 | uint8_t rmc_callback(uint8_t *data, uint16_t length) |
|
- | 141 | { |
|
- | 142 | rmc_length = length; |
|
- | 143 | memcpy(rmc_buff, data, length); |
|
138 | } |
144 | } |
139 | 145 | ||
140 | /* USER CODE END PFP */ |
146 | /* USER CODE END PFP */ |
141 | 147 | ||
142 | /* Private user code ---------------------------------------------------------*/ |
148 | /* Private user code ---------------------------------------------------------*/ |
143 | /* USER CODE BEGIN 0 */ |
149 | /* USER CODE BEGIN 0 */ |
144 | 150 | ||
145 | /* USER CODE END 0 */ |
151 | /* USER CODE END 0 */ |
146 | 152 | ||
147 | /** |
153 | /** |
148 | * @brief The application entry point. |
154 | * @brief The application entry point. |
149 | * @retval int |
155 | * @retval int |
150 | */ |
156 | */ |
151 | int main(void) |
157 | int main(void) |
152 | { |
158 | { |
153 | /* USER CODE BEGIN 1 */ |
159 | /* USER CODE BEGIN 1 */ |
154 | __HAL_RCC_SPI1_CLK_ENABLE() |
160 | __HAL_RCC_SPI1_CLK_ENABLE(); |
155 | ; |
- | |
156 | __HAL_RCC_USART1_CLK_ENABLE() |
161 | __HAL_RCC_USART1_CLK_ENABLE(); // PLX main port |
157 | ; // PLX main port |
- | |
158 | __HAL_RCC_USART2_CLK_ENABLE() |
162 | __HAL_RCC_USART2_CLK_ENABLE(); // debug port |
159 | ; // debug port |
- | |
160 | __HAL_RCC_USART3_CLK_ENABLE () |
163 | __HAL_RCC_USART3_CLK_ENABLE(); // Bluetooth port |
161 | ; // Bluetooth port |
164 | __HAL_RCC_UART4_CLK_ENABLE(); // NMEA0183 port |
162 | 165 | ||
163 | __HAL_RCC_TIM3_CLK_ENABLE(); |
166 | __HAL_RCC_TIM3_CLK_ENABLE(); |
164 | 167 | ||
165 | __HAL_RCC_TIM9_CLK_ENABLE(); |
168 | __HAL_RCC_TIM9_CLK_ENABLE(); |
166 | 169 | ||
Line 178... | Line 181... | ||
178 | /* Configure the system clock */ |
181 | /* Configure the system clock */ |
179 | SystemClock_Config(); |
182 | SystemClock_Config(); |
180 | 183 | ||
181 | /* USER CODE BEGIN SysInit */ |
184 | /* USER CODE BEGIN SysInit */ |
182 | // Switch handler called on sysTick interrupt. |
185 | // Switch handler called on sysTick interrupt. |
183 | InitSwitches (); |
186 | InitSwitches(); |
184 | 187 | ||
185 | /* USER CODE END SysInit */ |
188 | /* USER CODE END SysInit */ |
186 | 189 | ||
187 | /* Initialize all configured peripherals */ |
190 | /* Initialize all configured peripherals */ |
188 | MX_GPIO_Init(); |
191 | MX_GPIO_Init(); |
Line 191... | Line 194... | ||
191 | MX_USART2_UART_Init(); |
194 | MX_USART2_UART_Init(); |
192 | MX_USART3_UART_Init(); |
195 | MX_USART3_UART_Init(); |
193 | MX_TIM3_Init(); |
196 | MX_TIM3_Init(); |
194 | MX_TIM9_Init(); |
197 | MX_TIM9_Init(); |
195 | MX_TIM2_Init(); |
198 | MX_TIM2_Init(); |
- | 199 | MX_UART4_Init(); |
|
196 | /* USER CODE BEGIN 2 */ |
200 | /* USER CODE BEGIN 2 */ |
197 | 201 | ||
198 | /* Turn on USART1 IRQ */ |
202 | /* Turn on USART1 IRQ */ |
199 | HAL_NVIC_SetPriority (USART1_IRQn, 2, 0); |
203 | HAL_NVIC_SetPriority(USART1_IRQn, 2, 0); |
200 | HAL_NVIC_EnableIRQ (USART1_IRQn); |
204 | HAL_NVIC_EnableIRQ(USART1_IRQn); |
201 | 205 | ||
202 | /* Turn on USART2 IRQ */ |
206 | /* Turn on USART2 IRQ */ |
203 | HAL_NVIC_SetPriority (USART2_IRQn, 4, 0); |
207 | HAL_NVIC_SetPriority(USART2_IRQn, 4, 0); |
204 | HAL_NVIC_EnableIRQ (USART2_IRQn); |
208 | HAL_NVIC_EnableIRQ(USART2_IRQn); |
205 | 209 | ||
206 | /* turn on USART3 IRQ */ |
210 | /* turn on USART3 IRQ */ |
207 | HAL_NVIC_SetPriority (USART3_IRQn, 4, 0); |
211 | HAL_NVIC_SetPriority(USART3_IRQn, 4, 0); |
208 | HAL_NVIC_EnableIRQ (USART3_IRQn); |
212 | HAL_NVIC_EnableIRQ(USART3_IRQn); |
209 | 213 | ||
210 | /* setup the USART control blocks */ |
214 | /* turn on UART4 IRQ */ |
211 | init_usart_ctl (&uc1, &huart1); |
215 | HAL_NVIC_SetPriority(UART4_IRQn, 4, 0); |
212 | init_usart_ctl (&uc2, &huart2); |
- | |
213 | init_usart_ctl (&uc3, &huart3); |
216 | HAL_NVIC_EnableIRQ(UART4_IRQn); |
214 | 217 | ||
- | 218 | /* setup the USART control blocks */ |
|
215 | EnableSerialRxInterrupt (&uc1); |
219 | init_usart_ctl(&uc1, &huart1); |
216 | EnableSerialRxInterrupt (&uc2); |
220 | init_usart_ctl(&uc2, &huart2); |
217 | EnableSerialRxInterrupt (&uc3); |
221 | init_usart_ctl(&uc3, &huart3); |
- | 222 | init_usart_ctl(&uc4, &huart4); |
|
218 | 223 | ||
- | 224 | EnableSerialRxInterrupt(&uc1); |
|
- | 225 | EnableSerialRxInterrupt(&uc2); |
|
- | 226 | EnableSerialRxInterrupt(&uc3); |
|
219 | HAL_TIM_Encoder_Start (&htim3, TIM_CHANNEL_ALL); |
227 | EnableSerialRxInterrupt(&uc4); |
220 | 228 | ||
221 | HAL_TIM_Encoder_Start (&htim9, TIM_CHANNEL_ALL); |
229 | HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL); |
222 | 230 | ||
- | 231 | HAL_TIM_Encoder_Start(&htim9, TIM_CHANNEL_ALL); |
|
223 | 232 | ||
224 | initModule (&uc3, 9600); |
233 | initModule(&uc3, 9600); |
225 | 234 | ||
226 | // Initialise UART for 4800 baud NMEA |
235 | // Initialise UART for 4800 baud NMEA |
227 | setBaud (&uc2, 4800); |
236 | setBaud(&uc2, 4800); |
- | 237 | ||
- | 238 | // Initialuse UART4 for 4800 baud NMEA. |
|
- | 239 | setBaud(&uc4, 4800); |
|
228 | 240 | ||
229 | cc_init (); |
241 | cc_init(); |
230 | 242 | ||
231 | int i; |
243 | int i; |
232 | for (i = 0; i < 2; i++) |
244 | for (i = 0; i < 2; i++) |
233 | { |
245 | { |
234 | dial_pos[i] = 0; // default to items 0 and 1 |
246 | dial_pos[i] = 0; // default to items 0 and 1 |
235 | contexts[i].knobPos = -1; |
247 | contexts[i].knobPos = -1; |
236 | } |
248 | } |
237 | 249 | ||
238 | /* reset the display timeout, latch on power from accessories */ |
250 | /* reset the display timeout, latch on power from accessories */ |
239 | Latch_Timer = IGNITION_OFF_TIMEOUT; |
251 | Latch_Timer = IGNITION_OFF_TIMEOUT; |
240 | HAL_GPIO_WritePin (POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET); |
252 | HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET); |
- | 253 | ||
- | 254 | setRmcCallback(&rmc_callback); |
|
241 | 255 | ||
242 | /* USER CODE END 2 */ |
256 | /* USER CODE END 2 */ |
243 | 257 | ||
244 | /* Infinite loop */ |
258 | /* Infinite loop */ |
245 | /* USER CODE BEGIN WHILE */ |
259 | /* USER CODE BEGIN WHILE */ |
246 | while (1) |
260 | while (1) |
- | 261 | { |
|
- | 262 | ||
- | 263 | /* while ignition is on, keep resetting power latch timer */ |
|
- | 264 | if (HAL_GPIO_ReadPin(IGNITION_GPIO_Port, IGNITION_Pin) == GPIO_PIN_RESET) |
|
247 | { |
265 | { |
- | 266 | Latch_Timer = HAL_GetTick() + IGNITION_OFF_TIMEOUT; |
|
- | 267 | } |
|
- | 268 | else |
|
- | 269 | { |
|
- | 270 | /* if the ignition has been off for a while, then turn off power */ |
|
- | 271 | if (HAL_GetTick() > Latch_Timer) |
|
- | 272 | { |
|
- | 273 | HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, |
|
- | 274 | GPIO_PIN_RESET); |
|
- | 275 | } |
|
- | 276 | } |
|
- | 277 | ||
- | 278 | uint32_t timeout = 0; // |
|
- | 279 | ||
- | 280 | uint32_t nextTick = HAL_GetTick() + LOGGER_INTERVAL; |
|
- | 281 | uint8_t log = 0; |
|
- | 282 | // PLX decoder protocols |
|
- | 283 | char PLXPacket = 0; |
|
- | 284 | for (i = 0; i < MAXRDG; i++) |
|
- | 285 | { |
|
- | 286 | Info[i].Max = 0; |
|
- | 287 | Info[i].Min = 0xFFF; // 12 bit max value |
|
- | 288 | } |
|
248 | 289 | ||
- | 290 | int PLXPtr = 0; |
|
249 | 291 | ||
- | 292 | while (1) |
|
- | 293 | { |
|
250 | 294 | ||
- | 295 | // poll GPS Position/time on UART4 |
|
251 | bool stat = updateLocation (&loc, &uc2); |
296 | bool stat = updateLocation(&loc, &uc4); |
252 | if (loc.good) |
297 | if (loc.good) |
253 | { |
298 | { |
254 | 299 | ||
255 | loc.good = false; |
300 | loc.good = false; |
256 | } |
301 | } |
257 | if (loc.valid == 'V') |
302 | if (loc.valid == 'V') |
258 | memset (loc.time, '-', 6); |
303 | memset(loc.time, '-', 6); |
259 | 304 | ||
- | 305 | // Handle the bluetooth pairing / reset function by pressing both buttons. |
|
- | 306 | if ((push_pos[0] == 1) && (push_pos[1] == 1)) |
|
- | 307 | { |
|
- | 308 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
|
- | 309 | GPIO_PIN_RESET); |
|
- | 310 | } |
|
- | 311 | else |
|
- | 312 | { |
|
- | 313 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
|
- | 314 | GPIO_PIN_SET); |
|
- | 315 | } |
|
- | 316 | ||
- | 317 | uint16_t cc = SerialCharsReceived(&uc1); |
|
- | 318 | int chr; |
|
- | 319 | if (cc == 0) |
|
- | 320 | { |
|
- | 321 | timeout++; |
|
- | 322 | if (timeout % 1000 == 0) |
|
- | 323 | { |
|
- | 324 | const char msg[] = "Timeout\r\n"; |
|
- | 325 | sendString(&uc3, msg, sizeof(msg)); |
|
- | 326 | } |
|
260 | 327 | ||
- | 328 | if (timeout > 60000) |
|
- | 329 | { |
|
261 | 330 | ||
- | 331 | // do turn off screen |
|
- | 332 | } |
|
- | 333 | } |
|
- | 334 | for (chr = 0; chr < cc; chr++) |
|
- | 335 | { |
|
- | 336 | char c = GetCharSerial(&uc1); |
|
262 | 337 | ||
- | 338 | if (c == PLX_Start) // at any time if the start byte appears, reset the pointers |
|
- | 339 | { |
|
- | 340 | PLXPtr = 0; // reset the pointer |
|
- | 341 | PLXPacket = 1; |
|
- | 342 | timeout = 0; // Reset the timer |
|
- | 343 | if (HAL_GetTick() > nextTick) |
|
- | 344 | { |
|
- | 345 | nextTick = HAL_GetTick() + LOGGER_INTERVAL; |
|
- | 346 | log = 1; |
|
- | 347 | } |
|
- | 348 | else |
|
- | 349 | log = 0; |
|
- | 350 | } |
|
- | 351 | else if (c == PLX_Stop) |
|
- | 352 | { |
|
- | 353 | if (PLXPacket) |
|
- | 354 | { |
|
- | 355 | // we can now decode the selected parameter |
|
- | 356 | PLXItems = PLXPtr / sizeof(PLX_SensorInfo); // total |
|
- | 357 | // saturate the rotary switch position |
|
- | 358 | ||
- | 359 | // process min/max |
|
- | 360 | for (i = 0; i < PLXItems; i++) |
|
- | 361 | { |
|
- | 362 | Info[i].observation = ConvPLX(Data.Sensor[i].AddrH, |
|
- | 363 | Data.Sensor[i].AddrL); |
|
- | 364 | Info[i].instance = Data.Sensor[i].Instance; |
|
- | 365 | Info[i].data = ConvPLX(Data.Sensor[i].ReadingH, |
|
- | 366 | Data.Sensor[i].ReadingL); |
|
- | 367 | if (Info[i].data > Info[i].Max) |
|
- | 368 | { |
|
- | 369 | Info[i].Max = Info[i].data; |
|
- | 370 | } |
|
- | 371 | if (Info[i].data < Info[i].Min) |
|
- | 372 | { |
|
- | 373 | Info[i].Min = Info[i].data; |
|
- | 374 | } |
|
- | 375 | ||
- | 376 | // Send item to BT |
|
- | 377 | if (rmc_length) |
|
- | 378 | { |
|
- | 379 | sendString(&uc3, rmc_buff, rmc_length); |
|
- | 380 | rmc_length = 0; |
|
- | 381 | } |
|
- | 382 | ||
- | 383 | if (log) |
|
- | 384 | { |
|
- | 385 | ||
- | 386 | char outbuff[100]; |
|
- | 387 | ||
- | 388 | int cnt = small_sprintf(outbuff, |
|
- | 389 | "$PLLOG,%d,%d,%d", |
|
- | 390 | Info[i].observation, |
|
- | 391 | Info[i].instance, |
|
- | 392 | Info[i].data); |
|
- | 393 | ||
- | 394 | // NMEA style checksum |
|
- | 395 | int ck; |
|
- | 396 | int sum = 0; |
|
- | 397 | for (ck = 1; ck < cnt; ck++) |
|
- | 398 | sum += outbuff[ck]; |
|
- | 399 | cnt += small_sprintf(outbuff + cnt, "*%02X\n", |
|
- | 400 | sum & 0xFF); |
|
- | 401 | sendString(&uc3, outbuff, cnt); |
|
- | 402 | } |
|
- | 403 | } |
|
- | 404 | ||
- | 405 | // now to display the information |
|
- | 406 | int suppress = DisplayCurrent(0, -1); |
|
- | 407 | DisplayCurrent(1, suppress); |
|
- | 408 | } |
|
- | 409 | PLXPtr = 0; |
|
- | 410 | PLXPacket = 0; |
|
- | 411 | } |
|
- | 412 | else if (c > PLX_Stop) // illegal char, restart reading |
|
- | 413 | { |
|
- | 414 | PLXPacket = 0; |
|
- | 415 | PLXPtr = 0; |
|
- | 416 | } |
|
- | 417 | else if (PLXPacket && PLXPtr < sizeof(Data.Bytes)) |
|
- | 418 | { |
|
- | 419 | Data.Bytes[PLXPtr++] = c; |
|
- | 420 | } |
|
- | 421 | } |
|
263 | 422 | ||
264 | /* while ignition is on, keep resetting power latch timer */ |
- | |
265 | if (HAL_GPIO_ReadPin (IGNITION_GPIO_Port, IGNITION_Pin) == GPIO_PIN_RESET) |
- | |
266 | { |
- | |
267 | Latch_Timer = HAL_GetTick () + IGNITION_OFF_TIMEOUT; |
- | |
268 | } |
- | |
269 | else |
- | |
270 | { |
- | |
271 | /* if the ignition has been off for a while, then turn off power */ |
- | |
272 | if (HAL_GetTick () > Latch_Timer) |
- | |
273 | { |
- | |
274 | HAL_GPIO_WritePin (POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, |
- | |
275 | GPIO_PIN_RESET); |
- | |
276 | } |
- | |
277 | } |
- | |
278 | - | ||
279 | uint32_t timeout = 0; // |
- | |
280 | - | ||
281 | uint32_t nextTick = HAL_GetTick () + LOGGER_INTERVAL; |
- | |
282 | uint8_t log = 0; |
- | |
283 | // PLX decoder protocols |
- | |
284 | char PLXPacket = 0; |
- | |
285 | for (i = 0; i < MAXRDG; i++) |
- | |
286 | { |
- | |
287 | Info[i].Max = 0; |
- | |
288 | Info[i].Min = 0xFFF; // 12 bit max value |
- | |
289 | } |
- | |
290 | - | ||
291 | int PLXPtr = 0; |
- | |
292 | - | ||
293 | while (1) |
- | |
294 | { |
- | |
295 | // Handle the bluetooth pairing / reset function by pressing both buttons. |
- | |
296 | if ((push_pos[0] == 1) && (push_pos[1] == 1)) |
- | |
297 | { |
- | |
298 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
- | |
299 | GPIO_PIN_RESET); |
- | |
300 | } |
- | |
301 | else |
- | |
302 | { |
- | |
303 | HAL_GPIO_WritePin (BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
- | |
304 | GPIO_PIN_SET); |
- | |
305 | } |
- | |
306 | - | ||
307 | uint16_t cc = SerialCharsReceived (&uc1); |
- | |
308 | int chr; |
- | |
309 | if (cc == 0) |
- | |
310 | { |
- | |
311 | timeout++; |
- | |
312 | if (timeout % 1000 == 0) |
- | |
313 | { |
- | |
314 | const char msg[] = "Timeout\r\n"; |
- | |
315 | sendString (&uc3, msg, sizeof(msg)); |
- | |
316 | - | ||
317 | } |
- | |
318 | - | ||
319 | if (timeout > 60000) |
- | |
320 | { |
- | |
321 | - | ||
322 | // do turn off screen |
- | |
323 | } |
- | |
324 | - | ||
325 | } |
- | |
326 | for (chr = 0; chr < cc; chr++) |
- | |
327 | { |
- | |
328 | char c = GetCharSerial (&uc1); |
- | |
329 | - | ||
330 | if (c == PLX_Start) // at any time if the start byte appears, reset the pointers |
- | |
331 | { |
- | |
332 | PLXPtr = 0; // reset the pointer |
- | |
333 | PLXPacket = 1; |
- | |
334 | timeout = 0; // Reset the timer |
- | |
335 | if (HAL_GetTick () > nextTick) |
- | |
336 | { |
- | |
337 | nextTick = HAL_GetTick () + LOGGER_INTERVAL; |
- | |
338 | log = 1; |
- | |
339 | } |
- | |
340 | else |
- | |
341 | log = 0; |
- | |
342 | } |
- | |
343 | else if (c == PLX_Stop) |
- | |
344 | { |
- | |
345 | if (PLXPacket) |
- | |
346 | { |
- | |
347 | // we can now decode the selected parameter |
- | |
348 | PLXItems = PLXPtr / sizeof(PLX_SensorInfo); // total |
- | |
349 | // saturate the rotary switch position |
- | |
350 | - | ||
351 | // process min/max |
- | |
352 | for (i = 0; i < PLXItems; i++) |
- | |
353 | { |
- | |
354 | Info[i].observation = ConvPLX (Data.Sensor[i].AddrH, |
- | |
355 | Data.Sensor[i].AddrL); |
- | |
356 | Info[i].instance = Data.Sensor[i].Instance; |
- | |
357 | Info[i].data = ConvPLX (Data.Sensor[i].ReadingH, |
- | |
358 | Data.Sensor[i].ReadingL); |
- | |
359 | if (Info[i].data > Info[i].Max) |
- | |
360 | { |
- | |
361 | Info[i].Max = Info[i].data; |
- | |
362 | } |
- | |
363 | if (Info[i].data < Info[i].Min) |
- | |
364 | { |
- | |
365 | Info[i].Min = Info[i].data; |
- | |
366 | } |
- | |
367 | - | ||
368 | // Send item to BT |
- | |
369 | - | ||
370 | if (log) |
- | |
371 | { |
- | |
372 | - | ||
373 | char outbuff[100]; |
- | |
374 | - | ||
375 | int cnt = small_sprintf (outbuff, |
- | |
376 | "$PLLOG,%d,%d,%d", |
- | |
377 | Info[i].observation, |
- | |
378 | Info[i].instance, |
- | |
379 | Info[i].data); |
- | |
380 | - | ||
381 | //checksum |
- | |
382 | int ck; |
- | |
383 | int sum = 0; |
- | |
384 | for (ck = 1; ck < cnt; ck++) |
- | |
385 | sum += outbuff[ck]; |
- | |
386 | cnt += small_sprintf (outbuff + cnt, "*%02X\n", |
- | |
387 | sum & 0xFF); |
- | |
388 | sendString (&uc3, outbuff, cnt); |
- | |
389 | - | ||
390 | } |
- | |
391 | } |
- | |
392 | - | ||
393 | // now to display the information |
- | |
394 | int suppress = DisplayCurrent (0, -1); |
- | |
395 | DisplayCurrent (1, suppress); |
- | |
396 | } |
- | |
397 | PLXPtr = 0; |
- | |
398 | PLXPacket = 0; |
- | |
399 | } |
- | |
400 | else if (c > PLX_Stop) // illegal char, restart reading |
- | |
401 | { |
- | |
402 | PLXPacket = 0; |
- | |
403 | PLXPtr = 0; |
- | |
404 | } |
- | |
405 | else if (PLXPacket && PLXPtr < sizeof(Data.Bytes)) |
- | |
406 | { |
- | |
407 | Data.Bytes[PLXPtr++] = c; |
- | |
408 | } |
- | |
409 | - | ||
410 | } |
- | |
411 | - | ||
412 | HAL_Delay (1); |
423 | HAL_Delay(1); |
413 | 424 | ||
414 | for (i = 0; i < MAX_DISPLAYS; i++) |
425 | for (i = 0; i < MAX_DISPLAYS; i++) |
415 | { |
426 | { |
416 | if (dial_pos[i] < 0) |
427 | if (dial_pos[i] < 0) |
417 | dial_pos[i] = PLXItems - 1; |
428 | dial_pos[i] = PLXItems - 1; |
418 | if (dial_pos[i] >= PLXItems) |
429 | if (dial_pos[i] >= PLXItems) |
419 | dial_pos[i] = 0; |
430 | dial_pos[i] = 0; |
420 | 431 | ||
421 | int prevPos = contexts[i].knobPos; |
432 | int prevPos = contexts[i].knobPos; |
422 | if (contexts[i].knobPos >= 0) |
433 | if (contexts[i].knobPos >= 0) |
423 | contexts[i].knobPos = dial_pos[i]; |
434 | contexts[i].knobPos = dial_pos[i]; |
424 | // if the dial position was changed then reset timer |
435 | // if the dial position was changed then reset timer |
425 | if (prevPos != contexts[i].knobPos) |
436 | if (prevPos != contexts[i].knobPos) |
426 | contexts[i].dial_timer = DialTimeout; |
437 | contexts[i].dial_timer = DialTimeout; |
427 | 438 | ||
428 | cc_check_nvram (i); |
439 | cc_check_nvram(i); |
429 | if (contexts[i].knobPos >= 0) |
440 | if (contexts[i].knobPos >= 0) |
430 | dial_pos[i] = contexts[i].knobPos; |
441 | dial_pos[i] = contexts[i].knobPos; |
431 | } |
442 | } |
432 | } |
443 | } |
433 | /* USER CODE END WHILE */ |
444 | /* USER CODE END WHILE */ |
434 | 445 | ||
435 | /* USER CODE BEGIN 3 */ |
446 | /* USER CODE BEGIN 3 */ |
436 | } |
447 | } |
437 | /* USER CODE END 3 */ |
448 | /* USER CODE END 3 */ |
438 | } |
449 | } |
439 | 450 | ||
440 | /** |
451 | /** |
441 | * @brief System Clock Configuration |
452 | * @brief System Clock Configuration |
442 | * @retval None |
453 | * @retval None |
443 | */ |
454 | */ |
444 | void SystemClock_Config(void) |
455 | void SystemClock_Config(void) |
445 | { |
456 | { |
446 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
457 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
447 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
458 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
448 | 459 | ||
449 | /** Configure the main internal regulator output voltage |
460 | /** Configure the main internal regulator output voltage |
450 | */ |
461 | */ |
451 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
462 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
452 | /** Initializes the RCC Oscillators according to the specified parameters |
463 | /** Initializes the RCC Oscillators according to the specified parameters |
453 | * in the RCC_OscInitTypeDef structure. |
464 | * in the RCC_OscInitTypeDef structure. |
454 | */ |
465 | */ |
455 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
466 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
456 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
467 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
457 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
468 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
458 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
469 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
459 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
470 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
Line 461... | Line 472... | ||
461 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
472 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
462 | { |
473 | { |
463 | Error_Handler(); |
474 | Error_Handler(); |
464 | } |
475 | } |
465 | /** Initializes the CPU, AHB and APB buses clocks |
476 | /** Initializes the CPU, AHB and APB buses clocks |
466 | */ |
477 | */ |
467 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
478 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
468 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
- | |
469 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
479 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
470 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
480 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
471 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
481 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
472 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
482 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
473 | 483 | ||
Line 476... | Line 486... | ||
476 | Error_Handler(); |
486 | Error_Handler(); |
477 | } |
487 | } |
478 | } |
488 | } |
479 | 489 | ||
480 | /** |
490 | /** |
481 | * @brief SPI1 Initialization Function |
491 | * @brief SPI1 Initialization Function |
482 | * @param None |
492 | * @param None |
483 | * @retval None |
493 | * @retval None |
484 | */ |
494 | */ |
485 | static void MX_SPI1_Init(void) |
495 | static void MX_SPI1_Init(void) |
486 | { |
496 | { |
487 | 497 | ||
488 | /* USER CODE BEGIN SPI1_Init 0 */ |
498 | /* USER CODE BEGIN SPI1_Init 0 */ |
489 | 499 | ||
Line 510... | Line 520... | ||
510 | Error_Handler(); |
520 | Error_Handler(); |
511 | } |
521 | } |
512 | /* USER CODE BEGIN SPI1_Init 2 */ |
522 | /* USER CODE BEGIN SPI1_Init 2 */ |
513 | 523 | ||
514 | /* USER CODE END SPI1_Init 2 */ |
524 | /* USER CODE END SPI1_Init 2 */ |
515 | - | ||
516 | } |
525 | } |
517 | 526 | ||
518 | /** |
527 | /** |
519 | * @brief TIM2 Initialization Function |
528 | * @brief TIM2 Initialization Function |
520 | * @param None |
529 | * @param None |
521 | * @retval None |
530 | * @retval None |
522 | */ |
531 | */ |
523 | static void MX_TIM2_Init(void) |
532 | static void MX_TIM2_Init(void) |
524 | { |
533 | { |
525 | 534 | ||
526 | /* USER CODE BEGIN TIM2_Init 0 */ |
535 | /* USER CODE BEGIN TIM2_Init 0 */ |
527 | 536 | ||
Line 555... | Line 564... | ||
555 | Error_Handler(); |
564 | Error_Handler(); |
556 | } |
565 | } |
557 | /* USER CODE BEGIN TIM2_Init 2 */ |
566 | /* USER CODE BEGIN TIM2_Init 2 */ |
558 | 567 | ||
559 | /* USER CODE END TIM2_Init 2 */ |
568 | /* USER CODE END TIM2_Init 2 */ |
560 | - | ||
561 | } |
569 | } |
562 | 570 | ||
563 | /** |
571 | /** |
564 | * @brief TIM3 Initialization Function |
572 | * @brief TIM3 Initialization Function |
565 | * @param None |
573 | * @param None |
566 | * @retval None |
574 | * @retval None |
567 | */ |
575 | */ |
568 | static void MX_TIM3_Init(void) |
576 | static void MX_TIM3_Init(void) |
569 | { |
577 | { |
570 | 578 | ||
571 | /* USER CODE BEGIN TIM3_Init 0 */ |
579 | /* USER CODE BEGIN TIM3_Init 0 */ |
572 | 580 | ||
Line 604... | Line 612... | ||
604 | Error_Handler(); |
612 | Error_Handler(); |
605 | } |
613 | } |
606 | /* USER CODE BEGIN TIM3_Init 2 */ |
614 | /* USER CODE BEGIN TIM3_Init 2 */ |
607 | 615 | ||
608 | /* USER CODE END TIM3_Init 2 */ |
616 | /* USER CODE END TIM3_Init 2 */ |
609 | - | ||
610 | } |
617 | } |
611 | 618 | ||
612 | /** |
619 | /** |
613 | * @brief TIM9 Initialization Function |
620 | * @brief TIM9 Initialization Function |
614 | * @param None |
621 | * @param None |
615 | * @retval None |
622 | * @retval None |
616 | */ |
623 | */ |
617 | static void MX_TIM9_Init(void) |
624 | static void MX_TIM9_Init(void) |
618 | { |
625 | { |
619 | 626 | ||
620 | /* USER CODE BEGIN TIM9_Init 0 */ |
627 | /* USER CODE BEGIN TIM9_Init 0 */ |
621 | 628 | ||
Line 653... | Line 660... | ||
653 | Error_Handler(); |
660 | Error_Handler(); |
654 | } |
661 | } |
655 | /* USER CODE BEGIN TIM9_Init 2 */ |
662 | /* USER CODE BEGIN TIM9_Init 2 */ |
656 | 663 | ||
657 | /* USER CODE END TIM9_Init 2 */ |
664 | /* USER CODE END TIM9_Init 2 */ |
- | 665 | } |
|
- | 666 | ||
- | 667 | /** |
|
- | 668 | * @brief UART4 Initialization Function |
|
- | 669 | * @param None |
|
- | 670 | * @retval None |
|
- | 671 | */ |
|
- | 672 | static void MX_UART4_Init(void) |
|
- | 673 | { |
|
658 | 674 | ||
- | 675 | /* USER CODE BEGIN UART4_Init 0 */ |
|
- | 676 | ||
- | 677 | /* USER CODE END UART4_Init 0 */ |
|
- | 678 | ||
- | 679 | /* USER CODE BEGIN UART4_Init 1 */ |
|
- | 680 | ||
- | 681 | /* USER CODE END UART4_Init 1 */ |
|
- | 682 | huart4.Instance = UART4; |
|
- | 683 | huart4.Init.BaudRate = 4800; |
|
- | 684 | huart4.Init.WordLength = UART_WORDLENGTH_8B; |
|
- | 685 | huart4.Init.StopBits = UART_STOPBITS_1; |
|
- | 686 | huart4.Init.Parity = UART_PARITY_NONE; |
|
- | 687 | huart4.Init.Mode = UART_MODE_TX_RX; |
|
- | 688 | huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE; |
|
- | 689 | huart4.Init.OverSampling = UART_OVERSAMPLING_16; |
|
- | 690 | if (HAL_UART_Init(&huart4) != HAL_OK) |
|
- | 691 | { |
|
- | 692 | Error_Handler(); |
|
- | 693 | } |
|
- | 694 | /* USER CODE BEGIN UART4_Init 2 */ |
|
- | 695 | ||
- | 696 | /* USER CODE END UART4_Init 2 */ |
|
659 | } |
697 | } |
660 | 698 | ||
661 | /** |
699 | /** |
662 | * @brief USART1 Initialization Function |
700 | * @brief USART1 Initialization Function |
663 | * @param None |
701 | * @param None |
664 | * @retval None |
702 | * @retval None |
665 | */ |
703 | */ |
666 | static void MX_USART1_UART_Init(void) |
704 | static void MX_USART1_UART_Init(void) |
667 | { |
705 | { |
668 | 706 | ||
669 | /* USER CODE BEGIN USART1_Init 0 */ |
707 | /* USER CODE BEGIN USART1_Init 0 */ |
670 | 708 | ||
Line 686... | Line 724... | ||
686 | Error_Handler(); |
724 | Error_Handler(); |
687 | } |
725 | } |
688 | /* USER CODE BEGIN USART1_Init 2 */ |
726 | /* USER CODE BEGIN USART1_Init 2 */ |
689 | 727 | ||
690 | /* USER CODE END USART1_Init 2 */ |
728 | /* USER CODE END USART1_Init 2 */ |
691 | - | ||
692 | } |
729 | } |
693 | 730 | ||
694 | /** |
731 | /** |
695 | * @brief USART2 Initialization Function |
732 | * @brief USART2 Initialization Function |
696 | * @param None |
733 | * @param None |
697 | * @retval None |
734 | * @retval None |
698 | */ |
735 | */ |
699 | static void MX_USART2_UART_Init(void) |
736 | static void MX_USART2_UART_Init(void) |
700 | { |
737 | { |
701 | 738 | ||
702 | /* USER CODE BEGIN USART2_Init 0 */ |
739 | /* USER CODE BEGIN USART2_Init 0 */ |
703 | 740 | ||
Line 719... | Line 756... | ||
719 | Error_Handler(); |
756 | Error_Handler(); |
720 | } |
757 | } |
721 | /* USER CODE BEGIN USART2_Init 2 */ |
758 | /* USER CODE BEGIN USART2_Init 2 */ |
722 | 759 | ||
723 | /* USER CODE END USART2_Init 2 */ |
760 | /* USER CODE END USART2_Init 2 */ |
724 | - | ||
725 | } |
761 | } |
726 | 762 | ||
727 | /** |
763 | /** |
728 | * @brief USART3 Initialization Function |
764 | * @brief USART3 Initialization Function |
729 | * @param None |
765 | * @param None |
730 | * @retval None |
766 | * @retval None |
731 | */ |
767 | */ |
732 | static void MX_USART3_UART_Init(void) |
768 | static void MX_USART3_UART_Init(void) |
733 | { |
769 | { |
734 | 770 | ||
735 | /* USER CODE BEGIN USART3_Init 0 */ |
771 | /* USER CODE BEGIN USART3_Init 0 */ |
736 | 772 | ||
Line 752... | Line 788... | ||
752 | Error_Handler(); |
788 | Error_Handler(); |
753 | } |
789 | } |
754 | /* USER CODE BEGIN USART3_Init 2 */ |
790 | /* USER CODE BEGIN USART3_Init 2 */ |
755 | 791 | ||
756 | /* USER CODE END USART3_Init 2 */ |
792 | /* USER CODE END USART3_Init 2 */ |
757 | - | ||
758 | } |
793 | } |
759 | 794 | ||
760 | /** |
795 | /** |
761 | * @brief GPIO Initialization Function |
796 | * @brief GPIO Initialization Function |
762 | * @param None |
797 | * @param None |
763 | * @retval None |
798 | * @retval None |
764 | */ |
799 | */ |
765 | static void MX_GPIO_Init(void) |
800 | static void MX_GPIO_Init(void) |
766 | { |
801 | { |
767 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
802 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
768 | 803 | ||
769 | /* GPIO Ports Clock Enable */ |
804 | /* GPIO Ports Clock Enable */ |
Line 774... | Line 809... | ||
774 | 809 | ||
775 | /*Configure GPIO pin Output Level */ |
810 | /*Configure GPIO pin Output Level */ |
776 | HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
811 | HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
777 | 812 | ||
778 | /*Configure GPIO pin Output Level */ |
813 | /*Configure GPIO pin Output Level */ |
779 | HAL_GPIO_WritePin(GPIOA, SPI_CD_Pin|BT_BUTTON_Pin, GPIO_PIN_RESET); |
814 | HAL_GPIO_WritePin(GPIOA, SPI_CD_Pin | BT_BUTTON_Pin, GPIO_PIN_RESET); |
780 | 815 | ||
781 | /*Configure GPIO pin Output Level */ |
816 | /*Configure GPIO pin Output Level */ |
782 | HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin|POWER_LATCH_Pin|USB_PWR_Pin, GPIO_PIN_RESET); |
817 | HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin | POWER_LATCH_Pin | USB_PWR_Pin, GPIO_PIN_RESET); |
783 | 818 | ||
784 | /*Configure GPIO pin Output Level */ |
819 | /*Configure GPIO pin Output Level */ |
785 | HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
820 | HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
786 | 821 | ||
787 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
822 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
788 | GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI_CD_Pin; |
823 | GPIO_InitStruct.Pin = SPI_NSS1_Pin | SPI_CD_Pin; |
789 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
824 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
790 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
825 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
791 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
826 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
792 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
827 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
793 | 828 | ||
794 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
829 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
795 | GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NSS2_Pin|POWER_LATCH_Pin|USB_PWR_Pin; |
830 | GPIO_InitStruct.Pin = SPI_RESET_Pin | SPI_NSS2_Pin | POWER_LATCH_Pin | USB_PWR_Pin; |
796 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
831 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
797 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
832 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
798 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
833 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
799 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
834 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
800 | 835 | ||
801 | /*Configure GPIO pins : SW1_PUSH_Pin SW2_PUSH_Pin */ |
836 | /*Configure GPIO pins : SW1_PUSH_Pin SW2_PUSH_Pin */ |
802 | GPIO_InitStruct.Pin = SW1_PUSH_Pin|SW2_PUSH_Pin; |
837 | GPIO_InitStruct.Pin = SW1_PUSH_Pin | SW2_PUSH_Pin; |
803 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
838 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
804 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
839 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
805 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
840 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
806 | 841 | ||
807 | /*Configure GPIO pin : IGNITION_Pin */ |
842 | /*Configure GPIO pin : IGNITION_Pin */ |
Line 814... | Line 849... | ||
814 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
849 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
815 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
850 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
816 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
851 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
817 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
852 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
818 | HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
853 | HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
819 | - | ||
820 | } |
854 | } |
821 | 855 | ||
822 | /* USER CODE BEGIN 4 */ |
856 | /* USER CODE BEGIN 4 */ |
823 | 857 | ||
824 | /* USER CODE END 4 */ |
858 | /* USER CODE END 4 */ |
825 | 859 | ||
826 | /** |
860 | /** |
827 | * @brief This function is executed in case of error occurrence. |
861 | * @brief This function is executed in case of error occurrence. |
828 | * @retval None |
862 | * @retval None |
829 | */ |
863 | */ |
830 | void Error_Handler(void) |
864 | void Error_Handler(void) |
831 | { |
865 | { |
832 | /* USER CODE BEGIN Error_Handler_Debug */ |
866 | /* USER CODE BEGIN Error_Handler_Debug */ |
833 | /* User can add his own implementation to report the HAL error return state */ |
867 | /* User can add his own implementation to report the HAL error return state */ |
834 | 868 | ||
835 | /* USER CODE END Error_Handler_Debug */ |
869 | /* USER CODE END Error_Handler_Debug */ |
836 | } |
870 | } |
837 | 871 | ||
838 | #ifdef USE_FULL_ASSERT |
872 | #ifdef USE_FULL_ASSERT |
839 | /** |
873 | /** |
840 | * @brief Reports the name of the source file and the source line number |
874 | * @brief Reports the name of the source file and the source line number |
841 | * where the assert_param error has occurred. |
875 | * where the assert_param error has occurred. |
842 | * @param file: pointer to the source file name |
876 | * @param file: pointer to the source file name |
843 | * @param line: assert_param error line source number |
877 | * @param line: assert_param error line source number |
844 | * @retval None |
878 | * @retval None |
845 | */ |
879 | */ |
846 | void assert_failed(uint8_t *file, uint32_t line) |
880 | void assert_failed(uint8_t *file, uint32_t line) |
847 | { |
881 | { |
848 | /* USER CODE BEGIN 6 */ |
882 | /* USER CODE BEGIN 6 */ |
849 | /* User can add his own implementation to report the file name and line number, |
883 | /* User can add his own implementation to report the file name and line number, |
850 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
884 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |