MSP430 DriverLib for MSP430F5xx_6xx Devices  2.91.13.01
flashctl.h
1 //*****************************************************************************
2 //
3 // flashctl.h - Driver for the FLASHCTL Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_FLASHCTL_H__
8 #define __MSP430WARE_FLASHCTL_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_FLASH__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 //*****************************************************************************
26 //
27 // The following are values that can be passed to the mask parameter for
28 // functions: FlashCtl_getStatus() as well as returned by the
29 // FlashCtl_getStatus() function.
30 //
31 //*****************************************************************************
32 #define FLASHCTL_READY_FOR_NEXT_WRITE WAIT
33 #define FLASHCTL_ACCESS_VIOLATION_INTERRUPT_FLAG ACCVIFG
34 #define FLASHCTL_PASSWORD_WRITTEN_INCORRECTLY KEYV
35 #define FLASHCTL_BUSY BUSY
36 
37 //*****************************************************************************
38 //
39 // Prototypes for the APIs.
40 //
41 //*****************************************************************************
42 
43 //*****************************************************************************
44 //
45 //! \brief Erase a single segment of the flash memory.
46 //!
47 //! For devices like MSP430i204x, if the specified segment is the information
48 //! flash segment, the FLASH_unlockInfo API must be called prior to calling
49 //! this API.
50 //!
51 //! \param flash_ptr is the pointer into the flash segment to be erased
52 //!
53 //! \return None
54 //
55 //*****************************************************************************
56 extern void FlashCtl_eraseSegment(uint8_t *flash_ptr);
57 
58 //*****************************************************************************
59 //
60 //! \brief Erase a single bank of the flash memory.
61 //!
62 //! This function erases a single bank of the flash memory. This API will
63 //! erase the entire flash if device contains only one flash bank.
64 //!
65 //! \param flash_ptr is a pointer into the bank to be erased
66 //!
67 //! \return None
68 //
69 //*****************************************************************************
70 extern void FlashCtl_eraseBank(uint8_t *flash_ptr);
71 
72 //*****************************************************************************
73 //
74 //! \brief Erase all flash memory.
75 //!
76 //! This function erases all the flash memory banks. For devices like
77 //! MSP430i204x, this API erases main memory and information flash memory if
78 //! the FLASH_unlockInfo API was previously executed (otherwise the information
79 //! flash is not erased). Also note that erasing information flash memory in
80 //! the MSP430i204x impacts the TLV calibration constants located at the
81 //! information memory.
82 //!
83 //! \param flash_ptr is a pointer into the bank to be erased
84 //!
85 //! \return None
86 //
87 //*****************************************************************************
88 extern void FlashCtl_performMassErase(uint8_t *flash_ptr);
89 
90 //*****************************************************************************
91 //
92 //! \brief Erase check of the flash memory
93 //!
94 //! This function checks bytes in flash memory to make sure that they are in an
95 //! erased state (are set to 0xFF).
96 //!
97 //! \param flash_ptr is the pointer to the starting location of the erase check
98 //! \param numberOfBytes is the number of bytes to be checked
99 //!
100 //! \return STATUS_SUCCESS or STATUS_FAIL
101 //
102 //*****************************************************************************
103 extern bool FlashCtl_performEraseCheck(uint8_t *flash_ptr,
104  uint16_t numberOfBytes);
105 
106 //*****************************************************************************
107 //
108 //! \brief Write data into the flash memory in byte format, pass by reference
109 //!
110 //! This function writes a byte array of size count into flash memory. Assumes
111 //! the flash memory is already erased and unlocked. FlashCtl_eraseSegment can
112 //! be used to erase a segment.
113 //!
114 //! \param data_ptr is the pointer to the data to be written
115 //! \param flash_ptr is the pointer into which to write the data
116 //! \param count number of times to write the value
117 //!
118 //! \return None
119 //
120 //*****************************************************************************
121 extern void FlashCtl_write8(uint8_t *data_ptr,
122  uint8_t *flash_ptr,
123  uint16_t count);
124 
125 //*****************************************************************************
126 //
127 //! \brief Write data into the flash memory in 16-bit word format, pass by
128 //! reference
129 //!
130 //! This function writes a 16-bit word array of size count into flash memory.
131 //! Assumes the flash memory is already erased and unlocked.
132 //! FlashCtl_eraseSegment can be used to erase a segment.
133 //!
134 //! \param data_ptr is the pointer to the data to be written
135 //! \param flash_ptr is the pointer into which to write the data
136 //! \param count number of times to write the value
137 //!
138 //! \return None
139 //
140 //*****************************************************************************
141 extern void FlashCtl_write16(uint16_t *data_ptr,
142  uint16_t *flash_ptr,
143  uint16_t count);
144 
145 //*****************************************************************************
146 //
147 //! \brief Write data into the flash memory in 32-bit word format, pass by
148 //! reference
149 //!
150 //! This function writes a 32-bit array of size count into flash memory.
151 //! Assumes the flash memory is already erased and unlocked.
152 //! FlashCtl_eraseSegment can be used to erase a segment.
153 //!
154 //! \param data_ptr is the pointer to the data to be written
155 //! \param flash_ptr is the pointer into which to write the data
156 //! \param count number of times to write the value
157 //!
158 //! \return None
159 //
160 //*****************************************************************************
161 extern void FlashCtl_write32(uint32_t *data_ptr,
162  uint32_t *flash_ptr,
163  uint16_t count);
164 
165 //*****************************************************************************
166 //
167 //! \brief Write data into the flash memory in 32-bit word format, pass by
168 //! value
169 //!
170 //! This function writes a 32-bit data value into flash memory, count times.
171 //! Assumes the flash memory is already erased and unlocked.
172 //! FlashCtl_eraseSegment can be used to erase a segment.
173 //!
174 //! \param value value to fill memory with
175 //! \param flash_ptr is the pointer into which to write the data
176 //! \param count number of times to write the value
177 //!
178 //! \return None
179 //
180 //*****************************************************************************
181 extern void FlashCtl_fillMemory32(uint32_t value,
182  uint32_t *flash_ptr,
183  uint16_t count);
184 
185 //*****************************************************************************
186 //
187 //! \brief Check FlashCtl status to see if it is currently busy erasing or
188 //! programming
189 //!
190 //! This function checks the status register to determine if the flash memory
191 //! is ready for writing.
192 //!
193 //! \param mask FLASHCTL status to read
194 //! Mask value is the logical OR of any of the following:
195 //! - \b FLASHCTL_READY_FOR_NEXT_WRITE
196 //! - \b FLASHCTL_ACCESS_VIOLATION_INTERRUPT_FLAG
197 //! - \b FLASHCTL_PASSWORD_WRITTEN_INCORRECTLY
198 //! - \b FLASHCTL_BUSY
199 //!
200 //! \return Logical OR of any of the following:
201 //! - \b FLASHCTL_READY_FOR_NEXT_WRITE
202 //! - \b FLASHCTL_ACCESS_VIOLATION_INTERRUPT_FLAG
203 //! - \b FLASHCTL_PASSWORD_WRITTEN_INCORRECTLY
204 //! - \b FLASHCTL_BUSY
205 //! \n indicating the status of the FlashCtl
206 //
207 //*****************************************************************************
208 extern uint8_t FlashCtl_getStatus(uint8_t mask);
209 
210 //*****************************************************************************
211 //
212 //! \brief Locks the information flash memory segment A
213 //!
214 //! This function is typically called after an erase or write operation on the
215 //! information flash segment is performed by any of the other API functions in
216 //! order to re-lock the information flash segment.
217 //!
218 //!
219 //! \return None
220 //
221 //*****************************************************************************
222 extern void FlashCtl_lockInfoA(void);
223 
224 //*****************************************************************************
225 //
226 //! \brief Unlocks the information flash memory segment A
227 //!
228 //! This function must be called before an erase or write operation on the
229 //! information flash segment is performed by any of the other API functions.
230 //!
231 //!
232 //! \return None
233 //
234 //*****************************************************************************
235 extern void FlashCtl_unlockInfoA(void);
236 
237 //*****************************************************************************
238 //
239 // Mark the end of the C bindings section for C++ compilers.
240 //
241 //*****************************************************************************
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif
247 #endif // __MSP430WARE_FLASHCTL_H__
void FlashCtl_write16(uint16_t *data_ptr, uint16_t *flash_ptr, uint16_t count)
Write data into the flash memory in 16-bit word format, pass by reference.
Definition: flashctl.c:143
bool FlashCtl_performEraseCheck(uint8_t *flash_ptr, uint16_t numberOfBytes)
Erase check of the flash memory.
Definition: flashctl.c:99
void FlashCtl_eraseSegment(uint8_t *flash_ptr)
Erase a single segment of the flash memory.
Definition: flashctl.c:21
void FlashCtl_lockInfoA(void)
Locks the information flash memory segment A.
Definition: flashctl.c:235
void FlashCtl_write8(uint8_t *data_ptr, uint8_t *flash_ptr, uint16_t count)
Write data into the flash memory in byte format, pass by reference.
Definition: flashctl.c:115
uint8_t FlashCtl_getStatus(uint8_t mask)
Check FlashCtl status to see if it is currently busy erasing or programming.
Definition: flashctl.c:229
void FlashCtl_unlockInfoA(void)
Unlocks the information flash memory segment A.
Definition: flashctl.c:253
void FlashCtl_fillMemory32(uint32_t value, uint32_t *flash_ptr, uint16_t count)
Write data into the flash memory in 32-bit word format, pass by value.
Definition: flashctl.c:200
void FlashCtl_eraseBank(uint8_t *flash_ptr)
Erase a single bank of the flash memory.
Definition: flashctl.c:41
void FlashCtl_write32(uint32_t *data_ptr, uint32_t *flash_ptr, uint16_t count)
Write data into the flash memory in 32-bit word format, pass by reference.
Definition: flashctl.c:171
void FlashCtl_performMassErase(uint8_t *flash_ptr)
Erase all flash memory.
Definition: flashctl.c:77

Copyright 2020, Texas Instruments Incorporated