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