annotate Small_CPU/Src/baseCPU2.c @ 922:7c996354b8ac Evo_2_23

Moved UART6 into a separate unit: UART6 connects internal devices. As a first step the existing code sections have been moved into a new unit. As well the code of the external GNSS sensor has been copied into this unit as starting point for the further development. Later the internal part can be integrated into the common uart (code cleanup).
author Ideenmodellierer
date Sun, 03 Nov 2024 20:53:05 +0100
parents 0d6c4b40fae4
children effadaa3a1f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @copyright heinrichs weikamp
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @file base.c including main()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 15-Aug-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @version V1.0.3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @since 21-Nov-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @brief The beginning of it all. main() is part of this.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Do the inits for hardware
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + Do the inits for sub-systems like menu, dive screen etc.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Start IRQs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * + Start MainTasks not in IRQs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 * @bug
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * @warning
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ==============================================================================
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
18 ##### What about hardware without 8 MHz oscillator #####
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 [..] modify OTP Byte 1 at 0x1FFF7800 with ST-Link utility
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 ##### Where is the RTE Firmware version #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 [..] in baseCPU2.c <just here below :->
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 ##### What to do with the RTE Firmware version #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 [..] change the values RTErequiredHigh and RTErequiredLow in settings.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 to start warning via the firmware if not updated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 ##### What it does #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 ==============================================================================
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
36 [..] All realtime stuff and all what has to be done during sleep
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 [..] RealTimeClock. The entire time and date handling (including divetime)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 [..] Hardware control for pressure sensor, compass, battery monitor
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 [..] Calculations of tissue load, critical radius, otu, cns
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 [..] Switching off the power of the main CPU after request from it.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 ##### IRQs #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 [..] The IRQs are are only used for SystemTick and SPI TransferComplete after
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 DMA data reception.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 [..] HAL_SPI_TxRxCpltCallback() restarts DMA and will call
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 scheduleSpecial_Evaluate_DataSendToSlave() only if it is not blocked
239
e4207f0aaa4b cleanup: factor out dataSendToSlaveStopEval
Jan Mulder <jlmulder@xs4all.nl>
parents: 207
diff changeset
51 by I2C.
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 If the evaluation is blocked it has to be tested and executed afterwards.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 I2C is executed _without_ the usage of interrupts.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 ##### Main loop #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 [..] is a combination of the while loop below in main.c and code in scheduler.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 It is similar to the DR5 code / logic - in contrast to the main CPU
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 Switching the state is done via global.mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 The loops in scheduler all run in the main execution thread without
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 any job stacks (like it was in the DR5).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 ##### Real Time Clock #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 ==============================================================================
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
67 The RTC is a separate part of hardware inside the CPU and is not affected
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 by reset. Only power-on reset does change something.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 This is fine but the RTC is vital for the Sleep mode as Wakeuptimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 This is the only date/time system in the OSTC. The main CPU is passive.
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
71 Data transfer is done with localtime_rtc_tr and localtime_rtc_dr
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 in HAL_RTC format to the main CPU and as HAL_RTC structs the way back for
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 setting the actual time and date.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 The RTC unit has 20 Byte of V_bat powered SRAM. It could be used
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
75 for something useful in both CPUs.
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 ##### File system #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 [..] some files are used for both CPUs, like decom.c/.h, data_central.h, ...
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 ##### Unique device ID register (96 bits) #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 [..] some files are used for both CPUs, like decom.c/.h, data_central.h, ...
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 ##### I2C #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 [..] used for pressure, compass, (accelerator) and battery gauge
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 main cpu and pic (button) is spi
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 ##### Firmware Update Info #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 V0.85 160531 scheduleCheck_pressure_reached_dive_mode_level() changes
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
100 160606 global.no_fly_time_minutes is at least 24h after the dive
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 160613 ambient light fixed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 160720 compass calib to Flash (8000 writes max. as erase has problems)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 160829 do not reset main CPU on power on!
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 V0.91 161018 pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 V0.92+ 161020 global.sensorError[MAX_SENSORS]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 fix missing init_pressure(); at powerUp of RTE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 added HAL_StatusTypeDef for many functions in pressure.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 161024 no_fly_time_minutes Backup FIX
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 seconds_since_last_dive now related to RTC clock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 161121 close to surface starts at 1 meter below last known surface pressure
286
733877ab87d9 Minor: Some Texts fixed, allign RTErequired* values with RTE firmware
heinrichsweikamp
parents: 280
diff changeset
111 161121 in surface mode dive mode starts @1 mtr difference if surface 880 hPa instead of 700 hPa before
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 V0.97+ 170213 added global.dataSendToSlave.diveModeInfo for DIVEMODE_Apnea
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 added global.dataSendToSlave.setEndDive
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 DIVEMODE_Apnea special in scheduler.c (ticksdiff >= 1000) -> no tissue, cns, otu, no change in noFly Time etc.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 V0.99 170320 new HAL Driver Repository
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 V1.01 170509 old HAL Driver Repository
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 * <h2><center>&copy; COPYRIGHT(c) 2017 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 //#define DEBUG_PIN_ACTIVE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 #include "baseCPU2.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 // From Small_CPU/Inc:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 #include "dma.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 #include "i2c.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 #include "spi.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 #include "rtc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 #include "adc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 #include "compass.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 #include "pressure.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 #include "batteryGasGauge.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 #include "batteryCharger.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 #include "scheduler.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 #include "tm_stm32f4_otp.h"
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents: 533
diff changeset
144 #include "externalInterface.h"
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
145 #include "uart.h"
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
146 #include "uart_Internal.h"
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
147 #include "GNSS.h"
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
148
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 // From Common/Inc:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 #include "calc_crush.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 #include "FirmwareData.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 // From Common/Drivers/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 #include <stdio.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
158
433
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
159 uint8_t coldstart __attribute__((section (".noinit")));
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
160
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
161 uint8_t hasExternalClock(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
162 if ((TM_OTP_Read(0, 0) > 0) && (TM_OTP_Read(0, 0) < 0xFF))
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
163 return 1;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
164 else
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
165 return 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 // SHALL LOAD AT 0x08000000 + 0x00005000 = 0x08005000.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 // See CPU2-RTE.ld
100
b364c75005bb Stable.fix.
Dmitry Romanov <kitt@bk.ru>
parents: 90
diff changeset
170 const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= {
728
5143e927219f Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents: 713
diff changeset
171 .versionFirst = 3,
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 890
diff changeset
172 .versionSecond = 4,
762
32529dfea3b0 Preparing a 1.6.2 release candidate
heinrichsweikamp
parents: 738
diff changeset
173 .versionThird = 0,
843
2cab242c9a4a Update version number and set beta state
Ideenmodellierer
parents: 839
diff changeset
174 .versionBeta = 1,
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
176 /* 4 bytes with trailing 0 */
100
b364c75005bb Stable.fix.
Dmitry Romanov <kitt@bk.ru>
parents: 90
diff changeset
177 .signature = "mh",
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
762
32529dfea3b0 Preparing a 1.6.2 release candidate
heinrichsweikamp
parents: 738
diff changeset
179 .release_year = 23,
818
40e951cfa443 1.6.4 release
heinrichsweikamp
parents: 801
diff changeset
180 .release_month = 9,
40e951cfa443 1.6.4 release
heinrichsweikamp
parents: 801
diff changeset
181 .release_day = 14,
100
b364c75005bb Stable.fix.
Dmitry Romanov <kitt@bk.ru>
parents: 90
diff changeset
182 .release_sub = 0,
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
184 /* max 48 with trailing 0 */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
185 //release_info ="12345678901234567890123456789012345678901"
768
dfdfea8897f3 1.6.2 release
heinrichsweikamp
parents: 763
diff changeset
186 .release_info = "stable April 2023",
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
188 /* for safety reasons and coming functions */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
189 .magic[0] = FIRMWARE_MAGIC_FIRST, .magic[1] = FIRMWARE_MAGIC_SECOND,
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
190 .magic[2] = FIRMWARE_MAGIC_CPU2_RTE, /* the magic byte for RTE */
433
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
191 .magic[3] = FIRMWARE_MAGIC_END
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
192 };
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
193
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
195 uint8_t firmwareVersionHigh(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
196 return cpu2_FirmwareData.versionFirst;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
199 uint8_t firmwareVersionLow(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
200 return cpu2_FirmwareData.versionSecond;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 /** @addtogroup OSTC4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 /** @addtogroup CPU2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 #define BUTTON_OSTC_GPIO_PIN GPIO_PIN_0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 #define BUTTON_OSTC_GPIO_PORT GPIOA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 #define BUTTON_OSTC_HAL_RCC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 #define BUTTON_OSTC_IRQn EXTI0_IRQn
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
218 #define VIBRATION_CONTROL_PIN GPIO_PIN_3 /* PortA */
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
219 #define LED_CONTROL_PIN_RED GPIO_PIN_2 /* PortA */
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
220 #define LED_CONTROL_PIN_GREEN GPIO_PIN_1 /* PortA */
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
221 #define MAINCPU_CONTROL_PIN GPIO_PIN_0 /* PortC */
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
222 #define GPS_POWER_CONTROL_PIN GPIO_PIN_15 /* PortB */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
223 #define GPS_BCKP_CONTROL_PIN GPIO_PIN_14 /* PortB */
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
224
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 uint32_t global_test_time_counter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 SBackup backup;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 static void EXTI_Wakeup_Button_Init(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 static void EXTI_Wakeup_Button_DeInit(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
235 static void GPIO_LEDs_VIBRATION_Init(void);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 static void GPIO_Power_MainCPU_Init(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 static void GPIO_Power_MainCPU_ON(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 static void GPIO_Power_MainCPU_OFF(void);
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
239 #ifdef ENABLE_GPIO_V2
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
240 static void GPIO_LED_RED_OFF(void);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
241 static void GPIO_LED_RED_ON(void);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
242 static void GPIO_LED_GREEN_OFF(void);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
243 static void GPIO_LED_GREEN_ON(void);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
244 static void GPIO_VIBRATION_OFF(void);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
245 static void GPIO_VIBRATION_ON(void);
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
246 static void GPIO_GPS_OFF(void);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
247 static void GPIO_GPS_ON(void);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
248 static void GPIO_GPS_BCKP_OFF(void);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
249 static void GPIO_GPS_BCKP_ON(void);
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
250 #endif
183
9baecc0c24b2 Cleanup compiler warnings
ideenmodellierer
parents: 181
diff changeset
251 #ifdef DEBUG_I2C_LINES
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 void GPIO_test_I2C_lines(void);
183
9baecc0c24b2 Cleanup compiler warnings
ideenmodellierer
parents: 181
diff changeset
253 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 void sleep_prepare(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 void SystemClock_Config(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 void SystemClock_Config_HSI(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 void SystemClock_Config_HSE(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 void SYSCLKConfig_STOP_HSI(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 void SYSCLKConfig_STOP_HSE(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 void GPIO_new_DEBUG_Init(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 void GPIO_new_DEBUG_LOW(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 void GPIO_new_DEBUG_HIGH(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 #define REGULAR_RUN
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
269 int __io_putchar(int ch) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
270 ITM_SendChar(ch);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
271 return ch;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 * @brief Main program
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 * @param None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 */
120
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
281 /* #define DEBUG_RUNTIME TRUE */
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
282 #ifdef DEBUG_RUNTIME
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
283 #define MEASURECNT 60 /* number of measuremets to be stored */
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
284 static uint32_t loopcnt[MEASURECNT];
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
285 extern RTC_HandleTypeDef RTCHandle;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
286 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
288 int main(void) {
120
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
289
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
290 #ifdef DEBUG_RUNTIME
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
291 RTC_TimeTypeDef Stime;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
292 uint8_t measurementindex = 0;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
293 uint8_t lastsecond = 0xFF;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
294 #endif
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
295
917
0d6c4b40fae4 Bugfix external interface power up after sleep:
Ideenmodellierer
parents: 909
diff changeset
296 uint8_t extInterfaceActive = 0;
0d6c4b40fae4 Bugfix external interface power up after sleep:
Ideenmodellierer
parents: 909
diff changeset
297
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
298 HAL_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
299 SystemClock_Config();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
301 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
302 HAL_SYSTICK_CLKSourceConfig( SYSTICK_CLKSOURCE_HCLK);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
303 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
305 MX_RTC_init();
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
306 GPIO_LEDs_VIBRATION_Init();
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
307 GPIO_new_DEBUG_Init(); // added 170322 hw
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
308 initGlobals();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309
120
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
310 /* printf("CPU2-RTE running...\n"); */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311
329
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
312 HAL_Delay(100);
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
313
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
314 MX_I2C1_Init();
329
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
315 if (global.I2C_SystemStatus != HAL_OK)
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
316 {
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
317 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
318 MX_I2C1_TestAndClear(); // do it a second time
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
319 }
488
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
320 HAL_Delay(100);
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
321 I2C_DeInit();
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
322 HAL_Delay(100);
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
323 MX_I2C1_Init();
488
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
324 HAL_Delay(100);
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
325 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326
329
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
327
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
328
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
329 //dangerous: TM_OTP_Write(0,0, 0x01);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 #ifdef REGULAR_RUN
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
331 global.sensorError[SENSOR_PRESSURE_ID] = init_pressure();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
332 global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID];
329
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
333 if (global.I2C_SystemStatus != HAL_OK)
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
334 {
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
335 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
336 MX_I2C1_TestAndClear(); // do it a second time
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
337 }
488
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
338 HAL_Delay(100);
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
339 I2C_DeInit();
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
340 HAL_Delay(100);
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
341 MX_I2C1_Init();
488
9eeab3fead8f Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
heinrichsweikamp
parents: 473
diff changeset
342 HAL_Delay(100);
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
343 global.sensorError[SENSOR_PRESSURE_ID] = init_pressure();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
344 global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID];
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
345 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
347 global.dataSendToMaster.sensorErrors =
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
348 global.sensorError[SENSOR_PRESSURE_ID];
329
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
349
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
350 if(is_init_pressure_done())
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
351 {
339
37f45300bc2e Apply averaging to pressure measurement: In pre versions calculated pressure value jittered +/-10hPa. Since we measure the pressure several time a second but only use one value a second, calc average including not used values
ideenmodellierer
parents: 334
diff changeset
352 init_surface_ring(0);
329
da5b91b1e20e Improved startup robustness
ideenmodellierer
parents: 324
diff changeset
353 }
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
354 init_battery_gas_gauge();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
355 HAL_Delay(10);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
356 battery_gas_gauge_get_data();
473
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
357
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
358 global.lifeData.battery_voltage = get_voltage();
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
359 global.lifeData.battery_charge = get_charge();
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
360 copyBatteryData();
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
361
473
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
362 MX_SPI3_Init();
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
363
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
364 if(coldstart != 0xA5) /* Not reading a 0xA5 means the memory cells has not been initialized before => cold start */
433
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
365 {
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
366 coldstart = 0xA5;
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
367
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
368 set_charge_state(Charger_ColdStart);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
369
473
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
370 global.dataSendToMaster.power_on_reset = 1;
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
371 global.deviceDataSendToMaster.power_on_reset = 1;
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
372
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
373 if (!scheduleSetButtonResponsiveness())
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
374 {
763
aa6006975e76 increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents: 762
diff changeset
375 HAL_Delay(10);
473
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
376 if (!scheduleSetButtonResponsiveness()) // send again, if problem it's not my problem here.
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
377 {
763
aa6006975e76 increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents: 762
diff changeset
378 HAL_Delay(10);
473
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
379 scheduleSetButtonResponsiveness(); // init
763
aa6006975e76 increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents: 762
diff changeset
380 HAL_Delay(10);
473
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
381 }
edfc1a464b42 Do not signal power on reset in case of a "warm" reset:
ideenmodellierer
parents: 439
diff changeset
382 }
433
aa286a4926c2 Detect startup after power off:
ideenmodellierer
parents: 417
diff changeset
383 }
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
384 else
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
385 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
386 set_charge_state(Charger_NotConnected);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
387 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
389 ADCx_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
390 GPIO_Power_MainCPU_Init();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
391
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
392 externalInterface_InitPower33();
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
393
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
394 global.mode = MODE_POWERUP;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 #else
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
396 init_pressure();
339
37f45300bc2e Apply averaging to pressure measurement: In pre versions calculated pressure value jittered +/-10hPa. Since we measure the pressure several time a second but only use one value a second, calc average including not used values
ideenmodellierer
parents: 334
diff changeset
397 init_surface_ring(0);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
399 ADCx_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
400 GPIO_Power_MainCPU_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
401 global.mode = MODE_TEST;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
403 while (1) {
120
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
404 /* printf("Global mode = %d\n", global.mode); */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
406 switch (global.mode) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
407 case MODE_POWERUP:
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
408 case MODE_BOOT:
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
409 // ReInit_battery_charger_status_pins();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
410 compass_init(0, 7);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
411 accelerator_init();
554
3328189786e7 Added external ADC interface functionality (MCP3424):
Ideenmodellierer
parents: 533
diff changeset
412 externalInterface_Init();
181
331882a89421 Removed not suppoted wireless feature
ideenmodellierer
parents: 172
diff changeset
413
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
414 if (global.mode == MODE_BOOT) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
415 GPIO_Power_MainCPU_OFF();
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
416 #ifdef ENABLE_GPIO_V2
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
417 GPIO_LED_GREEN_ON();
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
418 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
419 HAL_Delay(100); // for GPIO_Power_MainCPU_ON();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
420 GPIO_Power_MainCPU_ON();
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
421 #ifdef ENABLE_GPIO_V2
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
422 GPIO_LED_GREEN_OFF();
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
423
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
424 GPIO_LED_RED_ON();
900
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
425 GPIO_VIBRATION_ON();
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
426 #endif
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
427 HAL_Delay(100);
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
428 #ifdef ENABLE_GPIO_V2
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
429 GPIO_LED_RED_OFF();
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
430 GPIO_VIBRATION_OFF();
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
431 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
432 }
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
433 #ifdef ENABLE_GPIO_V2
900
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
434 GPIO_LED_RED_OFF();
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
435 GPIO_LED_GREEN_OFF();
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
436 GPIO_VIBRATION_OFF();
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
437 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
438 SPI_synchronize_with_Master();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
439 MX_DMA_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
440 MX_SPI1_Init();
134
0586ae83a243 Removed cyclic (by timer) send on slave side
Ideenmodellierer
parents: 120
diff changeset
441 SPI_Start_single_TxRx_with_Master(); /* be prepared for the first data exchange */
207
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 183
diff changeset
442 Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD);
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
443
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
444 #ifdef ENABLE_GPIO_V2
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
445 // GNSS tests
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
446 GNSS_IO_init();
900
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
447 GPIO_GPS_ON();
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
448 GPIO_GPS_BCKP_ON();
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
449 MX_USART6_UART_Init();
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
450 GNSS_Init(&GNSS_Handle, &huart6);
900
6a7701f66b16 minor: LED/Vibration behavior on wake-up
heinrichsweikamp
parents: 899
diff changeset
451 #endif
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 890
diff changeset
452
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
453 /*
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
454 * Demo code from SimpleMethod
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
455 * called 1/second
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
456 while (1) {
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
457
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
458 if ((HAL_GetTick() - Timer) > 1000) {
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
459 GNSS_GetUniqID(&GNSS_Handle);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
460 GNSS_ParseBuffer(&GNSS_Handle);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
461 HAL_Delay(250);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
462 GNSS_GetPVTData(&GNSS_Handle);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
463 GNSS_ParseBuffer(&GNSS_Handle);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
464 printf("Day: %d-%d-%d \r\n", GNSS_Handle.day, GNSS_Handle.month,GNSS_Handle.year);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
465 printf("Time: %d:%d:%d \r\n", GNSS_Handle.hour, GNSS_Handle.min,GNSS_Handle.sec);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
466 printf("Status of fix: %d \r\n", GNSS_Handle.fixType);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
467 printf("Latitude: %f \r\n", GNSS_Handle.fLat);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
468 printf("Longitude: %f \r\n",(float) GNSS_Handle.lon / 10000000.0);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
469 printf("Height above ellipsoid: %d \r\n", GNSS_Handle.height);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
470 printf("Height above mean sea level: %d \r\n", GNSS_Handle.hMSL);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
471 printf("Ground Speed (2-D): %d \r\n", GNSS_Handle.gSpeed);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
472 printf("Unique ID: %04X %04X %04X %04X %04X \n\r",
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
473 GNSS_Handle.uniqueID[0], GNSS_Handle.uniqueID[1],
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
474 GNSS_Handle.uniqueID[2], GNSS_Handle.uniqueID[3],
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
475 GNSS_Handle.uniqueID[4], GNSS_Handle.uniqueID[5]);
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
476 Timer = HAL_GetTick();
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
477 }
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
478 */
889
cf3967fe6924 GNSS work in progress
heinrichsweikamp
parents: 887
diff changeset
479
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
480 global.mode = MODE_SURFACE;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
481 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
483 case MODE_CALIB:
90
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
484 scheduleCompassCalibrationMode();
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
485 break;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
486
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
487 case MODE_SURFACE:
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
488 scheduleSurfaceMode();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
489 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
491 case MODE_TEST:
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
492 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
494 case MODE_DIVE:
90
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
495 backup.no_fly_time_minutes = global.no_fly_time_minutes;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
496 backup.seconds_since_last_dive = global.seconds_since_last_dive;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
497
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
498 vpm_init( &global.vpm, global.conservatism, global.repetitive_dive,
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
499 global.seconds_since_last_dive );
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
500 global.no_fly_time_minutes = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
501 global.lifeData.dive_time_seconds = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
502 global.lifeData.dive_time_seconds_without_surface_time = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
503 scheduleDiveMode();
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
504 // done now in scheduler prior to change mode: global.seconds_since_last_dive = 1;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
505
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
506 if( global.lifeData.dive_time_seconds > 60 )
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
507 {
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
508 //No Fly time 60% of desaturationtime after dive
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
509 global.no_fly_time_minutes = decom_calc_desaturation_time(
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
510 global.lifeData.tissue_nitrogen_bar,
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
511 global.lifeData.tissue_helium_bar,
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
512 global.lifeData.pressure_surface_bar ) * 60 / 100;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
513 if( global.no_fly_time_minutes < (24 * 60) )
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
514 global.no_fly_time_minutes = 24 * 60;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
515 }
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
516 else
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
517 {
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
518 global.no_fly_time_minutes = backup.no_fly_time_minutes;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
519 global.seconds_since_last_dive = backup.seconds_since_last_dive;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
520 }
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
521
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
522 global.lifeData.dive_time_seconds = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
523 global.lifeData.dive_time_seconds_without_surface_time = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
524 global.lifeData.counterSecondsShallowDepth = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
525
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
526 backup.no_fly_time_minutes = 0;
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
527 backup.seconds_since_last_dive = 0;
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
528 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
530 case MODE_SHUTDOWN:
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
531 HAL_Delay(200);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
532 global.mode = MODE_SLEEP;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
533 MX_SPI3_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
534 break;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
535
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
536 case MODE_SLEEP:
917
0d6c4b40fae4 Bugfix external interface power up after sleep:
Ideenmodellierer
parents: 909
diff changeset
537 extInterfaceActive = externalInterface_isEnabledPower33();
839
061174d88af9 Code cleanup: UART protocol definitions
Ideenmodellierer
parents: 818
diff changeset
538 externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
539 externalInterface_SwitchPower33(false);
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
540 if (hasExternalClock())
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
541 SystemClock_Config_HSI();
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
542 GPIO_LEDs_VIBRATION_Init();
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
543 sleep_prepare();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
545 scheduleSleepMode();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
546 if (hasExternalClock())
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
547 SystemClock_Config_HSE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
548 EXTI_Wakeup_Button_DeInit();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
549 ADCx_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
550 GPIO_Power_MainCPU_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
551 GPIO_Power_MainCPU_ON();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
552 compass_init(0, 7);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
553 accelerator_init();
148
ee744c7160ce Use SPI TX callback to synchronize to main CPU
Ideenmodellierer
parents: 134
diff changeset
554 SPI_synchronize_with_Master();
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
555 MX_DMA_Init();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
556 MX_SPI1_Init();
148
ee744c7160ce Use SPI TX callback to synchronize to main CPU
Ideenmodellierer
parents: 134
diff changeset
557 SPI_Start_single_TxRx_with_Master();
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
558
917
0d6c4b40fae4 Bugfix external interface power up after sleep:
Ideenmodellierer
parents: 909
diff changeset
559 if(extInterfaceActive)
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
560 {
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
561 externalInterface_SwitchPower33(true);
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
562 }
738
30717de00f3a Added data init function for external interface:
Ideenmodellierer
parents: 728
diff changeset
563 externalInterface_InitDatastruct();
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
564 // EXTILine0_Button_DeInit(); not now, later after testing
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
565 break;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
566 }
120
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
567
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
568 #ifdef DEBUG_RUNTIME
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
569 HAL_RTC_GetTime(&RTCHandle, &Stime, RTC_FORMAT_BCD);
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
570
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
571 if(lastsecond == 0xFF)
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
572 {
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
573 measurementindex = 0;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
574 loopcnt[measurementindex] = 0;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
575 lastsecond = Stime.Seconds;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
576 }
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
577 loopcnt[measurementindex]++;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
578
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
579 if(lastsecond != Stime.Seconds)
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
580 {
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
581 measurementindex++;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
582 if (measurementindex == MEASURECNT) measurementindex = 0;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
583 loopcnt[measurementindex] = 0;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
584 lastsecond = Stime.Seconds;
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
585 if(measurementindex +1 < MEASURECNT) loopcnt[measurementindex +1] = 0xffff; /* helps to identify the latest value */
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
586 }
6347a86caa18 Cleanup warning and disable printf calls
Ideenmodellierer
parents: 105
diff changeset
587 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
588 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 /** @brief Button feedback - EXTI line detection callbacks
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 * @param GPIO_Pin: Specifies the pins connected EXTI line
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 */
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
595 void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
597 if (GPIO_Pin == BUTTON_OSTC_GPIO_PIN) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
598 if (global.mode == MODE_SLEEP) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
599 global.mode = MODE_BOOT;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
600 }
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
601 }
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
602 else
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
603 {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
604
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
605 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 * @brief System Clock Configuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 * The system Clock is configured as follow :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 * System Clock source = PLL (HSI)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 * SYSCLK(Hz) = 100 MHz
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 * HCLK(Hz) = 100 MHz
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 * AHB Prescaler = 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 * APB1 Prescaler = 2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 * APB2 Prescaler = 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 * HSI Frequency(Hz) = 16 MHz
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 * PLL_M = 16
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 * PLL_N = 400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 * PLL_P = 4
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 * PLL_Q = 7 // no USB
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 * VDD(V) = 3.3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 * Main regulator output voltage = Scale1 mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 * Flash Latency(WS) = 3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 * @param None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
629 void SystemClock_Config(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
630 if (hasExternalClock())
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
631 SystemClock_Config_HSE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
632 else
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
633 SystemClock_Config_HSI();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
636 void SYSCLKConfig_STOP(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
637 SYSCLKConfig_STOP_HSI();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
640 void SystemClock_Config_HSE(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
641 RCC_OscInitTypeDef RCC_OscInitStruct;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
642 RCC_ClkInitTypeDef RCC_ClkInitStruct;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 // RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
645 __PWR_CLK_ENABLE(); // is identical to __HAL_RCC_PWR_CLK_ENABLE();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
647 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
649 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; //|RCC_OSCILLATORTYPE_LSE;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
650 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
651 //RCC_OscInitStruct.LSEState = RCC_LSE_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
652 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
653 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
654 RCC_OscInitStruct.PLL.PLLM = 8;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
655 RCC_OscInitStruct.PLL.PLLN = 320;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
656 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
657 RCC_OscInitStruct.PLL.PLLQ = 4;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
658 HAL_RCC_OscConfig(&RCC_OscInitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
660 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
661 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
662 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
663 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
664 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
665 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
666 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 // PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 // PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 // HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 // HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 // HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
676 /* SysTick_IRQn interrupt configuration */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 // HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
680 void SystemClock_Config_HSI(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
681 RCC_ClkInitTypeDef RCC_ClkInitStruct;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
682 RCC_OscInitTypeDef RCC_OscInitStruct;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
684 /* Enable Power Control clock */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
685 __HAL_RCC_PWR_CLK_ENABLE();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
687 /* The voltage scaling allows optimizing the power consumption when the device is
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
688 clocked below the maximum system frequency, to update the voltage scaling value
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
689 regarding system frequency refer to product datasheet. */
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
690 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
692 /* Enable HSI Oscillator and activate PLL with HSI as source */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
693 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
694 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
695 RCC_OscInitStruct.HSICalibrationValue = 0x10;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
696 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
697 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
698 RCC_OscInitStruct.PLL.PLLM = 16;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
699 RCC_OscInitStruct.PLL.PLLN = 320;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
700 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
701 RCC_OscInitStruct.PLL.PLLQ = 4;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
702 HAL_RCC_OscConfig(&RCC_OscInitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
704 /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
705 clocks dividers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
706 RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
707 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
708 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
709 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
710 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
711 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
712 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 * @brief Configures system clock after wake-up from STOP: enable HSI, PLL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 * and select PLL as system clock source.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 * @param None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 */
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
722 void SYSCLKConfig_STOP_HSE(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
723 RCC_ClkInitTypeDef RCC_ClkInitStruct;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
724 RCC_OscInitTypeDef RCC_OscInitStruct;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
725 uint32_t pFLatency = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
727 /* Get the Oscillators configuration according to the internal RCC registers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
728 HAL_RCC_GetOscConfig(&RCC_OscInitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
730 /* After wake-up from STOP reconfigure the system clock: Enable HSI and PLL */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
731 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
732 RCC_OscInitStruct.HSIState = RCC_HSE_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
733 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
734 HAL_RCC_OscConfig(&RCC_OscInitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
736 /* Get the Clocks configuration according to the internal RCC registers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
737 HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &pFLatency);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
739 /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
740 clocks dividers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
741 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
742 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
743 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, pFLatency);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
746 void SYSCLKConfig_STOP_HSI(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
747 RCC_ClkInitTypeDef RCC_ClkInitStruct;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
748 RCC_OscInitTypeDef RCC_OscInitStruct;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
749 uint32_t pFLatency = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
751 /* Get the Oscillators configuration according to the internal RCC registers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
752 HAL_RCC_GetOscConfig(&RCC_OscInitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
754 /* After wake-up from STOP reconfigure the system clock: Enable HSI and PLL */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
755 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
756 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
757 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
758 RCC_OscInitStruct.HSICalibrationValue = 0x10;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
759 HAL_RCC_OscConfig(&RCC_OscInitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
761 /* Get the Clocks configuration according to the internal RCC registers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
762 HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &pFLatency);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
764 /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
765 clocks dividers */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
766 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
767 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
768 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, pFLatency);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 * @brief SYSTICK callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 * @param None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 */
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
776 void HAL_SYSTICK_Callback(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
777 HAL_IncTick();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 * @brief Configures GPIO for LED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 * Might move with STM32Cube usage
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 * @param None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 void GPIO_test_I2C_lines(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 GPIO_InitTypeDef GPIO_InitStructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 __GPIOB_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 GPIO_InitStructure.Pin = GPIO_PIN_8;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 GPIO_InitStructure.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 GPIO_InitStructure.Pin = GPIO_PIN_9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 HAL_Delay(10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,GPIO_PIN_RESET);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 HAL_Delay(10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
808 static void GPIO_LEDs_VIBRATION_Init(void) {
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
809 GPIO_InitTypeDef GPIO_InitStructure;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
811 __GPIOA_CLK_ENABLE();
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
812 GPIO_InitStructure.Pin = LED_CONTROL_PIN_RED;
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
813 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
814 GPIO_InitStructure.Pull = GPIO_PULLUP;
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
815 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
816 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
909
6902bb4b6b2e Define state of new GPIO out pins:
Ideenmodellierer
parents: 903
diff changeset
817 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET);
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
818
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
819 GPIO_InitStructure.Pin = LED_CONTROL_PIN_GREEN;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
820 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
821 GPIO_InitStructure.Pull = GPIO_PULLUP;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
822 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
823 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
909
6902bb4b6b2e Define state of new GPIO out pins:
Ideenmodellierer
parents: 903
diff changeset
824 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET);
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
825
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
826 GPIO_InitStructure.Pin = VIBRATION_CONTROL_PIN;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
827 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
828 GPIO_InitStructure.Pull = GPIO_PULLDOWN;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
829 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
830 HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
909
6902bb4b6b2e Define state of new GPIO out pins:
Ideenmodellierer
parents: 903
diff changeset
831 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET);
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
832
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
833 __GPIOB_CLK_ENABLE();
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
834 GPIO_InitStructure.Pin = GPS_POWER_CONTROL_PIN;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
835 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
836 GPIO_InitStructure.Pull = GPIO_PULLUP;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
837 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
838 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure);
909
6902bb4b6b2e Define state of new GPIO out pins:
Ideenmodellierer
parents: 903
diff changeset
839 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET);
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
840
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
841 GPIO_InitStructure.Pin = GPS_BCKP_CONTROL_PIN;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
842 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
843 GPIO_InitStructure.Pull = GPIO_PULLDOWN;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
844 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
845 HAL_GPIO_Init( GPIOB, &GPIO_InitStructure);
909
6902bb4b6b2e Define state of new GPIO out pins:
Ideenmodellierer
parents: 903
diff changeset
846 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
849 void GPIO_new_DEBUG_Init(void) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 #ifdef DEBUG_PIN_ACTIVE
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
851 GPIO_InitTypeDef GPIO_InitStructure;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
853 __GPIOC_CLK_ENABLE();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
854 GPIO_InitStructure.Pin = LED_CONTROL_PIN;
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
855 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
856 GPIO_InitStructure.Pull = GPIO_PULLUP;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
857 GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
858 HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
862 void GPIO_new_DEBUG_LOW(void) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 #ifdef DEBUG_PIN_ACTIVE
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
864 HAL_GPIO_WritePin(GPIOC,LED_CONTROL_PIN,GPIO_PIN_RESET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
868 void GPIO_new_DEBUG_HIGH(void) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 #ifdef DEBUG_PIN_ACTIVE
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
870 HAL_GPIO_WritePin(GPIOC,LED_CONTROL_PIN,GPIO_PIN_SET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
874 static void GPIO_Power_MainCPU_Init(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
875 GPIO_InitTypeDef GPIO_InitStructure;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
876 __GPIOC_CLK_ENABLE();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
877 GPIO_InitStructure.Pin = MAINCPU_CONTROL_PIN;
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
878 GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
879 GPIO_InitStructure.Pull = GPIO_PULLUP;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
880 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
881 HAL_GPIO_Init( GPIOC, &GPIO_InitStructure);
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
882 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
885 static void GPIO_Power_MainCPU_ON(void) {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
886 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
889 static void GPIO_Power_MainCPU_OFF(void) {
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
890 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
893 #ifdef ENABLE_GPIO_V2
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
894 static void GPIO_LED_GREEN_ON(void) {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
895 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
896 }
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
897
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
898 static void GPIO_LED_GREEN_OFF(void) {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
899 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
900 }
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
901
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
902 static void GPIO_LED_RED_ON(void) {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
903 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_RESET);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
904 }
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
905
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
906 static void GPIO_LED_RED_OFF(void) {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
907 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
908 }
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
909
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
910 static void GPIO_VIBRATION_ON(void) {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
911 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_SET);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
912 }
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
913
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
914 static void GPIO_VIBRATION_OFF(void) {
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
915 HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET);
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
916 }
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
917
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
918 static void GPIO_GPS_ON(void) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
919 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_RESET);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
920 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
921
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
922 static void GPIO_GPS_OFF(void) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
923 HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
924 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
925
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
926 static void GPIO_GPS_BCKP_ON(void) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
927 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
928 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
929
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
930 static void GPIO_GPS_BCKP_OFF(void) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
931 HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
932 }
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
933 #endif
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
934
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 * @brief Configures EXTI Line0 (connected to PA0 + PA1 pin) in interrupt mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 * @param None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
941 static void EXTI_Wakeup_Button_Init(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
942 GPIO_InitTypeDef GPIO_InitStructure;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
944 __HAL_RCC_GPIOA_CLK_ENABLE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
945 BUTTON_OSTC_HAL_RCC_GPIO_CLK_ENABLE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
946 GPIO_InitStructure.Pin = BUTTON_OSTC_GPIO_PIN;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
947 GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
948 GPIO_InitStructure.Pull = GPIO_NOPULL;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
949 HAL_GPIO_Init( BUTTON_OSTC_GPIO_PORT, &GPIO_InitStructure);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
951 HAL_NVIC_SetPriority( BUTTON_OSTC_IRQn, 0x0F, 0);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
952 HAL_NVIC_EnableIRQ( BUTTON_OSTC_IRQn);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
955 static void EXTI_Wakeup_Button_DeInit(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
956 GPIO_InitTypeDef GPIO_InitStructure;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
958 GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
959 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
960 GPIO_InitStructure.Pull = GPIO_NOPULL;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
962 GPIO_InitStructure.Pin = BUTTON_OSTC_GPIO_PIN;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
963 HAL_GPIO_Init( BUTTON_OSTC_GPIO_PORT, &GPIO_InitStructure);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
964 HAL_NVIC_DisableIRQ( BUTTON_OSTC_IRQn);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968 * @brief Wake Up Timer callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 * @param hrtc: RTC handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 static uint8_t uwCounter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 uwCounter = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
981 void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *I2cHandle) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
985 void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *I2cHandle) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
989 void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *I2cHandle) {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
993 void sleep_prepare(void) {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
994 EXTI_Wakeup_Button_Init();
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
995
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
996 compass_sleep();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
997 HAL_Delay(100);
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
998 accelerator_sleep();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
999 HAL_Delay(100);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1001 I2C_DeInit();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1002 MX_SPI_DeInit();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1003 MX_SPI3_DeInit();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1004 ADCx_DeInit();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1006 GPIO_InitTypeDef GPIO_InitStruct;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1008 __HAL_RCC_GPIOA_CLK_ENABLE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1009 __HAL_RCC_GPIOB_CLK_ENABLE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1010 __HAL_RCC_GPIOC_CLK_ENABLE();
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1011 __HAL_RCC_GPIOH_CLK_ENABLE();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1013 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1014 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1015 GPIO_InitStruct.Pull = GPIO_NOPULL;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1016 GPIO_InitStruct.Pin = GPIO_PIN_All;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1017 HAL_GPIO_Init( GPIOH, &GPIO_InitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018 #ifdef DEBUGMODE
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1019 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9); /* debug */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 #endif
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1021
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1022 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN | GPS_BCKP_CONTROL_PIN);
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1023 HAL_GPIO_Init( GPIOB, &GPIO_InitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1025 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( MAINCPU_CONTROL_PIN | CHARGE_OUT_PIN | EXT33V_CONTROL_PIN); /* power off & charger in & charge out & OSC32 & ext33Volt */
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 657
diff changeset
1026
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1027 HAL_GPIO_Init( GPIOC, &GPIO_InitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1029 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | VIBRATION_CONTROL_PIN | LED_CONTROL_PIN_RED | LED_CONTROL_PIN_GREEN);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 #ifdef DEBUGMODE
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1031 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | GPIO_PIN_13 | GPIO_PIN_14); /* wake up button & debug */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1033 HAL_GPIO_Init( GPIOA, &GPIO_InitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1035 GPIO_InitStruct.Pin = GPIO_PIN_All;
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1036 HAL_GPIO_Init( GPIOH, &GPIO_InitStruct);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1038 GPIO_Power_MainCPU_OFF();
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 917
diff changeset
1039 #ifdef ENABLE_GPIO_V2
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
1040 GPIO_LED_GREEN_OFF();
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
1041 GPIO_LED_RED_OFF();
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1042 GPIO_VIBRATION_OFF();
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1043 GPIO_GPS_BCKP_ON(); // mH : costs 100µA in sleep - beware
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents: 880
diff changeset
1044 GPIO_GPS_OFF();
880
f012fcd7f465 support for led and vibration
heinrichsweikamp
parents: 843
diff changeset
1045
890
651d21777b61 cleanup and disable function for GNSS uart and DMA
heinrichsweikamp
parents: 889
diff changeset
1046 MX_USART6_UART_DeInit();
903
0f2e5a166d40 Disable GNSS operations using compile switch:
Ideenmodellierer
parents: 900
diff changeset
1047 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048 #ifndef DEBUGMODE
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1049 __HAL_RCC_GPIOB_CLK_DISABLE();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 #endif
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1051 __HAL_RCC_GPIOH_CLK_DISABLE();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1053 HAL_Delay(1000);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 void sleep_test(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 GPIO_InitTypeDef GPIO_InitStruct;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 __HAL_RCC_GPIOA_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 __HAL_RCC_GPIOB_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 __HAL_RCC_GPIOC_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 __HAL_RCC_GPIOH_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068 GPIO_InitStruct.Pull = GPIO_NOPULL;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 GPIO_InitStruct.Pin = GPIO_PIN_All;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | GPIO_PIN_15 | GPIO_PIN_14);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 GPIO_Power_MainCPU_OFF();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 GPIO_InitStruct.Pull = GPIO_PULLUP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 GPIO_InitStruct.Pin = GPIO_PIN_0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 // __HAL_RCC_GPIOA_CLK_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 __HAL_RCC_GPIOB_CLK_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 // __HAL_RCC_GPIOC_CLK_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 __HAL_RCC_GPIOH_CLK_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 HAL_Delay(5000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 while(1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 RTC_StopMode_2seconds();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 HAL_Delay(200);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 #ifdef USE_FULL_ASSERT
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103 * @brief Reports the name of the source file and the source line number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 * where the assert_param error has occurred.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 * @param file: pointer to the source file name
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 * @param line: assert_param error line source number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 void assert_failed(uint8_t* file, uint32_t line)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 {
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1111 /* User can add his own implementation to report the file name and line number,
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1112 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113
89
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1114 /* Infinite loop */
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1115 while (1)
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1116 {
ff7775cc34c4 temp! full cyclic SPI
Dmitry Romanov <kitt@bk.ru>
parents: 88
diff changeset
1117 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 */
104
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1124 /**
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1125 * @brief This function handles SysTick Handler.
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1126 * @param None
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1127 * @retval None
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1128 */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129
104
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1130 /*TxRx only here. Every 100 ms.*/
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1131 uint8_t ticks100ms=0;
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1132 void SysTick_Handler(void)
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1133 {
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1134 HAL_IncTick();
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1135 if(ticks100ms<100){
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1136 ticks100ms++;
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1137 }else
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1138 {
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1139 ticks100ms=0;
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1140 }
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 103
diff changeset
1141 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/