2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 //*****************************************************************************
42 //! \addtogroup flash_api
45 //*****************************************************************************
47 //*****************************************************************************
49 // If building with a C++ compiler, make all of the definitions in this header
52 //*****************************************************************************
61 //*****************************************************************************
63 // Control specific variables
65 //*****************************************************************************
66 #define FLASH_BURST_PRG_BIT 0x03
69 #define FLASH_PROGRAM_ERROR FLCTL_IFG_PRG_ERR
70 #define FLASH_BENCHMARK_INT FLCTL_IFG_BMRK
71 #define FLASH_ERASE_COMPLETE FLCTL_IFG_ERASE
72 #define FLASH_BRSTPRGM_COMPLETE FLCTL_IFG_PRGB
73 #define FLASH_WRDPRGM_COMPLETE FLCTL_IFG_PRG
74 #define FLASH_POSTVERIFY_FAILED FLCTL_IFG_AVPST
75 #define FLASH_PREVERIFY_FAILED FLCTL_IFG_AVPRE
76 #define FLASH_BRSTRDCMP_COMPLETE FLCTL_IFG_RDBRST
78 #define FLASH_NORMAL_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_0
79 #define FLASH_MARGIN0_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_1
80 #define FLASH_MARGIN1_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_2
81 #define FLASH_PROGRAM_VERIFY_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_3
82 #define FLASH_ERASE_VERIFY_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_4
83 #define FLASH_LEAKAGE_VERIFY_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_5
84 #define FLASH_MARGIN0B_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_9
85 #define FLASH_MARGIN1B_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_10
87 #define FLASH_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE 0x70000
89 #define FLASH_BANK0 0x00
90 #define FLASH_BANK1 0x01
91 #define FLASH_DATA_READ 0x00
92 #define FLASH_INSTRUCTION_FETCH 0x01
94 #define FLASH_MAIN_MEMORY_SPACE_BANK0 0x01
95 #define FLASH_MAIN_MEMORY_SPACE_BANK1 0x02
96 #define FLASH_INFO_MEMORY_SPACE_BANK0 0x03
97 #define FLASH_INFO_MEMORY_SPACE_BANK1 0x04
99 #define FLASH_MAIN_SPACE FLCTL_RDBRST_CTLSTAT_MEM_TYPE_0
100 #define FLASH_INFO_SPACE FLCTL_RDBRST_CTLSTAT_MEM_TYPE_1
101 #define FLASH_1_PATTERN FLCTL_RDBRST_CTLSTAT_DATA_CMP
102 #define FLASH_0_PATTERN 0x00
104 #define FLASH_SECTOR0 FLCTL_BANK0_MAIN_WEPROT_PROT0
105 #define FLASH_SECTOR1 FLCTL_BANK0_MAIN_WEPROT_PROT1
106 #define FLASH_SECTOR2 FLCTL_BANK0_MAIN_WEPROT_PROT2
107 #define FLASH_SECTOR3 FLCTL_BANK0_MAIN_WEPROT_PROT3
108 #define FLASH_SECTOR4 FLCTL_BANK0_MAIN_WEPROT_PROT4
109 #define FLASH_SECTOR5 FLCTL_BANK0_MAIN_WEPROT_PROT5
110 #define FLASH_SECTOR6 FLCTL_BANK0_MAIN_WEPROT_PROT6
111 #define FLASH_SECTOR7 FLCTL_BANK0_MAIN_WEPROT_PROT7
112 #define FLASH_SECTOR8 FLCTL_BANK0_MAIN_WEPROT_PROT8
113 #define FLASH_SECTOR9 FLCTL_BANK0_MAIN_WEPROT_PROT9
114 #define FLASH_SECTOR10 FLCTL_BANK0_MAIN_WEPROT_PROT10
115 #define FLASH_SECTOR11 FLCTL_BANK0_MAIN_WEPROT_PROT11
116 #define FLASH_SECTOR12 FLCTL_BANK0_MAIN_WEPROT_PROT12
117 #define FLASH_SECTOR13 FLCTL_BANK0_MAIN_WEPROT_PROT13
118 #define FLASH_SECTOR14 FLCTL_BANK0_MAIN_WEPROT_PROT14
119 #define FLASH_SECTOR15 FLCTL_BANK0_MAIN_WEPROT_PROT15
120 #define FLASH_SECTOR16 FLCTL_BANK0_MAIN_WEPROT_PROT16
121 #define FLASH_SECTOR17 FLCTL_BANK0_MAIN_WEPROT_PROT17
122 #define FLASH_SECTOR18 FLCTL_BANK0_MAIN_WEPROT_PROT18
123 #define FLASH_SECTOR19 FLCTL_BANK0_MAIN_WEPROT_PROT19
124 #define FLASH_SECTOR20 FLCTL_BANK0_MAIN_WEPROT_PROT20
125 #define FLASH_SECTOR21 FLCTL_BANK0_MAIN_WEPROT_PROT21
126 #define FLASH_SECTOR22 FLCTL_BANK0_MAIN_WEPROT_PROT22
127 #define FLASH_SECTOR23 FLCTL_BANK0_MAIN_WEPROT_PROT23
128 #define FLASH_SECTOR24 FLCTL_BANK0_MAIN_WEPROT_PROT24
129 #define FLASH_SECTOR25 FLCTL_BANK0_MAIN_WEPROT_PROT25
130 #define FLASH_SECTOR26 FLCTL_BANK0_MAIN_WEPROT_PROT26
131 #define FLASH_SECTOR27 FLCTL_BANK0_MAIN_WEPROT_PROT27
132 #define FLASH_SECTOR28 FLCTL_BANK0_MAIN_WEPROT_PROT28
133 #define FLASH_SECTOR29 FLCTL_BANK0_MAIN_WEPROT_PROT29
134 #define FLASH_SECTOR30 FLCTL_BANK0_MAIN_WEPROT_PROT30
135 #define FLASH_SECTOR31 FLCTL_BANK0_MAIN_WEPROT_PROT31
137 #define FLASH_NOVER 0
138 #define FLASH_BURSTPOST FLCTL_PRGBRST_CTLSTAT_AUTO_PST
139 #define FLASH_BURSTPRE FLCTL_PRGBRST_CTLSTAT_AUTO_PRE
140 #define FLASH_REGPRE FLCTL_PRG_CTLSTAT_VER_PRE
141 #define FLASH_REGPOST FLCTL_PRG_CTLSTAT_VER_PST
142 #define FLASH_FULLVER (FLCTL_PRGBRST_CTLSTAT_AUTO_PST | \
143 FLCTL_PRGBRST_CTLSTAT_AUTO_PRE | FLCTL_PRG_CTLSTAT_VER_PRE \
144 | FLCTL_PRG_CTLSTAT_VER_PST)
146 #define FLASH_COLLATED_WRITE_MODE 0x01
147 #define FLASH_IMMEDIATE_WRITE_MODE 0x02
149 #define FlashInternal_eraseSector \
150 ((bool (*)(uint32_t addr, \
151 bool verify))ROM_FLASHCTLTABLE[9])
153 #define FlashInternal_performMassErase \
154 ((bool (*)(bool verify))ROM_FLASHCTLTABLE[8])
158 //*****************************************************************************
160 // Prototypes for the APIs.
162 //*****************************************************************************
163 //*****************************************************************************
165 //! Enables read buffering on accesses to a specified bank of flash memory
167 //! \param memoryBank is the value of the memory bank to enable read
168 //! buffering. Must be only one of the following values:
169 //! - \b FLASH_BANK0,
172 //! \param accessMethod is the value of the access type to enable read
173 //! buffering. Must be only one of the following values:
174 //! - \b FLASH_DATA_READ,
175 //! - \b FLASH_INSTRUCTION_FETCH
179 //*****************************************************************************
180 extern void FlashCtl_enableReadBuffering(uint_fast8_t memoryBank,
181 uint_fast8_t accessMethod);
183 //*****************************************************************************
185 //! Disables read buffering on accesses to a specified bank of flash memory
187 //! \param memoryBank is the value of the memory bank to disable read
188 //! buffering. Must be only one of the following values:
189 //! - \b FLASH_BANK0,
192 //! \param accessMethod is the value of the access type to disable read
193 //! buffering. Must ne only one of the following values:
194 //! - \b FLASH_DATA_READ,
195 //! - \b FLASH_INSTRUCTION_FETCH
199 //*****************************************************************************
200 extern void FlashCtl_disableReadBuffering(uint_fast8_t memoryBank,
201 uint_fast8_t accessMethod);
203 //*****************************************************************************
205 //! Disables program protection on the given sector mask. This setting can be
206 //! applied on a sector-wise bases on a given memory space (INFO or MAIN).
208 //! \param memorySpace is the value of the memory bank to disable program
209 //! protection. Must be only one of the following values:
210 //! - \b FLASH_MAIN_MEMORY_SPACE_BANK0,
211 //! - \b FLASH_MAIN_MEMORY_SPACE_BANK1,
212 //! - \b FLASH_INFO_MEMORY_SPACE_BANK0,
213 //! - \b FLASH_INFO_MEMORY_SPACE_BANK1
215 //! \param sectorMask is a bit mask of the sectors to disable program
216 //! protection. Must be a bitfield of the following values:
217 //! - \b FLASH_SECTOR0,
218 //! - \b FLASH_SECTOR1,
219 //! - \b FLASH_SECTOR2,
220 //! - \b FLASH_SECTOR3,
221 //! - \b FLASH_SECTOR4,
222 //! - \b FLASH_SECTOR5,
223 //! - \b FLASH_SECTOR6,
224 //! - \b FLASH_SECTOR7,
225 //! - \b FLASH_SECTOR8,
226 //! - \b FLASH_SECTOR9,
227 //! - \b FLASH_SECTOR10,
228 //! - \b FLASH_SECTOR11,
229 //! - \b FLASH_SECTOR12,
230 //! - \b FLASH_SECTOR13,
231 //! - \b FLASH_SECTOR14,
232 //! - \b FLASH_SECTOR15,
233 //! - \b FLASH_SECTOR16,
234 //! - \b FLASH_SECTOR17,
235 //! - \b FLASH_SECTOR18,
236 //! - \b FLASH_SECTOR19,
237 //! - \b FLASH_SECTOR20,
238 //! - \b FLASH_SECTOR21,
239 //! - \b FLASH_SECTOR22,
240 //! - \b FLASH_SECTOR23,
241 //! - \b FLASH_SECTOR24,
242 //! - \b FLASH_SECTOR25,
243 //! - \b FLASH_SECTOR26,
244 //! - \b FLASH_SECTOR27,
245 //! - \b FLASH_SECTOR28,
246 //! - \b FLASH_SECTOR29,
247 //! - \b FLASH_SECTOR30,
248 //! - \b FLASH_SECTOR31
250 //! \note Flash sector sizes are 4KB and the number of sectors may vary
251 //! depending on the specific device. Also, for INFO memory space, only sectors
252 //! \b FLASH_SECTOR0 and \b FLASH_SECTOR1 will exist.
254 //! \return true if sector protection disabled false otherwise.
256 //*****************************************************************************
257 extern bool FlashCtl_unprotectSector(uint_fast8_t memorySpace,
258 uint32_t sectorMask);
260 //*****************************************************************************
262 //! Enables program protection on the given sector mask. This setting can be
263 //! applied on a sector-wise bases on a given memory space (INFO or MAIN).
265 //! \param memorySpace is the value of the memory bank to enable program
266 //! protection. Must be only one of the following values:
267 //! - \b FLASH_MAIN_MEMORY_SPACE_BANK0,
268 //! - \b FLASH_MAIN_MEMORY_SPACE_BANK1,
269 //! - \b FLASH_INFO_MEMORY_SPACE_BANK0,
270 //! - \b FLASH_INFO_MEMORY_SPACE_BANK1
272 //! \param sectorMask is a bit mask of the sectors to enable program
273 //! protection. Must be a bitfield of the following values:
274 //! - \b FLASH_SECTOR0,
275 //! - \b FLASH_SECTOR1,
276 //! - \b FLASH_SECTOR2,
277 //! - \b FLASH_SECTOR3,
278 //! - \b FLASH_SECTOR4,
279 //! - \b FLASH_SECTOR5,
280 //! - \b FLASH_SECTOR6,
281 //! - \b FLASH_SECTOR7,
282 //! - \b FLASH_SECTOR8,
283 //! - \b FLASH_SECTOR9,
284 //! - \b FLASH_SECTOR10,
285 //! - \b FLASH_SECTOR11,
286 //! - \b FLASH_SECTOR12,
287 //! - \b FLASH_SECTOR13,
288 //! - \b FLASH_SECTOR14,
289 //! - \b FLASH_SECTOR15,
290 //! - \b FLASH_SECTOR16,
291 //! - \b FLASH_SECTOR17,
292 //! - \b FLASH_SECTOR18,
293 //! - \b FLASH_SECTOR19,
294 //! - \b FLASH_SECTOR20,
295 //! - \b FLASH_SECTOR21,
296 //! - \b FLASH_SECTOR22,
297 //! - \b FLASH_SECTOR23,
298 //! - \b FLASH_SECTOR24,
299 //! - \b FLASH_SECTOR25,
300 //! - \b FLASH_SECTOR26,
301 //! - \b FLASH_SECTOR27,
302 //! - \b FLASH_SECTOR28,
303 //! - \b FLASH_SECTOR29,
304 //! - \b FLASH_SECTOR30,
305 //! - \b FLASH_SECTOR31
307 //! \note Flash sector sizes are 4KB and the number of sectors may vary
308 //! depending on the specific device. Also, for INFO memory space, only sectors
309 //! \b FLASH_SECTOR0 and \b FLASH_SECTOR1 will exist.
311 //! \return true if sector protection enabled false otherwise.
313 //*****************************************************************************
314 extern bool FlashCtl_protectSector(uint_fast8_t memorySpace,
315 uint32_t sectorMask);
317 //*****************************************************************************
319 //! Returns the sector protection for given sector mask and memory space
321 //! \param memorySpace is the value of the memory bank to check for program
322 //! protection. Must be only one of the following values:
323 //! - \b FLASH_MAIN_MEMORY_SPACE_BANK0,
324 //! - \b FLASH_MAIN_MEMORY_SPACE_BANK1,
325 //! - \b FLASH_INFO_MEMORY_SPACE_BANK0,
326 //! - \b FLASH_INFO_MEMORY_SPACE_BANK1
328 //! \param sector is the sector to check for program protection.
329 //! Must be one of the following values:
330 //! - \b FLASH_SECTOR0,
331 //! - \b FLASH_SECTOR1,
332 //! - \b FLASH_SECTOR2,
333 //! - \b FLASH_SECTOR3,
334 //! - \b FLASH_SECTOR4,
335 //! - \b FLASH_SECTOR5,
336 //! - \b FLASH_SECTOR6,
337 //! - \b FLASH_SECTOR7,
338 //! - \b FLASH_SECTOR8,
339 //! - \b FLASH_SECTOR9,
340 //! - \b FLASH_SECTOR10,
341 //! - \b FLASH_SECTOR11,
342 //! - \b FLASH_SECTOR12,
343 //! - \b FLASH_SECTOR13,
344 //! - \b FLASH_SECTOR14,
345 //! - \b FLASH_SECTOR15,
346 //! - \b FLASH_SECTOR16,
347 //! - \b FLASH_SECTOR17,
348 //! - \b FLASH_SECTOR18,
349 //! - \b FLASH_SECTOR19,
350 //! - \b FLASH_SECTOR20,
351 //! - \b FLASH_SECTOR21,
352 //! - \b FLASH_SECTOR22,
353 //! - \b FLASH_SECTOR23,
354 //! - \b FLASH_SECTOR24,
355 //! - \b FLASH_SECTOR25,
356 //! - \b FLASH_SECTOR26,
357 //! - \b FLASH_SECTOR27,
358 //! - \b FLASH_SECTOR28,
359 //! - \b FLASH_SECTOR29,
360 //! - \b FLASH_SECTOR30,
361 //! - \b FLASH_SECTOR31
363 //! Note that flash sector sizes are 4KB and the number of sectors may vary
364 //! depending on the specific device. Also, for INFO memory space, only sectors
365 //! FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
367 //! \return true if sector protection enabled false otherwise.
369 //*****************************************************************************
370 extern bool FlashCtl_isSectorProtected(uint_fast8_t memorySpace,
373 //*****************************************************************************
375 //! Verifies a given segment of memory based off either a high (1) or low (0)
378 //! \param verifyAddr Start address where verification will begin
380 //! \param length Length in bytes to verify based off the pattern
382 //! \param pattern The pattern which verification will check versus. This can
383 //! either be a low pattern (each register will be checked versus a pattern
384 //! of 32 zeros, or a high pattern (each register will be checked versus a
385 //! pattern of 32 ones). Valid values are: FLASH_0_PATTERN, FLASH_1_PATTERN
387 //! Note that there are no sector/boundary restrictions for this function,
388 //! however it is encouraged to proved a start address aligned on 32-bit
389 //! boundaries. Providing an unaligned address will result in unaligned data
390 //! accesses and detriment efficiency.
392 //! Note that this function is blocking and will not exit until operation has
393 //! either completed or failed due to an error.
395 //! \return true if memory verification is successful, false otherwise.
397 //*****************************************************************************
398 extern bool FlashCtl_verifyMemory(void* verifyAddr, uint32_t length,
399 uint_fast8_t pattern);
401 //*****************************************************************************
403 //! Performs a mass erase on all unprotected flash sectors. Protected sectors
406 //! \note This function is blocking and will not exit until operation has
407 //! either completed or failed due to an error.
409 //! \return true if mass erase completes successfully, false otherwise
411 //*****************************************************************************
412 extern bool FlashCtl_performMassErase(void);
414 //*****************************************************************************
416 //! Erases a sector of MAIN or INFO flash memory.
418 //! \param addr The start of the sector to erase. Note that with flash,
419 //! the minimum allowed size that can be erased is a flash sector
420 //! (which is 4KB on the MSP432 family). If an address is provided to
421 //! this function which is not on a 4KB boundary, the entire sector
422 //! will still be erased.
424 //! Note that this function is blocking and will not exit until operation has
425 //! either completed or failed due to an error.
427 //! \return true if sector erase is successful, false otherwise.
429 //*****************************************************************************
430 extern bool FlashCtl_eraseSector(uint32_t addr);
432 //*****************************************************************************
434 //! Program a portion of flash memory with the provided data
436 //! \param src Pointer to the data source to program into flash
438 //! \param dest Pointer to the destination in flash to program
440 //! \param length Length in bytes to program
442 //! \note There are no sector/boundary restrictions for this function,
443 //! however it is encouraged to proved a start address aligned on 32-bit
444 //! boundaries. Providing an unaligned address will result in unaligned data
445 //! accesses and detriment efficiency.
447 //! Note that this function is blocking and will not exit until operation has
448 //! either completed or failed due to an error.
450 //! \return Whether or not the program succeeded
452 //*****************************************************************************
453 extern bool FlashCtl_programMemory(void* src, void* dest, uint32_t length);
455 //*****************************************************************************
457 //! Setups pre/post verification of burst and regular flash programming
458 //! instructions. Note that this API is for advanced users that are programming
459 //! their own flash drivers. The program/erase APIs are not affected by this
460 //! setting and take care of the verification requirements.
462 //! \param verificationSetting Verification setting to set. This value can
463 //! be a bitwise OR of the following values:
464 //! - \b FLASH_BURSTPOST,
465 //! - \b FLASH_BURSTPRE,
466 //! - \b FLASH_REGPRE,
467 //! - \b FLASH_REGPOST
468 //! - \b FLASH_NOVER No verification enabled
469 //! - \b FLASH_FULLVER Full verification enabled
473 //*****************************************************************************
474 extern void FlashCtl_setProgramVerification(uint32_t verificationSetting);
476 //*****************************************************************************
478 //! Clears pre/post verification of burst and regular flash programming
479 //! instructions. Note that this API is for advanced users that are programming
480 //! their own flash drivers. The program/erase APIs are not affected by this
481 //! setting and take care of the verification requirements.
483 //! \param verificationSetting Verification setting to clear. This value can
484 //! be a bitwise OR of the following values:
485 //! - \b FLASH_BURSTPOST,
486 //! - \b FLASH_BURSTPRE,
487 //! - \b FLASH_REGPRE,
488 //! - \b FLASH_REGPOST
489 //! - \b FLASH_NOVER No verification enabled
490 //! - \b FLASH_FULLVER Full verification enabled
494 //*****************************************************************************
495 extern void FlashCtl_clearProgramVerification(uint32_t verificationSetting);
497 //*****************************************************************************
499 //! Enables word programming of flash memory.
501 //! This function will enable word programming of the flash memory and set the
502 //! mode of behavior when the flash write occurs.
504 //! \param mode The mode specifies the behavior of the flash controller when
505 //! programming words to flash. In \b FLASH_IMMEDIATE_WRITE_MODE, the
506 //! program operation happens immediately on the write to flash while
507 //! in \b FLASH_COLLATED_WRITE_MODE the write will be delayed until a full
508 //! 128-bits have been collated. Possible values include:
509 //! - \b FLASH_IMMEDIATE_WRITE_MODE
510 //! - \b FLASH_COLLATED_WRITE_MODE
513 //! Refer to the user's guide for further documentation.
517 //*****************************************************************************
518 extern void FlashCtl_enableWordProgramming(uint32_t mode);
520 //*****************************************************************************
522 //! Disables word programming of flash memory.
524 //! Refer to FlashCtl_enableWordProgramming and the user's guide for description
525 //! on the difference between full word and immediate programming
529 //*****************************************************************************
530 extern void FlashCtl_disableWordProgramming(void);
532 //*****************************************************************************
534 //! Returns if word programming mode is enabled (and if it is, the specific mode)
536 //! Refer to FlashCtl_enableWordProgramming and the user's guide for description
537 //! on the difference between full word and immediate programming
539 //! \return a zero value if word programming is disabled,
540 //! - \b FLASH_IMMEDIATE_WRITE_MODE
541 //! - \b FLASH_COLLATED_WRITE_MODE
544 //*****************************************************************************
545 extern uint32_t FlashCtl_isWordProgrammingEnabled(void);
547 //*****************************************************************************
549 //! Sets the flash read mode to be used by default flash read operations.
550 //! Note that the proper wait states must be set prior to entering this
553 //! \param flashBank Flash bank to set read mode for. Valid values are:
557 //! \param readMode The read mode to set. Valid values are:
558 //! - \b FLASH_NORMAL_READ_MODE,
559 //! - \b FLASH_MARGIN0_READ_MODE,
560 //! - \b FLASH_MARGIN1_READ_MODE,
561 //! - \b FLASH_PROGRAM_VERIFY_READ_MODE,
562 //! - \b FLASH_ERASE_VERIFY_READ_MODE,
563 //! - \b FLASH_LEAKAGE_VERIFY_READ_MODE,
564 //! - \b FLASH_MARGIN0B_READ_MODE,
565 //! - \b FLASH_MARGIN1B_READ_MODE
569 //*****************************************************************************
570 extern bool FlashCtl_setReadMode(uint32_t flashBank, uint32_t readMode);
572 //*****************************************************************************
574 //! Gets the flash read mode to be used by default flash read operations.
576 //! \param flashBank Flash bank to set read mode for. Valid values are:
580 //! \return Returns the read mode to set. Valid values are:
581 //! - \b FLASH_NORMAL_READ_MODE,
582 //! - \b FLASH_MARGIN0_READ_MODE,
583 //! - \b FLASH_MARGIN1_READ_MODE,
584 //! - \b FLASH_PROGRAM_VERIFY_READ_MODE,
585 //! - \b FLASH_ERASE_VERIFY_READ_MODE,
586 //! - \b FLASH_LEAKAGE_VERIFY_READ_MODE,
587 //! - \b FLASH_MARGIN0B_READ_MODE,
588 //! - \b FLASH_MARGIN1B_READ_MODE
591 //*****************************************************************************
592 extern uint32_t FlashCtl_getReadMode(uint32_t flashBank);
594 //*****************************************************************************
596 //! Changes the number of wait states that are used by the flash controller
597 //! for read operations. When changing frequency ranges of the clock, this
598 //! functions must be used in order to allow for readable flash memory.
600 //! \param waitState The number of wait states to set. Note that only
601 //! bits 0-3 are used.
603 //! \param flashBank Flash bank to set wait state for. Valid values are:
608 //*****************************************************************************
609 extern void FlashCtl_setWaitState(uint32_t bank, uint32_t waitState);
611 //*****************************************************************************
613 //! Returns the set number of flash wait states for the given flash bank.
615 //! \param flashBank Flash bank to set wait state for. Valid values are:
619 //! \return The wait state setting for the specified flash bank
621 //*****************************************************************************
622 extern uint32_t FlashCtl_getWaitState(uint32_t bank);
624 //*****************************************************************************
626 //! Enables individual flash control interrupt sources.
628 //! \param flags is a bit mask of the interrupt sources to be enabled. Must
629 //! be a logical OR of:
630 //! - \b FLASH_PROGRAM_ERROR,
631 //! - \b FLASH_BENCHMARK_INT,
632 //! - \b FLASH_ERASE_COMPLETE,
633 //! - \b FLASH_BRSTPRGM_COMPLETE,
634 //! - \b FLASH_WRDPRGM_COMPLETE,
635 //! - \b FLASH_POSTVERIFY_FAILED,
636 //! - \b FLASH_PREVERIFY_FAILED,
637 //! - \b FLASH_BRSTRDCMP_COMPLETE
639 //! This function enables the indicated flash system interrupt sources. Only
640 //! the sources that are enabled can be reflected to the processor interrupt;
641 //! disabled sources have no effect on the processor.
643 //! \note The interrupt sources vary based on the part in use.
644 //! Please consult the data sheet for the part you are using to determine
645 //! which interrupt sources are available.
649 //*****************************************************************************
650 extern void FlashCtl_enableInterrupt(uint32_t flags);
652 //*****************************************************************************
654 //! Disables individual flash system interrupt sources.
656 //! \param flags is a bit mask of the interrupt sources to be disabled. Must
657 //! be a logical OR of:
658 //! - \b FLASH_PROGRAM_ERROR,
659 //! - \b FLASH_BENCHMARK_INT,
660 //! - \b FLASH_ERASE_COMPLETE,
661 //! - \b FLASH_BRSTPRGM_COMPLETE,
662 //! - \b FLASH_WRDPRGM_COMPLETE,
663 //! - \b FLASH_POSTVERIFY_FAILED,
664 //! - \b FLASH_PREVERIFY_FAILED,
665 //! - \b FLASH_BRSTRDCMP_COMPLETE
667 //! This function disables the indicated flash system interrupt sources.
668 //! Only the sources that are enabled can be reflected to the processor
669 //! interrupt; disabled sources have no effect on the processor.
674 //*****************************************************************************
675 extern void FlashCtl_disableInterrupt(uint32_t flags);
677 //*****************************************************************************
679 //! Gets the current interrupt status masked with the enabled interrupts.
680 //! This function is useful to call in ISRs to get a list
681 //! of pending interrupts that are actually enabled and could have caused the
684 //! \return The current interrupt status, enumerated as a bit field of
685 //! - \b FLASH_PROGRAM_ERROR,
686 //! - \b FLASH_BENCHMARK_INT,
687 //! - \b FLASH_ERASE_COMPLETE,
688 //! - \b FLASH_BRSTPRGM_COMPLETE,
689 //! - \b FLASH_WRDPRGM_COMPLETE,
690 //! - \b FLASH_POSTVERIFY_FAILED,
691 //! - \b FLASH_PREVERIFY_FAILED,
692 //! - \b FLASH_BRSTRDCMP_COMPLETE
694 //! \note The interrupt sources vary based on the part in use.
695 //! Please consult the data sheet for the part you are using to determine
696 //! which interrupt sources are available.
698 //*****************************************************************************
699 extern uint32_t FlashCtl_getEnabledInterruptStatus(void);
701 //*****************************************************************************
703 //! Gets the current interrupt status.
705 //! \return The current interrupt status, enumerated as a bit field of:
706 //! - \b FLASH_PROGRAM_ERROR,
707 //! - \b FLASH_BENCHMARK_INT,
708 //! - \b FLASH_ERASE_COMPLETE,
709 //! - \b FLASH_BRSTPRGM_COMPLETE,
710 //! - \b FLASH_WRDPRGM_COMPLETE,
711 //! - \b FLASH_POSTVERIFY_FAILED,
712 //! - \b FLASH_PREVERIFY_FAILED,
713 //! - \b FLASH_BRSTRDCMP_COMPLETE
715 //! \note The interrupt sources vary based on the part in use.
716 //! Please consult the data sheet for the part you are using to determine
717 //! which interrupt sources are available.
719 //*****************************************************************************
720 extern uint32_t FlashCtl_getInterruptStatus(void);
722 //*****************************************************************************
724 //! Clears flash system interrupt sources.
726 //! \param flags is a bit mask of the interrupt sources to be cleared. Must
727 //! be a logical OR of:
728 //! - \b FLASH_PROGRAM_ERROR,
729 //! - \b FLASH_BENCHMARK_INT,
730 //! - \b FLASH_ERASE_COMPLETE,
731 //! - \b FLASH_BRSTPRGM_COMPLETE,
732 //! - \b FLASH_WRDPRGM_COMPLETE,
733 //! - \b FLASH_POSTVERIFY_FAILED,
734 //! - \b FLASH_PREVERIFY_FAILED,
735 //! - \b FLASH_BRSTRDCMP_COMPLETE
737 //! The specified flash system interrupt sources are cleared, so that they no
738 //! longer assert. This function must be called in the interrupt handler to
739 //! keep it from being called again immediately upon exit.
741 //! \note Because there is a write buffer in the Cortex-M processor, it may
742 //! take several clock cycles before the interrupt source is actually cleared.
743 //! Therefore, it is recommended that the interrupt source be cleared early in
744 //! the interrupt handler (as opposed to the very last action) to avoid
745 //! returning from the interrupt handler before the interrupt source is
746 //! actually cleared. Failure to do so may result in the interrupt handler
747 //! being immediately reentered (because the interrupt controller still sees
748 //! the interrupt source asserted).
750 //! \note The interrupt sources vary based on the part in use.
751 //! Please consult the data sheet for the part you are using to determine
752 //! which interrupt sources are available.
756 //*****************************************************************************
757 extern void FlashCtl_clearInterruptFlag(uint32_t flags);
759 //*****************************************************************************
761 //! Registers an interrupt handler for flash clock system interrupt.
763 //! \param intHandler is a pointer to the function to be called when the clock
764 //! system interrupt occurs.
766 //! This function registers the handler to be called when a clock system
767 //! interrupt occurs. This function enables the global interrupt in the
768 //! interrupt controller; specific flash controller interrupts must be enabled
769 //! via FlashCtl_enableInterrupt(). It is the interrupt handler's
770 //! responsibility to clear the interrupt source via
771 //! FlashCtl_clearInterruptFlag().
773 //! \sa Interrupt_registerInterrupt() for important information about
774 //! registering interrupt handlers.
778 //*****************************************************************************
779 extern void FlashCtl_registerInterrupt(void (*intHandler)(void));
781 //*****************************************************************************
783 //! Unregisters the interrupt handler for the flash system.
785 //! This function unregisters the handler to be called when a clock system
786 //! interrupt occurs. This function also masks off the interrupt in the
787 //! interrupt controller so that the interrupt handler no longer is called.
789 //! \sa Interrupt_registerInterrupt() for important information about
790 //! registering interrupt handlers.
794 //*****************************************************************************
795 extern void FlashCtl_unregisterInterrupt(void);
797 //*****************************************************************************
799 // Mark the end of the C bindings section for C++ compilers.
801 //*****************************************************************************
806 //*****************************************************************************
808 // Close the Doxygen group.
811 //*****************************************************************************
813 #endif // __FLASH_H__