EEPROM Library Overview  1.0.0.x
eeprom_emulation_type_a.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file eeprom_emulation_type_a.h
34  * @brief EEPROM Emulation Type A
35  * @defgroup EEPROM_TYPE_A EEPROM Emulation Type A
36  *
37  * @anchor EEPROM_EMULATION_TYPE_A_H__Overview
38  * # Overview
39  *
40  * MSPM0 support EEPROM emulation through its internal Flash. Compared to using
41  * an external serial EEPROM, EEPROM emulation using the internal Flash saves
42  * pin usage and cost.
43  * The EEPROM emulation Type A solution is suitable if the user application
44  * needs to store large "blocks" of data.
45  *
46  * <hr>
47  ******************************************************************************/
51 #ifndef EEPROM_EMULATION_TYPE_A_H_
52 #define EEPROM_EMULATION_TYPE_A_H_
53 
54 #include <stdbool.h>
55 #include <stdint.h>
56 
57 #include <ti/devices/msp/msp.h>
58 #include <ti/driverlib/driverlib.h>
59 #include <ti/driverlib/m0p/dl_core.h>
60 
61 /* clang-format off */
62 
71 #ifndef EEPROM_EMULATION_ADDRESS
72 #define EEPROM_EMULATION_ADDRESS (0x00001000)
73 #endif
74 
77 #define EEPROM_EMULATION_SECTOR_ACCOUNT (2)
78 
81 #define EEPROM_EMULATION_RECORD_SIZE (128)
82 
93 #define EEPROM_EMULATION_DATA_SIZE (EEPROM_EMULATION_RECORD_SIZE - 8)
94 
97 #define EEPROM_EMULATION_RECORD_ACCOUNT (1024 / EEPROM_EMULATION_RECORD_SIZE)
98 
101 #define EEPROM_EMULATION_ACTIVE_RECORD_NUM_MIN (1)
102 
105 #define EEPROM_EMULATION_ACTIVE_RECORD_NUM_MAX \
106  (EEPROM_EMULATION_RECORD_ACCOUNT)
107 
110 #define EEPROM_EMULATION_ACTIVE_SECTOR_NUM_MIN (1)
111 
114 #define EEPROM_EMULATION_ACTIVE_SECTOR_NUM_MAX \
115  (EEPROM_EMULATION_SECTOR_ACCOUNT)
116 
126 #define EEPROM_EMULATION_WRITE_OK ((uint32_t) 0x00000000U)
127 
130 #define EEPROM_EMULATION_WRITE_ERROR ((uint32_t) 0x00000001U)
131 
134 #define EEPROM_EMULATION_FORMAT_ERROR ((uint32_t) 0x00000010U)
135 
138 #define EEPROM_EMULATION_INIT_OK ((uint32_t) 0x00000000U)
139 
142 #define EEPROM_EMULATION_INIT_ERROR ((uint32_t) 0x00000002U)
143 
145 /* clang-format on */
146 
148 extern uint32_t gActiveRecordAddress;
150 extern uint32_t gNextRecordAddress;
152 extern uint16_t gActiveRecordNum;
154 extern uint16_t gActiveSectorNum;
155 
157 extern bool gEEPROMTypeASearchFlag;
159 extern bool gEEPROMTypeAEraseFlag;
161 extern bool gEEPROMTypeAFormatErrorFlag;
162 
183 uint32_t EEPROM_TypeA_writeData(uint32_t *data);
184 
216 uint32_t EEPROM_TypeA_init(uint32_t *data);
217 
227 void EEPROM_TypeA_readData(uint32_t *data);
228 
254 bool EEPROM_TypeA_repairFormat(uint32_t *data);
255 
267 void EEPROM_TypeA_searchCheck(void);
268 
281 
294 
304 
305 #endif /* EEPROM_EMULATION_TYPE_A_H_ */
306 
bool EEPROM_TypeA_eraseLastSector(void)
Erase the previous sector of the active sector.
bool gEEPROMTypeASearchFlag
Indicate when the active record exists.
uint16_t gActiveRecordNum
Store the number of active records.
uint32_t EEPROM_TypeA_writeData(uint32_t *data)
Store provided data to the virtual EEPROM.
bool gEEPROMTypeAEraseFlag
Indicate when the sector is full nad needs to be erased.
bool gEEPROMTypeAFormatErrorFlag
Indicate when a format error is found.
bool EEPROM_TypeA_eraseNonActiveSectors(void)
Erases sectors other than the active sector.
uint32_t gActiveRecordAddress
Store the address of the current active record.
bool EEPROM_TypeA_repairFormat(uint32_t *data)
Repair the format.
bool EEPROM_TypeA_eraseAllSectors(void)
Erase all sectors used by EEPROM emulation.
uint32_t gNextRecordAddress
Store the address of the next active record.
void EEPROM_TypeA_readData(uint32_t *data)
Read the data from active record to the buffer in RAM.
uint16_t gActiveSectorNum
Store the number of active sectors.
uint32_t EEPROM_TypeA_init(uint32_t *data)
Initialize the specified area in flash.
void EEPROM_TypeA_searchCheck(void)
Search the active record and check the format.
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale