annotate Discovery/Inc/externLogbookFlash.h @ 428:0e5341951079 ImprovmentNVM_2

Activated ringbuffer for settings: Updated Headerfile with new parameter
author ideenmodellierer
date Mon, 17 Feb 2020 19:04:10 +0100
parents 86fcac4cc43a
children 1c0b911c367f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Inc/externLogbookFlash.h
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief Header File to access the new 1.8 Volt Spansion S25FS256S 256 Mbit (32 Mbyte)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 07-Aug-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 /* Define to prevent recursive inclusion -------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 #ifndef EXTERN_LOGBOOK_FLASH_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 #define EXTERN_LOGBOOK_FLASH_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "logbook.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 /* Exported variables --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 /* 4 KB
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 * one for the basics like min./max. temperature, max. depth, charge cycles
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 * after that two or more 0for settings (less than one necessary as of 26. March 2015)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 #define DDSTART 0x00000000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 #define DDSTOP 0x00000FFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 #define unused1START 0x00001000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 #define unused1STOP 0x00007FFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 /* 32 KB */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 #define unused2START 0x00008000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 #define unused2STOP 0x0000FFFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 /* 64 KB
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 * 001x used for settings
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 * 001x used for VPM
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * 005x unused
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 * 008x for header (0.5 MB)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 * 192x for samples (12 MB)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 * 016x for firmware ( 1 MB)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 * 032x for firmware2 ( 2 MB)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 #define SETTINGSSTART 0x00010000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 #define SETTINGSSTOP 0x0001FFFF
425
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
62 #define VPMSTART 0x00020000
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
63 #define VPMSTOP 0x0002FFFF
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 #define unused3START 0x00030000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 #define unused3STOP 0x0007FFFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 #define HEADERSTART 0x00080000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 #define HEADERSTOP 0x000FFFFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 #define SAMPLESTART 0x00100000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 #define SAMPLESTOP 0x00CFFFFF
425
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
70 #define FWSTART 0x00D00000
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
71 #define FWSTOP 0x00DFFFFF
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
72 #define FWSTART2 0x00E00000
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
73 #define FWSTOP2 0x00FFFFFF
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 /* 16 MB with 4 Byte addressing */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 #define unused4START 0x01000000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 #define unused4STOP 0x01FFFFFF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 #define HEADERSIZE sizeof(SLogbookHeader)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 #define HEADERSIZEOSTC3 sizeof(SLogbookHeaderOSTC3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80
425
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
81 /* Sample ring buffer sector states derived from the usage at begin and end of a sector */
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
82 #define SECTOR_CLOSED (0)
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
83 #define SECTOR_NOTUSED (1)
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
84 #define SECTOR_INUSE (4)
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
85 #define SECTOR_EMPTY (5)
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
86
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 /* Exported types ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 typedef struct{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 uint8_t byteLow;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 uint8_t byteMidLow;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 uint8_t byteMidHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 uint8_t byteHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 } addressToByte_t;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 typedef struct{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 uint8_t byteLow;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 uint8_t byteHigh;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 } WordToByte_t;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 typedef union{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 addressToByte_t u8bit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 uint32_t u32bit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 } convert_Type;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 typedef union{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 WordToByte_t u8bit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 uint16_t u16bit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 } convert16_Type;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 /* Exported functions --------------------------------------------------------*/
428
0e5341951079 Activated ringbuffer for settings:
ideenmodellierer
parents: 425
diff changeset
111 void ext_flash_write_settings(uint8_t resetRing);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 uint8_t ext_flash_read_settings(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113
421
3f7d80f37bfc Enable sequentionel writing of device data:
ideenmodellierer
parents: 268
diff changeset
114 void ext_flash_write_devicedata(uint8_t resetRing);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 uint16_t ext_flash_read_devicedata(uint8_t *buffer, uint16_t max_length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 void ext_flash_read_fixed_16_devicedata_blocks_formated_128byte_total(uint8_t *buffer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 #ifndef BOOTLOADER_STANDALONE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 void ext_flash_write_vpm(SVpm *vpmInput);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 int ext_flash_read_vpm(SVpm *vpmOutput);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 void ext_flash_start_new_dive_log_and_set_actualPointerSample(uint8_t *pHeaderPreDive);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 void ext_flash_create_new_dive_log(uint8_t *pHeaderPreDive);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 void ext_flash_close_new_dive_log(uint8_t *pHeaderPostDive);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 void ext_flash_write_sample(uint8_t *pSample, uint16_t length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 uint8_t ext_flash_count_dive_headers(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 void ext_flash_read_dive_header(uint8_t *pHeaderToFill, uint8_t StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 void ext_flash_read_dive_header2(uint8_t *pHeaderToFill, uint8_t id, _Bool bOffset);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 void ext_flash_open_read_sample(uint8_t StepBackwards, uint32_t *totalNumberOfBytes);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 void ext_flash_read_next_sample_part(uint8_t *pSample, uint8_t length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 void ext_flash_close_read_sample(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 void ext_flash_set_entry_point(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 void ext_flash_reopen_read_sample_at_entry_point(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 void ext_flash_write_dive_raw_with_double_header_1K(uint8_t *data, uint32_t length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 uint32_t ext_flash_read_dive_raw_with_double_header_1K(uint8_t *data, uint32_t max_size, uint8_t StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 void ext_flash_read_header_memory(uint8_t *data);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 void ext_flash_write_header_memory(uint8_t *data);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 void ext_flash_erase_logbook(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 void ext_flash_erase_chip(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 void ext_flash_erase_firmware(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 void ext_flash_erase_firmware2(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 void ext_flash_disable_protection_for_logbook(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 void ext_flash_enable_protection(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 void ext_flash_read_block_start(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 void ext_flash_repair_dive_log(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 uint8_t ext_flash_erase_firmware_if_not_empty(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 uint8_t ext_flash_erase_firmware2_if_not_empty(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 void ext_flash_write_firmware(uint8_t *pSample1, uint32_t length1);//,uint8_t *pSample2, uint32_t length2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 uint32_t ext_flash_read_firmware(uint8_t *pSample1, uint32_t max_length, uint8_t *magicByte);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 uint8_t ext_flash_read_firmware_version(char *text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 void ext_flash_write_firmware2(uint32_t offset, uint8_t *pSample1, uint32_t length1,uint8_t *pSample2, uint32_t length2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 uint32_t ext_flash_read_firmware2(uint32_t *offset, uint8_t *pSample1, uint32_t max_length1, uint8_t *pSample2, uint32_t max_length2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 uint16_t ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(uint16_t startCount);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
425
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
166 uint32_t ext_flash_AnalyseSampleBuffer(char *pstrResult);
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
167 void ext_flash_CloseSector(void);
86fcac4cc43a Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents: 421
diff changeset
168
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 #endif /* EXTERN_LOGBOOK_FLASH_H */