Fix doc path
[opentx.git] / radio / src / storage / storage.h
blob8227878155d2f9b3e87aab5ae1c7223481bd153d
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _STORAGE_H_
22 #define _STORAGE_H_
24 #if defined(SIMU)
25 #define WRITE_DELAY_10MS 100
26 #elif defined(RAMBACKUP)
27 #define WRITE_DELAY_10MS 1500 /* 15s */
28 #elif defined(PCBTARANIS)
29 #define WRITE_DELAY_10MS 500
30 #elif defined(PCBSKY9X) && !defined(REV0)
31 #define WRITE_DELAY_10MS 500
32 #elif defined(PCBGRUVIN9X) && !defined(REV0)
33 #define WRITE_DELAY_10MS 500
34 #else
35 #define WRITE_DELAY_10MS 200
36 #endif
38 extern uint8_t storageDirtyMsk;
39 extern tmr10ms_t storageDirtyTime10ms;
40 #define TIME_TO_WRITE() (storageDirtyMsk && (tmr10ms_t)(get_tmr10ms() - storageDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS)
42 #if defined(RAMBACKUP)
43 extern uint8_t rambackupDirtyMsk;
44 extern tmr10ms_t rambackupDirtyTime10ms;
45 #define TIME_TO_RAMBACKUP() (rambackupDirtyMsk && (tmr10ms_t)(get_tmr10ms() - rambackupDirtyTime10ms) >= (tmr10ms_t)100)
46 #endif
48 void storageEraseAll(bool warn);
49 void storageFormat();
50 void storageReadAll();
51 void storageDirty(uint8_t msk);
52 void storageCheck(bool immediately);
53 void storageFlushCurrentModel();
55 void preModelLoad();
56 void postModelLoad(bool alarms);
58 #if defined(EEPROM_RLC)
59 #include "eeprom_common.h"
60 #include "eeprom_rlc.h"
61 #elif defined(EEPROM)
62 #include "eeprom_common.h"
63 #include "eeprom_raw.h"
64 #elif defined(SDCARD)
65 #include "sdcard_raw.h"
66 #endif
68 #if defined(RAMBACKUP)
69 void rambackupWrite();
70 bool rambackupRestore();
71 unsigned int compress(uint8_t * dst, unsigned int dstsize, const uint8_t * src, unsigned int len);
72 unsigned int uncompress(uint8_t * dst, unsigned int dstsize, const uint8_t * src, unsigned int len);
73 #endif
75 #endif // _STORAGE_H_