SRD Standelone programmation box: MemoryManager.h Source File

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
MemoryManager.h
Go to the documentation of this file.
1 /*############################################################################################*/
2 /*############################################################################################*/
3 /**
4 * \file MemoryManager.h
5 * \author Thibaut LALUQUE 3D-Ouest
6 * \date 24/11/2014
7 * \version 1.0
8 * \brief Headerfile for Memory manager.
9 * \details All Right Reserved.
10 */
11 /*############################################################################################*/
12 /*############################################################################################*/
13 #ifndef __MEMORYMANAGER_H__
14 #define __MEMORYMANAGER_H__
15
16 /*############################################################################################*/
17 /*## INCLUDES ################################################################################*/
18 /*############################################################################################*/
19 #include "FM25V20.h"
20 #include "checksum.h"
21 #include "watchdog.h"
22 #include "SRDMemorymapping.h"
23 #include "Watchdog.h"
24 /*############################################################################################*/
25 /*## END INCLUDES ############################################################################*/
26 /*############################################################################################*/
27
28
29 /*############################################################################################*/
30 /*## DEFINES #################################################################################*/
31 /*############################################################################################*/
32
33 /*----------------------------------------------------------------------------*/
34 /**
35 * \brief Define memory mapping of the log and control structure.
36 */
37 ///@{
38 /*----------------------------------------------------------------------------*/
39 /*=== addr mapping ===*/
40 #define MEMORYMANAGER_ADDR_DIVING_START (31U)
41 #define MEMORYMANAGER_ADDR_DIVING_DEPTH (MEMORYMANAGER_ADDR_DIVING_START + 0)
42 #define MEMORYMANAGER_ADDR_DIVING_FILTER_MSB (MEMORYMANAGER_ADDR_DIVING_START + 1)
43 #define MEMORYMANAGER_ADDR_DIVING_FILTER_LSB (MEMORYMANAGER_ADDR_DIVING_START + 2)
44 #define MEMORYMANAGER_ADDR_DIVING_CHECKSUM (MEMORYMANAGER_ADDR_DIVING_START + 3)
45 #define MEMORYMANAGER_DIVING_BLOCK_SIZE (4U)
46
47
48 #define MEMORYMANAGER_ADDR_SERIAL_START (0U)
49 #define MEMORYMANAGER_ADDR_SERIAL_1 (MEMORYMANAGER_ADDR_SERIAL_START + 0)
50 #define MEMORYMANAGER_ADDR_SERIAL_2 (MEMORYMANAGER_ADDR_SERIAL_START + 1)
51 #define MEMORYMANAGER_ADDR_SERIAL_3 (MEMORYMANAGER_ADDR_SERIAL_START + 2)
52 #define MEMORYMANAGER_ADDR_SERIAL_4 (MEMORYMANAGER_ADDR_SERIAL_START + 3)
53 #define MEMORYMANAGER_ADDR_SERIAL_5 (MEMORYMANAGER_ADDR_SERIAL_START + 4)
54 #define MEMORYMANAGER_ADDR_SERIAL_6 (MEMORYMANAGER_ADDR_SERIAL_START + 5)
55 #define MEMORYMANAGER_ADDR_SERIAL_7 (MEMORYMANAGER_ADDR_SERIAL_START + 6)
56 #define MEMORYMANAGER_ADDR_SERIAL_8 (MEMORYMANAGER_ADDR_SERIAL_START + 7)
57 #define MEMORYMANAGER_ADDR_SERIAL_CHECKSUM (MEMORYMANAGER_ADDR_SERIAL_START + 8)
58 #define MEMORYMANAGER_SERIAL_BLOCK_SIZE (9U)
59
60 #define MEMORYMANAGER_ADDR_LOG_START (64U)
61 #define MEMORYMANAGER_LOG_SIZE (SRD_MEMORY_NBR_BYTE + 8)
62 ///@}
63
64 /*----------------------------------------------------------------------------*/
65 /**
66 * \def MEMORYMANAGER_MAX_NBR_LOG
67 * \brief Define the maximum number of log that we can save in the memory.
68 */
69 /*----------------------------------------------------------------------------*/
70 #define MEMORYMANAGER_MAX_NBR_LOG ( (FM25V20_NBR_BYTE - MEMORYMANAGER_ADDR_LOG_START) / MEMORYMANAGER_LOG_SIZE)
71
72 /*############################################################################################*/
73 /*## END DEFINES #############################################################################*/
74 /*############################################################################################*/
75
76
77
78 /*############################################################################################*/
79 /*## TYPEDEF/STRUCT/ENUM/UNION ###############################################################*/
80 /*############################################################################################*/
81 /*----------------------------------------------------------------------------*/
82 /**
83 * \struct tMemoryManagerDiving
84 * \brief Define a structure used to save the diving parameters.
85 */
86 /*----------------------------------------------------------------------------*/
87 typedef struct {
88 unsigned char depth; /*!< Depth programmed */
89 unsigned char filterMSB; /*!< Filter MSB */
90 unsigned char filterLSB; /*!< Filter LSB */
91 unsigned char checksum; /*!< Checksum of the diving structure */
92 } tMemoryManagerDiving;
93
94 /*----------------------------------------------------------------------------*/
95 /**
96 * \struct tMemoryManagerSerial
97 * \brief Define a structure used to save the serial parameters.
98 */
99 /*----------------------------------------------------------------------------*/
100 typedef struct {
101 unsigned long long serial; /*!< Serial number */
102 unsigned char checksum; /*!< Checksum of the serial structure */
103 } tMemoryManagerSerial;
104
105 /*----------------------------------------------------------------------------*/
106 /**
107 * \enum tMemoryManagerRWOp
108 * \brief Define the log operation (write or read operation).
109 */
110 /*----------------------------------------------------------------------------*/
111 typedef enum {
112 MEMORYMANAGER_WRITE_OPERATION = 0x01, /*!< Write operation */
113 MEMORYMANAGER_READ_OPERATION = 0x02 /*!< Read operation */
114 }tMemoryManagerRWOp;
115
116 /*----------------------------------------------------------------------------*/
117 /**
118 * \struct tMemoryManagerCtrl
119 * \brief Define a structure used to control the memory operation.
120 */
121 /*----------------------------------------------------------------------------*/
122 typedef struct {
123 union {
124 struct {
125 unsigned short serial : 1; /*!< Serial si initialized */
126 unsigned short diving : 1; /*!< Diving parameters are initialized */
127 unsigned short RSVD : 14; /*!< Reserved */
128 }bits; /*!< Bit access */
129 unsigned short all; /*!< Global access */
130 }isValid; /*!< Valid parameters structure */
131 unsigned long nbrLog; /*!< number of log in memory */
132 } tMemoryManagerCtrl;
133
134 /*----------------------------------------------------------------------------*/
135 /**
136 * \struct tMemoryManagerLog
137 * \brief Define a structure used to store a log in memory.
138 */
139 /*----------------------------------------------------------------------------*/
140 typedef struct {
141 unsigned long date; /*!< Date of the log */
142 unsigned long logOp; /*!< Log operation */
143 tSRDEeprom srdData; /*!< SRD data of the log */
144 }tMemoryManagerLog;
145 /*############################################################################################*/
146 /*## END TYPEDEF/STRUCT/ENUM/UNION ###########################################################*/
147 /*############################################################################################*/
148
149
150
151 /*############################################################################################*/
152 /*## VARIABLES ###############################################################################*/
153 /*############################################################################################*/
154
155 /*----------------------------------------------------------------------------*/
156 /**
157 * \var MemoryManagerCtrl
158 * \brief Variable used to control the memory manager.
159 */
160 /*----------------------------------------------------------------------------*/
161 extern tMemoryManagerCtrl MemoryManagerCtrl;
162
163 /*----------------------------------------------------------------------------*/
164 /**
165 * \var DivingParameters
166 * \brief Variable used to control the diving parameters.
167 */
168 /*----------------------------------------------------------------------------*/
169 extern tMemoryManagerDiving DivingParameters;
170
171 /*----------------------------------------------------------------------------*/
172 /**
173 * \var SerialParameters
174 * \brief Variable used to control the serial parameters.
175 */
176 /*----------------------------------------------------------------------------*/
177 extern tMemoryManagerSerial SerialParameters;
178 /*############################################################################################*/
179 /*## END VARIABLES ###########################################################################*/
180 /*############################################################################################*/
181
182
183
184 /*############################################################################################*/
185 /*## DECLARATION FONCTIONS ###################################################################*/
186 /*############################################################################################*/
187 /*----------------------------------------------------------------------------*/
188 /**
189 * \fn void MemoryManagerInit (void)
190 * \brief function use to initialize the memory manager.
191 */
192 /*----------------------------------------------------------------------------*/
193 extern void MemoryManagerInit (void);
194
195 /*----------------------------------------------------------------------------*/
196 /**
197 * \brief function used read/write and check the diving parameters in the memory.
198 */
199 ///@{
200 /*----------------------------------------------------------------------------*/
201 extern signed short MemoryManagerReadDiving (tMemoryManagerDiving* divingParameters);
202 extern void MemoryManagerCheckDiving (tMemoryManagerDiving* divingParameters);
203 extern signed short MemoryManagerWriteDiving (tMemoryManagerDiving* divingParameters);
204 ///@}
205
206 /*----------------------------------------------------------------------------*/
207 /**
208 * \brief function used read/write and check the serial parameters in the memory.
209 */
210 ///@{
211 /*----------------------------------------------------------------------------*/
212 extern signed short MemoryManagerReadSerial (tMemoryManagerSerial* serialParameters);
213 extern void MemoryManagerCheckSerial (tMemoryManagerSerial* serialParameters);
214 extern signed short MemoryManagerWriteSerial (tMemoryManagerSerial* serialParameters);
215 ///@}
216
217 /*----------------------------------------------------------------------------*/
218 /**
219 * \brief function used read/write and check the log in the memory.
220 */
221 ///@{
222 /*----------------------------------------------------------------------------*/
223 extern signed short MemoryManagerWriteLog(unsigned long date, tMemoryManagerRWOp opType, tSRDEeprom* data);
224 extern signed short MemoryManagerClearLog(void);
225 extern signed short MemoryManagerReadLog(unsigned short addr, tMemoryManagerLog* data);
226 ///@}
227
228 /*----------------------------------------------------------------------------*/
229 /**
230 * \fn signed short MemoryManagerComputeNbrLog (void)
231 * \brief Return the number of log stored in memory.
232 * \return (signed short) : Return the number of log in the memory.
233 */
234 /*----------------------------------------------------------------------------*/
235 extern signed short MemoryManagerComputeNbrLog (void);
236 /*############################################################################################*/
237 /*## END DECLARATION FONCTIONS ###############################################################*/
238 /*############################################################################################*/
239 #endif
tMemoryManagerLog::srdData
tSRDEeprom srdData
Definition: MemoryManager.h:143
tMemoryManagerSerial
Define a structure used to save the serial parameters.
Definition: MemoryManager.h:100
tMemoryManagerDiving::checksum
unsigned char checksum
Definition: MemoryManager.h:91
SerialParameters
tMemoryManagerSerial SerialParameters
Variable used to control the serial parameters.
Definition: MemoryManager.c:55
tMemoryManagerSerial::checksum
unsigned char checksum
Definition: MemoryManager.h:102
tMemoryManagerDiving::filterLSB
unsigned char filterLSB
Definition: MemoryManager.h:90
MemoryManagerCtrl
tMemoryManagerCtrl MemoryManagerCtrl
Variable used to control the memory manager.
Definition: MemoryManager.c:53
MemoryManagerClearLog
signed short MemoryManagerClearLog(void)
function used read/write and check the log in the memory.
Definition: MemoryManager.c:280
MemoryManagerReadSerial
signed short MemoryManagerReadSerial(tMemoryManagerSerial *serialParameters)
function used read/write and check the serial parameters in the memory.
Definition: MemoryManager.c:168
MemoryManagerReadDiving
signed short MemoryManagerReadDiving(tMemoryManagerDiving *divingParameters)
function used read/write and check the diving parameters in the memory.
Definition: MemoryManager.c:103
watchdog.h
Headerfile for watchdog driver.
MemoryManagerCheckDiving
void MemoryManagerCheckDiving(tMemoryManagerDiving *divingParameters)
function used read/write and check the diving parameters in the memory.
Definition: MemoryManager.c:128
MemoryManagerCheckSerial
void MemoryManagerCheckSerial(tMemoryManagerSerial *serialParameters)
function used read/write and check the serial parameters in the memory.
Definition: MemoryManager.c:193
tMemoryManagerLog
Define a structure used to store a log in memory.
Definition: MemoryManager.h:140
MemoryManagerWriteDiving
signed short MemoryManagerWriteDiving(tMemoryManagerDiving *divingParameters)
function used read/write and check the diving parameters in the memory.
Definition: MemoryManager.c:139
MemoryManagerWriteLog
signed short MemoryManagerWriteLog(unsigned long date, tMemoryManagerRWOp opType, tSRDEeprom *data)
function used read/write and check the log in the memory.
Definition: MemoryManager.c:233
tMemoryManagerCtrl
Define a structure used to control the memory operation.
Definition: MemoryManager.h:122
tMemoryManagerRWOp
tMemoryManagerRWOp
Define the log operation (write or read operation).
Definition: MemoryManager.h:111
tMemoryManagerLog::logOp
unsigned long logOp
Definition: MemoryManager.h:142
tMemoryManagerDiving::depth
unsigned char depth
Definition: MemoryManager.h:88
SRDMemoryMapping.h
Headerfile for SRD Memory Mapping.
tMemoryManagerCtrl::nbrLog
unsigned long nbrLog
Definition: MemoryManager.h:131
DivingParameters
tMemoryManagerDiving DivingParameters
Variable used to control the diving parameters.
Definition: MemoryManager.c:54
tSRDEeprom
Structure used to represent and store SRD RFID memory.
Definition: SRDMemoryMapping.h:130
MemoryManagerReadLog
signed short MemoryManagerReadLog(unsigned short addr, tMemoryManagerLog *data)
function used read/write and check the log in the memory.
Definition: MemoryManager.c:350
tMemoryManagerDiving
Define a structure used to save the diving parameters.
Definition: MemoryManager.h:87
FM25V20.h
Headerfile for FRAM FM25V20 driver.
MEMORYMANAGER_READ_OPERATION
Definition: MemoryManager.h:113
tMemoryManagerDiving::filterMSB
unsigned char filterMSB
Definition: MemoryManager.h:89
MemoryManagerWriteSerial
signed short MemoryManagerWriteSerial(tMemoryManagerSerial *serialParameters)
function used read/write and check the serial parameters in the memory.
Definition: MemoryManager.c:204
tMemoryManagerLog::date
unsigned long date
Definition: MemoryManager.h:141
checksum.h
Headerfile for checksum computation.
tMemoryManagerSerial::serial
unsigned long long serial
Definition: MemoryManager.h:101
MemoryManagerComputeNbrLog
signed short MemoryManagerComputeNbrLog(void)
Return the number of log stored in memory.
Definition: MemoryManager.c:316
MemoryManagerInit
void MemoryManagerInit(void)
function use to initialize the memory manager.
Definition: MemoryManager.c:73
MEMORYMANAGER_WRITE_OPERATION
Definition: MemoryManager.h:112
tMemoryManagerCtrl::all
unsigned short all
Definition: MemoryManager.h:129