annotate Discovery/Src/data_exchange_main.c @ 263:a6c0375bc950 IPC_Sync_Improvment_2

Forward 100ms time stamp to RTE and handle logbook in main loop Because of code execution variance between 100ms cycle event and start of SPI communication, the synchronization between Main and RTE may shift. To avoid these shifts the time stamp of the 100ms event is forwarded to the RTE which is now able to adapt to small variations. One variation point was the storage of dive samples within the external flash. Taking a closer look how this function works, moving it from the timer callback to the main loop should not be an issue. A critical point of having the function in the timer call back was the sector clean function which is called (depending on dive data) every ~300minutes and may take 250ms - 1500ms.
author ideenmodellierer
date Sun, 14 Apr 2019 11:38:14 +0200
parents f0069f002c55
children 2e58a4094770 189387bf23a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file data_exchange_main.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @date 13-Oct-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @version V0.0.3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @since 17-Feb-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @brief Communication with the second CPU == RTE system
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ##### Version Changes #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 160217 V0.0.3 pStateUsed->decolistXXXXX.tickstamp = HAL_GetTick(); added
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 150627 V0.0.2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 ==============================================================================
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 ##### Button, Set Time, Clear Deco etc Request #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 was updated (151207) for buttons and clear deco at the moment only
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 using requestNecessary and checking in DataEX_copy_to_LifeData()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 Hence if there is no confirm from the smallCPU on the data after the request
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 the request will be send again.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 ##### Device Data #####
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 main CPU always sends the device data info that it has at the moment
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 on start it is INT32_MIN, INT32_MAX and 0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 as initialized in data_central.c variable declaration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 second small CPU gets request to send its device data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
41 on reception the data is merged with the data in externLogbookFlash,
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 stored on the externLogbookFlash and from now on send to small CPU
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 ##### Magnet Reset #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 *
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 /* Includes ------------------------------------------------------------------*/
133
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
58 #include <stdlib.h>
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
59 #include <string.h> // for memcpy
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 #include "stdio.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 #include "ostc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 #include "data_central.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 #include "data_exchange_main.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 #include "base.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 #include "calc_crush.h" /* for vpm_init */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 #include "simulation.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 #include "tCCR.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 #include "timer.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 #include "buehlmann.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 #include "externLogbookFlash.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
173
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
76 /* Exported variables --------------------------------------------------------*/
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
77 static uint8_t wasPowerOn = 0;
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
78 static confirmbit8_Type requestNecessary = { .uw = 0 };
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
79 static uint8_t wasUpdateNotPowerOn = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 /* Private variables with external access ------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 /* Private variables ---------------------------------------------------------*/
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
84 static uint8_t told_reset_logik_alles_ok = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
86 static SDataReceiveFromMaster dataOut;
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
87 static SDataExchangeSlaveToMaster dataIn;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
89 static uint8_t data_old__lost_connection_to_slave_counter_temp = 0;
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
90 static uint8_t data_old__lost_connection_to_slave_counter_retry = 0;
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
91 static uint32_t data_old__lost_connection_to_slave_counter_total = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 /* Private function prototypes -----------------------------------------------*/
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
96 static uint8_t DataEX_check_header_and_footer_ok(void);
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
97 static uint8_t DataEX_check_header_and_footer_shifted(void);
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
98 static uint8_t DataEX_check_header_and_footer_devicedata(void);
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
99 static void DataEX_check_DeviceData(void);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 uint8_t DataEX_was_power_on(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 return wasPowerOn;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
108 static uint8_t count_DataEX_Error_Handler = 0;
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
109 static uint8_t last_error_DataEX_Error_Handler = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
111 static void DataEX_Error_Handler(uint8_t answer)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 count_DataEX_Error_Handler++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 last_error_DataEX_Error_Handler = answer;
133
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
115
156
1fbdb45db701 Removed special indicator for DMA transfer error
Ideenmodellierer
parents: 154
diff changeset
116 /* A wrong footer indicates a communication interrupt. State machine is waiting for new data which is not received because no new transmission is triggered */
133
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
117 /* ==> Abort data exchange to enable a new RX / TX cycle */
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
118 if(answer == HAL_BUSY)
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
119 {
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
120 HAL_SPI_Abort_IT(&cpu2DmaSpi);
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
121 }
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
122
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 return;
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 uint32_t DataEX_lost_connection_count(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 return data_old__lost_connection_to_slave_counter_total;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
133 SDataReceiveFromMaster *dataOutGetPointer(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 return &dataOut;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 void DataEX_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 SDiveState * pStateReal = stateRealGetPointerWrite();
99
6a2308b9a3d4 Config for debug data
Dmitry Romanov <kitt@bk.ru>
parents: 90
diff changeset
141 pStateReal->data_old__lost_connection_to_slave = 0; //initial value
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 data_old__lost_connection_to_slave_counter_temp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 data_old__lost_connection_to_slave_counter_total = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 memset((void *)&dataOut, 0, sizeof(SDataReceiveFromMaster));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 dataOut.header.checkCode[0] = 0xBB;
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
148 dataOut.header.checkCode[1] = SPI_RX_STATE_OK;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
149 dataOut.header.checkCode[2] = SPI_RX_STATE_OK;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 dataOut.header.checkCode[3] = 0xBB;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 dataOut.footer.checkCode[0] = 0xF4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 dataOut.footer.checkCode[1] = 0xF3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 dataOut.footer.checkCode[2] = 0xF2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 dataOut.footer.checkCode[3] = 0xF1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
159 static void DataEx_call_helper_requests(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 static uint8_t setDateWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 static uint8_t setTimeWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 static uint8_t calibrateCompassWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 static uint8_t setButtonSensitivityWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 static uint8_t clearDecoWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 static uint8_t getDeviceDataWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 static uint8_t setAccidentFlagWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 static uint8_t setEndDiveWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 if(getDeviceDataWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 dataOut.getDeviceDataNow = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 requestNecessary.ub.devicedata = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 getDeviceDataWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 if(dataOut.getDeviceDataNow)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 getDeviceDataWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 if(setEndDiveWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 dataOut.setEndDive = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 //requestNecessary.ub.XXX = 1; not implemented and no space here
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 setEndDiveWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 if(dataOut.setEndDive)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 setEndDiveWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 if(setAccidentFlagWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 dataOut.setAccidentFlag = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 requestNecessary.ub.accident = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 setAccidentFlagWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 if(dataOut.setAccidentFlag)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 setAccidentFlagWasSend = 1;
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 if(setDateWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 dataOut.setDateNow = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 requestNecessary.ub.date = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 setDateWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 if(dataOut.setDateNow)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 setDateWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 if(setTimeWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 dataOut.setTimeNow = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 requestNecessary.ub.time = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 setTimeWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 if(dataOut.setTimeNow)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 setTimeWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 if(calibrateCompassWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 dataOut.calibrateCompassNow = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 requestNecessary.ub.compass = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 calibrateCompassWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 if(dataOut.calibrateCompassNow)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 calibrateCompassWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 if(clearDecoWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 dataOut.clearDecoNow = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 requestNecessary.ub.clearDeco = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 if(dataOut.clearDecoNow)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 clearDecoWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 if(setButtonSensitivityWasSend)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 dataOut.setButtonSensitivityNow = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 requestNecessary.ub.button = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 setButtonSensitivityWasSend = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 if(dataOut.setButtonSensitivityNow)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 setButtonSensitivityWasSend = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 uint8_t DataEX_call(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 {
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
261 static uint32_t RTEOfflineCnt = 0;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
262 static uint8_t SusppressCom = 0;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
263
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 uint8_t SPI_DMA_answer = 0;
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
265
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
266 if(SusppressCom)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 {
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
268 SusppressCom--;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 }
149
e1d66bc78f9a Eliminate warnings
Ideenmodellierer
parents: 141
diff changeset
270 else
e1d66bc78f9a Eliminate warnings
Ideenmodellierer
parents: 141
diff changeset
271 {
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
272 if(data_old__lost_connection_to_slave_counter_temp >= 2) /* error reaction is triggered whenever communication could not be reestablishen within two cycles */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
273 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
274 data_old__lost_connection_to_slave_counter_temp = 0;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
275 if(DataEX_check_header_and_footer_shifted())
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
276 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
277 if(RTEOfflineCnt > 1) /* RTE restarted communication after a longer silent time => restart error handling to recover */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
278 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
279 data_old__lost_connection_to_slave_counter_retry = 0;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
280 RTEOfflineCnt = 0;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
281 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
283 /* We received shifted data. Step one. Reset DMA to see if the problem is located at main */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
284 if (data_old__lost_connection_to_slave_counter_retry == 0)
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
285 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
286 HAL_SPI_Abort_IT(&cpu2DmaSpi);
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
287 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
288 /* reset of own DMA does not work ==> request reset of slave dma by indicating shifted receiption */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
289 if (data_old__lost_connection_to_slave_counter_retry == 1)
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
290 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
291 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_SHIFTED;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
292 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
293
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
294 /* stop communication with RTE to trigger RTE timeout reaction */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
295 if (data_old__lost_connection_to_slave_counter_retry == 2)
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
296 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
297 SusppressCom = 3;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
298 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
300 data_old__lost_connection_to_slave_counter_retry++;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
301 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
302 else
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
303 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
304 RTEOfflineCnt++; /* based on footer status the RTE does not seem to provide data in time */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
305 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OFFLINE;
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
306 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
307 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
308 #if USE_OLD_SYNC_METHOD
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
309 /* one cycle with NotChipSelect true to clear slave spi buffer */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
310 else
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
311 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
312 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
313 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
314 #endif
133
acc98f5bd8c4 Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents: 115
diff changeset
315
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
316 DataEx_call_helper_requests();
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
317
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
318 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_RESET); /* only for testing with Oscilloscope */
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
319
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
320 if(SusppressCom == 0)
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
321 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
322 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
323
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
324 SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE);
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
325 if(SPI_DMA_answer != HAL_OK)
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
326 {
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
327 DataEX_Error_Handler(SPI_DMA_answer);
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
328 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
329 }
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
330 }
104
22a1094545f3 Tested and alive.
Dmitry Romanov <kitt@bk.ru>
parents: 99
diff changeset
331 // HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 //HAL_Delay(3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_SET); /* only for testing with Oscilloscope */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
338
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
339 static uint32_t SPI_CALLBACKS;
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
340 uint32_t get_num_SPI_CALLBACKS(void){
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
341 return SPI_CALLBACKS;
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
342 }
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
343
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
344 SDataExchangeSlaveToMaster* get_dataInPointer(void){
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
345 return &dataIn;
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
346 }
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
347
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
348 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
349 {
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
350 if(hspi == &cpu2DmaSpi)
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
351 {
154
1ac5033f7c7a Keep NSS low during SPI transfer only
Ideenmodellierer
parents: 149
diff changeset
352 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
82
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
353 SPI_CALLBACKS+=1;
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
354 }
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
355 }
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
356
a6f0881074a4 +i2c analog noise filtering
Dmitry Romanov <kitt@bk.ru>
parents: 51
diff changeset
357
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 void DateEx_copy_to_dataOut(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 const SDiveState * pStateReal = stateRealGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 SSettings *settings = settingsGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 if(get_globalState() == StStop)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 dataOut.mode = MODE_SHUTDOWN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 dataOut.mode = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 dataOut.diveModeInfo = pStateReal->diveSettings.diveMode; // hw 170215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 memcpy(&dataOut.data.DeviceData, stateDeviceGetPointer(), sizeof(SDevice));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 dataOut.data.VPMconservatism = pStateReal->diveSettings.vpm_conservatism;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 dataOut.data.actualGas = pStateReal->lifeData.actualGas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 dataOut.data.ambient_pressure_mbar_ceiling = (pStateReal->decolistBuehlmann.output_ceiling_meter * 100) + (pStateReal->lifeData.pressure_surface_bar * 1000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 dataOut.data.divetimeToCreateLogbook = settings->divetimeToCreateLogbook;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 dataOut.data.timeoutDiveReachedZeroDepth = settings->timeoutDiveReachedZeroDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 dataOut.data.offsetPressureSensor_mbar = settings->offsetPressure_mbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 if((hardwareDataGetPointer()->primarySerial <= 32) || (((hardwareDataGetPointer()->primarySerial == 72) && (hardwareDataGetPointer()->secondarySerial == 15))))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 dataOut.revisionHardware = 0x00;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 dataOut.revisionCRCx0x7A = 0x7A;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 if(hardwareDataGetPointer()->primarySerial < 0xFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 dataOut.revisionHardware = hardwareDataGetPointer()->revision8bit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 dataOut.revisionCRCx0x7A = hardwareDataGetPointer()->revision8bit ^ 0x7A;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 dataOut.revisionHardware = 0xFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 dataOut.revisionCRCx0x7A = 0xFF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 if(DataEX_check_header_and_footer_ok() && !told_reset_logik_alles_ok)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 MX_tell_reset_logik_alles_ok();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 told_reset_logik_alles_ok = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 if(DataEX_check_header_and_footer_ok() && (dataIn.power_on_reset == 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 if(!wasUpdateNotPowerOn)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 wasPowerOn = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settings->ButtonResponsiveness);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 setButtonResponsiveness(settings->ButtonResponsiveness);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 // hw 160720 new lastKnownBatteryPercentage
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 if(!wasUpdateNotPowerOn)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 // dataOut.data.newBatteryGaugePercentageFloat = settingsGetPointer()->lastKnownBatteryPercentage;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 dataOut.data.newBatteryGaugePercentageFloat = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 dataOut.setBatteryGaugeNow = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 void DataEX_copy_to_deco(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 SDiveState * pStateUsed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 if(decoLock == DECO_CALC_running)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 if(stateUsed == stateRealGetPointer())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 pStateUsed = stateRealGetPointerWrite();
90
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
430 else{
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 pStateUsed = stateSimGetPointerWrite();
90
83857eb3b12b +- stable
Dmitry Romanov <kitt@bk.ru>
parents: 89
diff changeset
432 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 if(decoLock == DECO_CALC_init_as_is_start_of_dive)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 vpm_init(&pStateUsed->vpm, pStateUsed->diveSettings.vpm_conservatism, 0, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 buehlmann_init();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 timer_init();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 resetEvents();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 * ToDo by Peter
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 * copy VPM stuff etc. pp.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 * was void initDiveState(SDiveSettings * pDiveSettings, SVpm * pVpm);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 if(decoLock == DECO_CALC_FINSHED_Buehlmann)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 switch(decoLock)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 //Deco_calculation finished
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 case DECO_CALC_FINSHED_vpm:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 memcpy(&pStateUsed->decolistVPM,&stateDeco.decolistVPM,sizeof(SDecoinfo));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 pStateUsed->decolistVPM.tickstamp = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 pStateUsed->vpm.deco_zone_reached = stateDeco.vpm.deco_zone_reached;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 for(int i = 0; i< 16; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 pStateUsed->vpm.adjusted_critical_radius_he[i] = stateDeco.vpm.adjusted_critical_radius_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 pStateUsed->vpm.adjusted_critical_radius_n2[i] = stateDeco.vpm.adjusted_critical_radius_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 pStateUsed->vpm.adjusted_crushing_pressure_he[i] = stateDeco.vpm.adjusted_crushing_pressure_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 pStateUsed->vpm.adjusted_crushing_pressure_n2[i] = stateDeco.vpm.adjusted_crushing_pressure_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 pStateUsed->vpm.initial_allowable_gradient_he[i] = stateDeco.vpm.initial_allowable_gradient_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 pStateUsed->vpm.initial_allowable_gradient_n2[i] = stateDeco.vpm.initial_allowable_gradient_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 pStateUsed->vpm.max_actual_gradient[i] = stateDeco.vpm.max_actual_gradient[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 case DECO_CALC_FINSHED_Buehlmann:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 memcpy(&pStateUsed->decolistBuehlmann,&stateDeco.decolistBuehlmann,sizeof(SDecoinfo));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 pStateUsed->decolistBuehlmann.tickstamp = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 //Copy Data to be stored if regular Buehlmann, not FutureBuehlmann
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 pStateUsed->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = stateDeco.diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 case DECO_CALC_FINSHED_FutureBuehlmann:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 memcpy(&pStateUsed->decolistFutureBuehlmann,&stateDeco.decolistFutureBuehlmann,sizeof(SDecoinfo));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 pStateUsed->decolistFutureBuehlmann.tickstamp = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 case DECO_CALC_FINSHED_Futurevpm:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 memcpy(&pStateUsed->decolistFutureVPM,&stateDeco.decolistFutureVPM,sizeof(SDecoinfo));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 pStateUsed->decolistFutureVPM.tickstamp = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 //Copy Inputdata from stateReal to stateDeco
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 memcpy(&stateDeco.lifeData,&pStateUsed->lifeData,sizeof(SLifeData));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 memcpy(&stateDeco.diveSettings,&pStateUsed->diveSettings,sizeof(SDiveSettings));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 stateDeco.vpm.deco_zone_reached = pStateUsed->vpm.deco_zone_reached;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 for(int i = 0; i< 16; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 stateDeco.vpm.max_crushing_pressure_he[i] = pStateUsed->vpm.max_crushing_pressure_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 stateDeco.vpm.max_crushing_pressure_n2[i] = pStateUsed->vpm.max_crushing_pressure_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 stateDeco.vpm.adjusted_critical_radius_he[i] = pStateUsed->vpm.adjusted_critical_radius_he[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 stateDeco.vpm.adjusted_critical_radius_n2[i] = pStateUsed->vpm.adjusted_critical_radius_n2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 decoLock = DECO_CALC_ready;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
504 static void DataEX_helper_copy_deviceData(SDeviceLine *lineWrite, const SDeviceLine *lineRead)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 lineWrite->date_rtc_dr = lineRead->date_rtc_dr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 lineWrite->time_rtc_tr = lineRead->time_rtc_tr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 lineWrite->value_int32 = lineRead->value_int32;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
511 static void DataEX_helper_SetTime(RTC_TimeTypeDef inStimestructure, uint32_t *outTimetmpreg)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 inStimestructure.TimeFormat = RTC_HOURFORMAT_24;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 *outTimetmpreg = (uint32_t)(((uint32_t)RTC_ByteToBcd2(inStimestructure.Hours) << 16U) | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 ((uint32_t)RTC_ByteToBcd2(inStimestructure.Minutes) << 8U) | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 ((uint32_t)RTC_ByteToBcd2(inStimestructure.Seconds)) | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 (((uint32_t)inStimestructure.TimeFormat) << 16U));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
522 static void DataEX_helper_SetDate(RTC_DateTypeDef inSdatestructure, uint32_t *outDatetmpreg)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 *outDatetmpreg = (((uint32_t)RTC_ByteToBcd2(inSdatestructure.Year) << 16U) | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 ((uint32_t)RTC_ByteToBcd2(inSdatestructure.Month) << 8U) | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 ((uint32_t)RTC_ByteToBcd2(inSdatestructure.Date)) | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 ((uint32_t)inSdatestructure.WeekDay << 13U));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
532 static void DataEX_helper_set_Unknown_Date_deviceData(SDeviceLine *lineWrite)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 RTC_DateTypeDef sdatestructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 RTC_TimeTypeDef stimestructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 stimestructure.Hours = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 stimestructure.Minutes = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 stimestructure.Seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 sdatestructure.Date = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 sdatestructure.Month = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 sdatestructure.Year = 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 setWeekday(&sdatestructure);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 DataEX_helper_SetTime(stimestructure, &lineWrite->time_rtc_tr);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 DataEX_helper_SetDate(sdatestructure, &lineWrite->date_rtc_dr);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
551 static uint8_t DataEX_helper_Check_And_Correct_Date_deviceData(SDeviceLine *lineWrite)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 RTC_DateTypeDef sdatestructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 RTC_TimeTypeDef stimestructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 // from lineWrite to structure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 translateDate(lineWrite->date_rtc_dr, &sdatestructure);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 translateTime(lineWrite->time_rtc_tr, &stimestructure);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 if( (sdatestructure.Year >= 15)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 && (sdatestructure.Year <= 30)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 && (sdatestructure.Month <= 12))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 DataEX_helper_set_Unknown_Date_deviceData(lineWrite);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
571 static uint8_t DataEX_helper_Check_And_Correct_Value_deviceData(SDeviceLine *lineWrite, int32_t from, int32_t to)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 if(lineWrite->value_int32 >= from && lineWrite->value_int32 <= to)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 if(lineWrite->value_int32 < from)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 lineWrite->value_int32 = from;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 lineWrite->value_int32 = to;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 DataEX_helper_set_Unknown_Date_deviceData(lineWrite);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
586 static void DataEX_check_DeviceData(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 SDevice *DeviceData = stateDeviceGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->batteryChargeCompleteCycles);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->batteryChargeCycles);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->depthMaximum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->diveCycles);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->hoursOfOperation);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->temperatureMaximum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->temperatureMinimum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->voltageMinimum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->batteryChargeCompleteCycles, 0, 10000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->batteryChargeCycles, 0, 20000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->depthMaximum, 0, (500*100)+1000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->diveCycles, 0, 20000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->hoursOfOperation, 0, 1000000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->temperatureMaximum, -30*100, 150*100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->temperatureMinimum, -30*100, 150*100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->voltageMinimum, -1*1000, 6*1000);
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
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
610 static void DataEX_merge_DeviceData_and_store(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 uint16_t dataLengthRead;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 SDevice DeviceDataFlash;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 SDevice *DeviceData = stateDeviceGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 dataLengthRead = ext_flash_read_devicedata((uint8_t *)&DeviceDataFlash,sizeof(SDevice));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 if(dataLengthRead == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 ext_flash_write_devicedata();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 /* max values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 if(DeviceData->batteryChargeCompleteCycles.value_int32 < DeviceDataFlash.batteryChargeCompleteCycles.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 DataEX_helper_copy_deviceData(&DeviceData->batteryChargeCompleteCycles, &DeviceDataFlash.batteryChargeCompleteCycles);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 if(DeviceData->batteryChargeCycles.value_int32 < DeviceDataFlash.batteryChargeCycles.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 DataEX_helper_copy_deviceData(&DeviceData->batteryChargeCycles, &DeviceDataFlash.batteryChargeCycles);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 if(DeviceData->temperatureMaximum.value_int32 < DeviceDataFlash.temperatureMaximum.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 DataEX_helper_copy_deviceData(&DeviceData->temperatureMaximum, &DeviceDataFlash.temperatureMaximum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 if(DeviceData->depthMaximum.value_int32 < DeviceDataFlash.depthMaximum.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 DataEX_helper_copy_deviceData(&DeviceData->depthMaximum, &DeviceDataFlash.depthMaximum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 if(DeviceData->diveCycles.value_int32 < DeviceDataFlash.diveCycles.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 DataEX_helper_copy_deviceData(&DeviceData->diveCycles, &DeviceDataFlash.diveCycles);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 /* min values */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 if(DeviceData->temperatureMinimum.value_int32 > DeviceDataFlash.temperatureMinimum.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 DataEX_helper_copy_deviceData(&DeviceData->temperatureMinimum, &DeviceDataFlash.temperatureMinimum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 // Voltage minimum, keep limit to 2.0 Volt; hw 09.09.2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 if(DeviceData->voltageMinimum.value_int32 > DeviceDataFlash.voltageMinimum.value_int32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 if(DeviceDataFlash.voltageMinimum.value_int32 > 2000) // do not copy back 2000 and below
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 DataEX_helper_copy_deviceData(&DeviceData->voltageMinimum, &DeviceDataFlash.voltageMinimum);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 if(DeviceData->voltageMinimum.value_int32 < 2000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 DeviceData->voltageMinimum.value_int32 = 2000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 DataEX_check_DeviceData ();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 ext_flash_write_devicedata();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
665 static void DataEX_copy_to_DeviceData(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 SDevice * pDeviceState = stateDeviceGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 memcpy(pDeviceState, &dataInDevice->DeviceData[dataInDevice->boolDeviceData], sizeof(SDevice));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
674 static void DataEX_copy_to_VpmRepetitiveData(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 SVpmRepetitiveData * pVpmState = stateVpmRepetitiveDataGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 if(dataInDevice->boolVpmRepetitiveDataValid)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 memcpy(pVpmState, &dataInDevice->VpmRepetitiveData, sizeof(SVpmRepetitiveData));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 pVpmState->is_data_from_RTE_CPU = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 void DataEX_control_connection_while_asking_for_sleep(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 if(!DataEX_check_header_and_footer_ok())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 if(DataEX_check_header_and_footer_devicedata())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 data_old__lost_connection_to_slave_counter_retry = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 data_old__lost_connection_to_slave_counter_temp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 stateRealGetPointerWrite()->data_old__lost_connection_to_slave = 0;
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
696 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 stateRealGetPointerWrite()->data_old__lost_connection_to_slave = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 data_old__lost_connection_to_slave_counter_temp += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 data_old__lost_connection_to_slave_counter_total += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706
173
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
707 #define AVERAGE_COUNT 4
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
708 static float getSampleDepth(SDataExchangeSlaveToMaster *d, SDiveState *ds)
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
709 {
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
710 static uint8_t c = 0;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
711 static float ambient[AVERAGE_COUNT] = {0};
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
712 static float surface[AVERAGE_COUNT]= {0};
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
713 static float depth[AVERAGE_COUNT]= {0};
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
714
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
715 ambient[c] = d->data[d->boolPressureData].pressure_mbar / 1000.0f;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
716 surface[c] = d->data[d->boolPressureData].surface_mbar / 1000.0f;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
717 float density = ((float)( 100 + settingsGetPointer()->salinity)) / 100.0f;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
718
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
719 ds->lifeData.pressure_ambient_bar = (ambient[0] + ambient[1] + ambient[2] + ambient[3])/4.0f;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
720 ds->lifeData.pressure_surface_bar = (surface[0] + surface[1] + surface[2] + surface[3])/4.0f;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
721 depth[c] = (ambient[c] - surface[c]) / (0.09807f * density);
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
722
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
723 c++;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
724 if (c == AVERAGE_COUNT) c = 0;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
725
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
726 return (depth[0] + depth[1] + depth[2] + depth[3])/4.0f;
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
727 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728
189
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
729 #define TEMP_AVERAGE_COUNT 3
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
730 static float getTemperature(SDataExchangeSlaveToMaster *d)
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
731 {
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
732 static uint8_t c = 0;
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
733 static float temp[TEMP_AVERAGE_COUNT] = {0};
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
734
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
735 temp[c] = d->data[d->boolPressureData].temperature;
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
736
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
737 c++;
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
738 if (c == TEMP_AVERAGE_COUNT) c = 0;
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
739
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
740 return (temp[0] + temp[1] + temp[2])/3.0f;
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
741 }
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
742
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 {
173
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
745 SDiveState *pStateReal = stateRealGetPointerWrite();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 static uint16_t getDeviceDataAfterStartOfMainCPU = 20;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 /* internal sensor: HUD data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 for(int i=0;i<3;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 pStateReal->lifeData.ppO2Sensor_bar[i] = get_ppO2Sensor_bar(i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 pStateReal->lifeData.sensorVoltage_mV[i] = get_sensorVoltage_mV(i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 pStateReal->lifeData.HUD_battery_voltage_V = get_HUD_battery_voltage_V();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 // wireless - �ltere daten aufr�umen
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
759 for(int i=0;i<(2*NUM_GASES+1);i++)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 if(pStateReal->lifeData.bottle_bar[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 if((pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] == 0) || (pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] > 60000))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 pStateReal->lifeData.bottle_bar[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] += 100;
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 if(!DataEX_check_header_and_footer_ok())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 if(DataEX_check_header_and_footer_devicedata())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 DataEX_copy_to_DeviceData();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 DataEX_merge_DeviceData_and_store();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 DataEX_copy_to_VpmRepetitiveData();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 data_old__lost_connection_to_slave_counter_temp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 data_old__lost_connection_to_slave_counter_retry = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 pStateReal->data_old__lost_connection_to_slave = 0;
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
783 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 pStateReal->data_old__lost_connection_to_slave = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 data_old__lost_connection_to_slave_counter_temp += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 data_old__lost_connection_to_slave_counter_total += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 }
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
793 else /* RX data OK */
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
794 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
795 data_old__lost_connection_to_slave_counter_temp = 0;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
796 data_old__lost_connection_to_slave_counter_retry = 0;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
797 pStateReal->data_old__lost_connection_to_slave = 0;
208
9fc06e1e0f66 Update SPI error display and handling
ideenmodellierer
parents: 198
diff changeset
798 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK;
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
799 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 if(getDeviceDataAfterStartOfMainCPU)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 getDeviceDataAfterStartOfMainCPU--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 if(getDeviceDataAfterStartOfMainCPU == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 dataOut.getDeviceDataNow = 1;
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
807 getDeviceDataAfterStartOfMainCPU = 10*60*10; /* * 100ms = 60 second => update device data every 10 minutes */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 /* new 151207 hw */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 if(requestNecessary.uw != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 requestNecessary.ub.button = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 if(requestNecessary.ub.button == 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 requestNecessary.uw = 0; // clear all
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825
173
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
826 float meter = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 SSettings *pSettings;
149
e1d66bc78f9a Eliminate warnings
Ideenmodellierer
parents: 141
diff changeset
828
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 /* uint8_t IAmStolenPleaseKillMe;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 */
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
831 pSettings = settingsGetPointer();
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
832
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
833 if(pSettings->IAmStolenPleaseKillMe > 3)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 pSettings->salinity = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 dataIn.data[dataIn.boolPressureData].surface_mbar = 999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 dataIn.data[dataIn.boolPressureData].pressure_mbar = 98971;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 dataIn.mode = MODE_DIVE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
841 if(pStateReal->data_old__lost_connection_to_slave == 0)
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
842 {
173
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
843 meter = getSampleDepth(&dataIn, pStateReal);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
845 pStateReal->pressure_uTick_old = pStateReal->pressure_uTick_new;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
846 pStateReal->pressure_uTick_new = dataIn.data[dataIn.boolPressureData].pressure_uTick;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
847 pStateReal->pressure_uTick_local_new = HAL_GetTick();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
849 pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
850 pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
851 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 dataOut.setAccidentFlag = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
854 if(pStateReal->data_old__lost_connection_to_slave == 0)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 {
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
856 //Start of diveMode?
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
857 if(pStateReal->mode != MODE_DIVE && dataIn.mode == MODE_DIVE)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
858 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
859 if(modeChangeFlag)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
860 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
861 *modeChangeFlag = 1;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
862 }
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
863 if(stateUsed == stateSimGetPointer())
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 simulation_exit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 }
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
867 // new 170508
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 settingsGetPointer()->bluetoothActive = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 MX_Bluetooth_PowerOff();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 //Init dive Mode
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
871 decoLock = DECO_CALC_init_as_is_start_of_dive;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
872 pStateReal->lifeData.boolResetAverageDepth = 1;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
873 pStateReal->lifeData.boolResetStopwatch = 1;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 }
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
875
197
c853f5d23bb7 cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents: 189
diff changeset
876 pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns;
c853f5d23bb7 cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents: 189
diff changeset
877 pStateReal->lifeData.otu = dataIn.data[dataIn.boolToxicData].otu;
c853f5d23bb7 cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents: 189
diff changeset
878 pStateReal->lifeData.no_fly_time_minutes = dataIn.data[dataIn.boolToxicData].no_fly_time_minutes;
c853f5d23bb7 cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents: 189
diff changeset
879 pStateReal->lifeData.desaturation_time_minutes = dataIn.data[dataIn.boolToxicData].desaturation_time_minutes;
c853f5d23bb7 cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents: 189
diff changeset
880
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
881 //End of diveMode?
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
882 if(pStateReal->mode == MODE_DIVE && dataIn.mode != MODE_DIVE)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
883 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
884 if(modeChangeFlag)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
885 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
886 *modeChangeFlag = 1;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
887 }
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
888 createDiveSettings();
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
890 if(pStateReal->warnings.cnsHigh)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
891 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
892 if(pStateReal->lifeData.cns >= 130)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
893 dataOut.setAccidentFlag += ACCIDENT_CNSLVL2;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
894 else if(pStateReal->lifeData.cns >= 100)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
895 dataOut.setAccidentFlag += ACCIDENT_CNS;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
896 }
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
897 if(pStateReal->warnings.decoMissed)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
898 dataOut.setAccidentFlag += ACCIDENT_DECOSTOP;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
899 }
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
900 pStateReal->mode = dataIn.mode;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
901 pStateReal->chargeStatus = dataIn.chargeStatus;
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
902
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
903 if(is_ambient_pressure_close_to_surface(&pStateReal->lifeData))
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
904 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
905 pStateReal->lifeData.depth_meter = 0;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
906 }
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
907 else
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
908 {
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
909 pStateReal->lifeData.depth_meter = meter;
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
910 }
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
911
189
8b8074080d7b Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents: 173
diff changeset
912 pStateReal->lifeData.temperature_celsius = getTemperature(&dataIn);
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
913 pStateReal->lifeData.ascent_rate_meter_per_min = dataIn.data[dataIn.boolPressureData].ascent_rate_meter_per_min;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
914 if(pStateReal->mode != MODE_DIVE)
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
915 pStateReal->lifeData.max_depth_meter = 0;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
916 else
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
917 {
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
918 if(meter > pStateReal->lifeData.max_depth_meter)
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
919 pStateReal->lifeData.max_depth_meter = meter;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
920 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
922 if(dataIn.accidentFlags & ACCIDENT_DECOSTOP)
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
923 pStateReal->decoMissed_at_the_end_of_dive = 1;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
924 if(dataIn.accidentFlags & ACCIDENT_CNS)
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
925 pStateReal->cnsHigh_at_the_end_of_dive = 1;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
926
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
927 pStateReal->lifeData.dive_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].divetime_seconds;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
928 pStateReal->lifeData.dive_time_seconds_without_surface_time = (int32_t)dataIn.data[dataIn.boolTimeData].dive_time_seconds_without_surface_time;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
929 pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
930 pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
932 pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
933 if(settingsGetPointer()->FlipDisplay) /* consider that diver is targeting into the opposite direction */
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
934 {
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
935 pStateReal->lifeData.compass_heading -= 180.0;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
936 if (pStateReal->lifeData.compass_heading < 0) pStateReal->lifeData.compass_heading +=360.0;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
937 }
109
65a6e352ce08 Consider computer heading in case of a flipped display
Ideenmodellierer
parents: 51
diff changeset
938
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
939 pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
940 pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
942 pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
943 pStateReal->lifeData.compass_DY_f = dataIn.data[dataIn.boolCompassData].compass_DY_f;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
944 pStateReal->lifeData.compass_DZ_f = dataIn.data[dataIn.boolCompassData].compass_DZ_f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
946 pStateReal->compass_uTick_old = pStateReal->compass_uTick_new;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
947 pStateReal->compass_uTick_new = dataIn.data[dataIn.boolCompassData].compass_uTick;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
948 pStateReal->compass_uTick_local_new = HAL_GetTick();
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
949
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
950 memcpy(pStateReal->lifeData.tissue_nitrogen_bar, dataIn.data[dataIn.boolTisssueData].tissue_nitrogen_bar,sizeof(pStateReal->lifeData.tissue_nitrogen_bar));
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
951 memcpy(pStateReal->lifeData.tissue_helium_bar, dataIn.data[dataIn.boolTisssueData].tissue_helium_bar,sizeof(pStateReal->lifeData.tissue_helium_bar));
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
952
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
953 if(pStateReal->mode == MODE_DIVE)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 {
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
955 for(int i= 0; i <16; i++)
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
956 {
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
957 pStateReal->vpm.max_crushing_pressure_he[i] = dataIn.data[dataIn.boolCrushingData].max_crushing_pressure_he[i];
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
958 pStateReal->vpm.max_crushing_pressure_n2[i] = dataIn.data[dataIn.boolCrushingData].max_crushing_pressure_n2[i];
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
959 pStateReal->vpm.adjusted_critical_radius_he[i] = dataIn.data[dataIn.boolCrushingData].adjusted_critical_radius_he[i];
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
960 pStateReal->vpm.adjusted_critical_radius_n2[i] = dataIn.data[dataIn.boolCrushingData].adjusted_critical_radius_n2[i];
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
961 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
964 /* battery and ambient light sensors
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
965 */
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
966 pStateReal->lifeData.ambient_light_level = dataIn.data[dataIn.boolAmbientLightData].ambient_light_level;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
967 pStateReal->lifeData.battery_charge = dataIn.data[dataIn.boolBatteryData].battery_charge;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
968 pStateReal->lifeData.battery_voltage = dataIn.data[dataIn.boolBatteryData].battery_voltage;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
969 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 /* apnea specials
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 if(pStateReal->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 pStateReal->lifeData.apnea_total_max_depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 pStateReal->lifeData.apnea_last_dive_time_seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 pStateReal->lifeData.apnea_last_max_depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 if(pStateReal->lifeData.max_depth_meter > pStateReal->lifeData.apnea_total_max_depth_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 pStateReal->lifeData.apnea_total_max_depth_meter = pStateReal->lifeData.max_depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 if(pStateReal->lifeData.dive_time_seconds > 15)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 pStateReal->lifeData.apnea_last_dive_time_seconds = pStateReal->lifeData.dive_time_seconds;
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 if(pStateReal->lifeData.counterSecondsShallowDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 if(pStateReal->lifeData.max_depth_meter > 1.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 pStateReal->lifeData.apnea_last_max_depth_meter = pStateReal->lifeData.max_depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997 }
173
05c770dc2911 Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents: 156
diff changeset
998 // reset max_depth_meter, average_depth_meter and internal values
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 pStateReal->lifeData.max_depth_meter = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 pStateReal->lifeData.boolResetAverageDepth = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 pStateReal->lifeData.boolResetStopwatch = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 /* average depth
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 float *AvgDepthValue = &pStateReal->lifeData.average_depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 float DepthNow = pStateReal->lifeData.depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 uint32_t *AvgDepthCount = &pStateReal->lifeData.internal.average_depth_meter_Count;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 uint32_t *AvgDepthTimer = &pStateReal->lifeData.internal.average_depth_last_update_dive_time_seconds_without_surface_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 uint32_t AvgSecondsSinceLast;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 uint32_t DiveTime = pStateReal->lifeData.dive_time_seconds_without_surface_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 if(pStateReal->lifeData.boolResetAverageDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 *AvgDepthValue = DepthNow;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017 *AvgDepthCount = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018 *AvgDepthTimer = DiveTime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019 pStateReal->lifeData.boolResetAverageDepth = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021 else if (DiveTime > *AvgDepthTimer)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 AvgSecondsSinceLast = DiveTime - *AvgDepthTimer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 for(int i=0;i<AvgSecondsSinceLast;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 *AvgDepthValue = (*AvgDepthValue * *AvgDepthCount + DepthNow) / (*AvgDepthCount + 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027 *AvgDepthCount += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 *AvgDepthTimer = DiveTime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031 if(*AvgDepthCount == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 *AvgDepthValue = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 /* stop watch
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037 if(pStateReal->lifeData.boolResetStopwatch)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039 pStateReal->lifeData.internal.stopwatch_start_at_this_dive_time_seconds = pStateReal->lifeData.dive_time_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040 pStateReal->lifeData.boolResetStopwatch = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042 pStateReal->lifeData.stopwatch_seconds = pStateReal->lifeData.dive_time_seconds - pStateReal->lifeData.internal.stopwatch_start_at_this_dive_time_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 /* wireless data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 uint16_t wirelessData[4][3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 for(int i=0;i<4;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 pStateReal->lifeData.wireless_data[i].ageInMilliSeconds = dataIn.data[dataIn.boolWirelessData].wireless_data[i].ageInMilliSeconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 pStateReal->lifeData.wireless_data[i].status = dataIn.data[dataIn.boolWirelessData].wireless_data[i].status;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 pStateReal->lifeData.wireless_data[i].numberOfBytes = dataIn.data[dataIn.boolWirelessData].wireless_data[i].numberOfBytes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 for(int j=0;j<12;j++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 pStateReal->lifeData.wireless_data[i].data[j] = dataIn.data[dataIn.boolWirelessData].wireless_data[i].data[j];
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 // neu 160412
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 for(int i=0;i<4;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 if(pStateReal->lifeData.wireless_data[i].numberOfBytes == 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 wirelessData[i][0] = (pStateReal->lifeData.wireless_data[i].data[0] >> 4) & 0x7F;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 wirelessData[i][1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 wirelessData[i][2] = pStateReal->lifeData.wireless_data[i].ageInMilliSeconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 wirelessData[i][0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068 wirelessData[i][1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 wirelessData[i][2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 // aussortieren doppelte ids, j�ngster datensatz ist relevant
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 for(int i=0;i<3;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 if(wirelessData[i][0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078 for(int j=i+1; j<4; j++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080 if(wirelessData[i][0] == wirelessData[j][0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 if(wirelessData[i][2] > wirelessData[j][2])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 wirelessData[i][0] = wirelessData[j][0];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 wirelessData[i][1] = wirelessData[j][1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 wirelessData[i][2] = wirelessData[j][2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 wirelessData[j][0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 wirelessData[j][1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 wirelessData[j][2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 /* PIC data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 for(int i=0;i<4;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 pStateReal->lifeData.buttonPICdata[i] = dataIn.data[dataIn.boolPICdata].button_setting[i];
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 /* sensorErrors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 pStateReal->sensorErrorsRTE = dataIn.sensorErrors;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 uint8_t DataEX_check_RTE_version__needs_update(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 if(data_old__lost_connection_to_slave_counter_retry > 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 if(stateRealGetPointer()->data_old__lost_connection_to_slave == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117 setActualRTEversion(dataIn.RTE_VERSION_high, dataIn.RTE_VERSION_low);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 if(RTEminimum_required_high() < dataIn.RTE_VERSION_high)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 if((RTEminimum_required_high() == dataIn.RTE_VERSION_high) && (RTEminimum_required_low() <= dataIn.RTE_VERSION_low))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
1135 /* Check if there is an empty frame provided by RTE (all 0) or even no data provided by RTE (all 0xFF)
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1136 * If that is not the case the DMA is somehow not in sync
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1137 */
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
1138 static uint8_t DataEX_check_header_and_footer_shifted()
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1139 {
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1140 uint8_t ret = 1;
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1141 if((dataIn.footer.checkCode[0] == 0x00)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1142 && (dataIn.footer.checkCode[1] == 0x00)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1143 && (dataIn.footer.checkCode[2] == 0x00)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1144 && (dataIn.footer.checkCode[3] == 0x00)) { ret = 0; }
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1145
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1146 if((dataIn.footer.checkCode[0] == 0xff)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1147 && (dataIn.footer.checkCode[1] == 0xff)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1148 && (dataIn.footer.checkCode[2] == 0xff)
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1149 && (dataIn.footer.checkCode[3] == 0xff)) { ret = 0; }
137
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1150
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1151 return ret;
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1152 }
9eda5a75c5fd Only copy data if data connection to RTE is valid
Ideenmodellierer
parents: 133
diff changeset
1153
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
1154 static uint8_t DataEX_check_header_and_footer_ok(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 if(dataIn.header.checkCode[0] != 0xA1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 return 0;
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1158 #if USE_OLD_HEADER_FORMAT
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 if(dataIn.header.checkCode[1] != 0xA2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161 if(dataIn.header.checkCode[2] != 0xA3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 return 0;
141
30d855ea60d8 Only use data if data frame is valid
Ideenmodellierer
parents: 138
diff changeset
1163 #endif
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 if(dataIn.header.checkCode[3] != 0xA4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 if(dataIn.footer.checkCode[0] != 0xE1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 if(dataIn.footer.checkCode[1] != 0xE2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 if(dataIn.footer.checkCode[2] != 0xE3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172 if(dataIn.footer.checkCode[3] != 0xE4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177
198
878dc9e0dbc5 cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents: 197
diff changeset
1178 static uint8_t DataEX_check_header_and_footer_devicedata(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180 if(dataIn.header.checkCode[0] != 0xDF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 if(dataIn.header.checkCode[1] != 0xDE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 if(dataIn.header.checkCode[2] != 0xDD)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 if(dataIn.header.checkCode[3] != 0xDC)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188 if(dataIn.footer.checkCode[0] != 0xE1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190 if(dataIn.footer.checkCode[1] != 0xE2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192 if(dataIn.footer.checkCode[2] != 0xE3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194 if(dataIn.footer.checkCode[3] != 0xE4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1196
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198 }