flash_a.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, 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  * --/COPYRIGHT--*/
32 #ifndef __FLASH_A_H__
33 #define __FLASH_A_H__
34 
35 #include <stdbool.h>
36 #include <ti/devices/msp432p4xx/inc/msp.h>
37 
38 /* Define to ensure that our current MSP432 has the FLCTL_A module. This
39  definition is included in the device specific header file */
40 #ifdef __MCU_HAS_FLCTL_A__
41 
42 //*****************************************************************************
43 //
46 //
47 //*****************************************************************************
48 
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 //*****************************************************************************
61 //
62 // Control specific variables
63 //
64 //*****************************************************************************
65 #define FLASH_A_BURST_PRG_BIT 0x03
66 #define FLASH_A_SECTOR_SIZE 4096
67 
68 /* Interrupts */
69 #define FLASH_A_PROGRAM_ERROR FLCTL_A_IFG_PRG_ERR
70 #define FLASH_A_BENCHMARK_INT FLCTL_A_IFG_BMRK
71 #define FLASH_A_ERASE_COMPLETE FLCTL_A_IFG_ERASE
72 #define FLASH_A_BRSTPRGM_COMPLETE FLCTL_A_IFG_PRGB
73 #define FLASH_A_WRDPRGM_COMPLETE FLCTL_A_IFG_PRG
74 #define FLASH_A_POSTVERIFY_FAILED FLCTL_A_IFG_AVPST
75 #define FLASH_A_PREVERIFY_FAILED FLCTL_A_IFG_AVPRE
76 #define FLASH_A_BRSTRDCMP_COMPLETE FLCTL_A_IFG_RDBRST
77 
78 #define FLASH_A_NORMAL_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_0
79 #define FLASH_A_MARGIN0_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_1
80 #define FLASH_A_MARGIN1_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_2
81 #define FLASH_A_PROGRAM_VERIFY_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_3
82 #define FLASH_A_ERASE_VERIFY_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_4
83 #define FLASH_A_LEAKAGE_VERIFY_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_5
84 #define FLASH_A_MARGIN0B_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_9
85 #define FLASH_A_MARGIN1B_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_10
86 
87 #define FLASH_A_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE FLCTL_A_PRGBRST_CTLSTAT_BURST_STATUS_7
88 
89 #define FLASH_A_BANK0 0x00
90 #define FLASH_A_BANK1 0x01
91 #define FLASH_A_DATA_READ 0x00
92 #define FLASH_A_INSTRUCTION_FETCH 0x01
93 
94 #define FLASH_A_MAIN_MEMORY_SPACE_BANK0 0x01
95 #define FLASH_A_MAIN_MEMORY_SPACE_BANK1 0x02
96 #define FLASH_A_INFO_MEMORY_SPACE_BANK0 0x03
97 #define FLASH_A_INFO_MEMORY_SPACE_BANK1 0x04
98 
99 #define FLASH_A_MAIN_SPACE FLCTL_A_RDBRST_CTLSTAT_MEM_TYPE_0
100 #define FLASH_A_INFO_SPACE FLCTL_A_RDBRST_CTLSTAT_MEM_TYPE_1
101 #define FLASH_A_1_PATTERN FLCTL_A_RDBRST_CTLSTAT_DATA_CMP
102 #define FLASH_A_0_PATTERN 0x00
103 
104 #define FLASH_A_SECTOR0 FLCTL_A_BANK0_MAIN_WEPROT_PROT0
105 #define FLASH_A_SECTOR1 FLCTL_A_BANK0_MAIN_WEPROT_PROT1
106 #define FLASH_A_SECTOR2 FLCTL_A_BANK0_MAIN_WEPROT_PROT2
107 #define FLASH_A_SECTOR3 FLCTL_A_BANK0_MAIN_WEPROT_PROT3
108 #define FLASH_A_SECTOR4 FLCTL_A_BANK0_MAIN_WEPROT_PROT4
109 #define FLASH_A_SECTOR5 FLCTL_A_BANK0_MAIN_WEPROT_PROT5
110 #define FLASH_A_SECTOR6 FLCTL_A_BANK0_MAIN_WEPROT_PROT6
111 #define FLASH_A_SECTOR7 FLCTL_A_BANK0_MAIN_WEPROT_PROT7
112 #define FLASH_A_SECTOR8 FLCTL_A_BANK0_MAIN_WEPROT_PROT8
113 #define FLASH_A_SECTOR9 FLCTL_A_BANK0_MAIN_WEPROT_PROT9
114 #define FLASH_A_SECTOR10 FLCTL_A_BANK0_MAIN_WEPROT_PROT10
115 #define FLASH_A_SECTOR11 FLCTL_A_BANK0_MAIN_WEPROT_PROT11
116 #define FLASH_A_SECTOR12 FLCTL_A_BANK0_MAIN_WEPROT_PROT12
117 #define FLASH_A_SECTOR13 FLCTL_A_BANK0_MAIN_WEPROT_PROT13
118 #define FLASH_A_SECTOR14 FLCTL_A_BANK0_MAIN_WEPROT_PROT14
119 #define FLASH_A_SECTOR15 FLCTL_A_BANK0_MAIN_WEPROT_PROT15
120 #define FLASH_A_SECTOR16 FLCTL_A_BANK0_MAIN_WEPROT_PROT16
121 #define FLASH_A_SECTOR17 FLCTL_A_BANK0_MAIN_WEPROT_PROT17
122 #define FLASH_A_SECTOR18 FLCTL_A_BANK0_MAIN_WEPROT_PROT18
123 #define FLASH_A_SECTOR19 FLCTL_A_BANK0_MAIN_WEPROT_PROT19
124 #define FLASH_A_SECTOR20 FLCTL_A_BANK0_MAIN_WEPROT_PROT20
125 #define FLASH_A_SECTOR21 FLCTL_A_BANK0_MAIN_WEPROT_PROT21
126 #define FLASH_A_SECTOR22 FLCTL_A_BANK0_MAIN_WEPROT_PROT22
127 #define FLASH_A_SECTOR23 FLCTL_A_BANK0_MAIN_WEPROT_PROT23
128 #define FLASH_A_SECTOR24 FLCTL_A_BANK0_MAIN_WEPROT_PROT24
129 #define FLASH_A_SECTOR25 FLCTL_A_BANK0_MAIN_WEPROT_PROT25
130 #define FLASH_A_SECTOR26 FLCTL_A_BANK0_MAIN_WEPROT_PROT26
131 #define FLASH_A_SECTOR27 FLCTL_A_BANK0_MAIN_WEPROT_PROT27
132 #define FLASH_A_SECTOR28 FLCTL_A_BANK0_MAIN_WEPROT_PROT28
133 #define FLASH_A_SECTOR29 FLCTL_A_BANK0_MAIN_WEPROT_PROT29
134 #define FLASH_A_SECTOR30 FLCTL_A_BANK0_MAIN_WEPROT_PROT30
135 #define FLASH_A_SECTOR31 FLCTL_A_BANK0_MAIN_WEPROT_PROT31
136 
137 #define FLASH_A_NOVER 0
138 #define FLASH_A_BURSTPOST FLCTL_A_PRGBRST_CTLSTAT_AUTO_PST
139 #define FLASH_A_BURSTPRE FLCTL_A_PRGBRST_CTLSTAT_AUTO_PRE
140 #define FLASH_A_REGPRE FLCTL_A_PRG_CTLSTAT_VER_PRE
141 #define FLASH_A_REGPOST FLCTL_A_PRG_CTLSTAT_VER_PST
142 #define FLASH_A_FULLVER (FLCTL_A_PRGBRST_CTLSTAT_AUTO_PST | \
143  FLCTL_A_PRGBRST_CTLSTAT_AUTO_PRE | FLCTL_A_PRG_CTLSTAT_VER_PRE \
144  | FLCTL_A_PRG_CTLSTAT_VER_PST)
145 
146 #define FLASH_A_COLLATED_WRITE_MODE 0x01
147 #define FLASH_A_IMMEDIATE_WRITE_MODE 0x02
148 
149 /* Internal parameters/definitions */
150 #define __INFO_FLASH_A_TECH_START__ 0x00200000
151 #define __INFO_FLASH_A_TECH_MIDDLE__ 0x00204000
152 
154 {
155  uint32_t B0_MAIN_R0;
156  uint32_t B0_MAIN_R1;
157  uint32_t B0_MAIN_R2;
158  uint32_t B0_MAIN_R3;
159  uint32_t B0_MAIN_R4;
160  uint32_t B0_MAIN_R5;
161  uint32_t B0_MAIN_R6;
162  uint32_t B0_MAIN_R7;
163  uint32_t B1_MAIN_R0;
164  uint32_t B1_MAIN_R1;
165  uint32_t B1_MAIN_R2;
166  uint32_t B1_MAIN_R3;
167  uint32_t B1_MAIN_R4;
168  uint32_t B1_MAIN_R5;
169  uint32_t B1_MAIN_R6;
170  uint32_t B1_MAIN_R7;
171  uint32_t B0_INFO_R0;
172  uint32_t B1_INFO_R0;
174 
175 //*****************************************************************************
176 //
177 // Prototypes for the APIs.
178 //
179 //*****************************************************************************
180 
181 //*****************************************************************************
182 //
201 //
202 //*****************************************************************************
203 extern void FlashCtl_A_getMemoryInfo(uint32_t addr, uint32_t *bankNum,
204  uint32_t *sectorNum);
205 
206 //*****************************************************************************
207 //
221 //
222 //*****************************************************************************
223 extern void FlashCtl_A_enableReadBuffering(uint_fast8_t memoryBank,
224  uint_fast8_t accessMethod);
225 
226 //*****************************************************************************
227 //
241 //
242 //*****************************************************************************
243 extern void FlashCtl_A_disableReadBuffering(uint_fast8_t memoryBank,
244  uint_fast8_t accessMethod);
245 
246 //*****************************************************************************
247 //
261 //
262 //*****************************************************************************
263 extern bool FlashCtl_A_protectMemory(uint32_t startAddr, uint32_t endAddr);
264 
265 //*****************************************************************************
266 //
280 //
281 //*****************************************************************************
282 extern bool FlashCtl_A_unprotectMemory(uint32_t startAddr, uint32_t endAddr);
283 
284 //*****************************************************************************
285 //
295 //
296 //*****************************************************************************
297 extern bool FlashCtl_A_isMemoryRangeProtected(uint32_t startAddr,
298  uint32_t endAddr);
299 
300 //*****************************************************************************
301 //
311 //
312 //*****************************************************************************
313 extern bool FlashCtl_A_isMemoryProtected(uint32_t addr);
314 
315 //*****************************************************************************
316 //
350 //
351 //*****************************************************************************
352 extern bool FlashCtl_A_verifyMemory(void* verifyAddr, uint32_t length,
353  uint_fast8_t pattern);
354 
355 //*****************************************************************************
356 //
376 //
377 //*****************************************************************************
378 extern bool FlashCtl_A_performMassErase(void);
379 
380 //*****************************************************************************
381 //
388 //
389 //*****************************************************************************
390 extern void FlashCtl_A_initiateMassErase(void);
391 
392 //*****************************************************************************
393 //
418 //
419 //*****************************************************************************
420 extern bool FlashCtl_A_eraseSector(uint32_t addr);
421 
422 //*****************************************************************************
423 //
453 //
454 //*****************************************************************************
455 extern bool FlashCtl_A_programMemory(void* src, void* dest,
456  uint32_t length);
457 
458 //*****************************************************************************
459 //
475 //
476 //*****************************************************************************
477 extern void FlashCtl_A_setProgramVerification(uint32_t verificationSetting);
478 
479 //*****************************************************************************
480 //
496 //
497 //*****************************************************************************
499  uint32_t verificationSetting);
500 
501 //*****************************************************************************
502 //
520 //
521 //*****************************************************************************
522 extern void FlashCtl_A_enableWordProgramming(uint32_t mode);
523 
524 //*****************************************************************************
525 //
532 //
533 //*****************************************************************************
534 extern void FlashCtl_A_disableWordProgramming(void);
535 
536 //*****************************************************************************
537 //
547 //
548 //*****************************************************************************
549 extern uint32_t FlashCtl_A_isWordProgrammingEnabled(void);
550 
551 //*****************************************************************************
552 //
572 //
573 //*****************************************************************************
574 extern bool FlashCtl_A_setReadMode(uint32_t flashBank, uint32_t readMode);
575 
576 //*****************************************************************************
577 //
594 //
595 //*****************************************************************************
596 extern uint32_t FlashCtl_A_getReadMode(uint32_t flashBank);
597 
598 //*****************************************************************************
599 //
611 //
612 //*****************************************************************************
613 extern void FlashCtl_A_setWaitState(uint32_t bank, uint32_t waitState);
614 
615 //*****************************************************************************
616 //
624 //
625 //*****************************************************************************
626 extern uint32_t FlashCtl_A_getWaitState(uint32_t bank);
627 
628 //*****************************************************************************
629 //
652 //
653 //*****************************************************************************
654 extern void FlashCtl_A_enableInterrupt(uint32_t flags);
655 
656 //*****************************************************************************
657 //
677 //
678 //*****************************************************************************
679 extern void FlashCtl_A_disableInterrupt(uint32_t flags);
680 
681 //*****************************************************************************
682 //
701 //
702 //*****************************************************************************
703 extern uint32_t FlashCtl_A_getEnabledInterruptStatus(void);
704 
705 //*****************************************************************************
706 //
722 //
723 //*****************************************************************************
724 extern uint32_t FlashCtl_A_getInterruptStatus(void);
725 
726 //*****************************************************************************
727 //
759 //
760 //*****************************************************************************
761 extern void FlashCtl_A_clearInterruptFlag(uint32_t flags);
762 
763 //*****************************************************************************
764 //
781 //
782 //*****************************************************************************
783 extern void FlashCtl_A_registerInterrupt(void (*intHandler)(void));
784 
785 //*****************************************************************************
786 //
797 //
798 //*****************************************************************************
799 extern void FlashCtl_A_unregisterInterrupt(void);
800 
801 //*****************************************************************************
802 //
817 //
818 //*****************************************************************************
819 extern void FlashCtl_A_initiateSectorErase(uint32_t addr);
820 
821 /* The following functions are advanced functions that are used by the flash
822  * driver to remask a failed bit in the event of a post or pre verification
823  * failure. They are meant to be advanced functions and should not be used
824  * by the majority of users (unless you are writing your own flash driver).
825  */
826 extern uint8_t __FlashCtl_A_remaskData8Post(uint8_t data, uint32_t addr);
827 extern uint8_t __FlashCtl_A_remaskData8Pre(uint8_t data, uint32_t addr);
828 extern uint32_t __FlashCtl_A_remaskData32Post(uint32_t data, uint32_t addr);
829 extern uint32_t __FlashCtl_A_remaskData32Pre(uint32_t data, uint32_t addr);
830 extern void __FlashCtl_A_remaskBurstDataPost(uint32_t addr, uint32_t size);
831 extern void __FlashCtl_A_remaskBurstDataPre(uint32_t addr, uint32_t size);
832 
833 //*****************************************************************************
834 //
835 // Mark the end of the C bindings section for C++ compilers.
836 //
837 //*****************************************************************************
838 #ifdef __cplusplus
839 }
840 #endif
841 
842 //*****************************************************************************
843 //
844 // Close the Doxygen group.
846 //
847 //*****************************************************************************
848 
849 #endif /* __MCU_HAS_FLCTL_A__ */
850 
851 #endif // __FLASH_A_H__
uint32_t FlashCtl_A_getWaitState(uint32_t bank)
Definition: flash_a.c:1415
uint32_t B0_MAIN_R7
Definition: flash_a.h:162
void FlashCtl_A_initiateSectorErase(uint32_t addr)
Definition: flash_a.c:1171
uint32_t B1_MAIN_R4
Definition: flash_a.h:167
uint32_t B0_MAIN_R3
Definition: flash_a.h:158
void FlashCtl_A_setProgramVerification(uint32_t verificationSetting)
Definition: flash_a.c:1332
void __FlashCtl_A_remaskBurstDataPost(uint32_t addr, uint32_t size)
Definition: flash_a.c:1714
bool FlashCtl_A_isMemoryProtected(uint32_t addr)
Definition: flash_a.c:422
void FlashCtl_A_enableInterrupt(uint32_t flags)
Definition: flash_a.c:1432
void FlashCtl_A_unregisterInterrupt(void)
Definition: flash_a.c:1470
uint32_t B1_MAIN_R0
Definition: flash_a.h:163
bool FlashCtl_A_programMemory(void *src, void *dest, uint32_t length)
Definition: flash_a.c:1214
uint32_t B1_MAIN_R7
Definition: flash_a.h:170
uint32_t B0_INFO_R0
Definition: flash_a.h:171
uint32_t B0_MAIN_R5
Definition: flash_a.h:160
uint32_t B1_MAIN_R1
Definition: flash_a.h:164
void FlashCtl_A_setWaitState(uint32_t bank, uint32_t waitState)
Definition: flash_a.c:1397
uint32_t FlashCtl_A_isWordProgrammingEnabled(void)
Definition: flash_a.c:1386
uint32_t __FlashCtl_A_remaskData32Pre(uint32_t data, uint32_t addr)
Definition: flash_a.c:1601
void FlashCtl_A_enableWordProgramming(uint32_t mode)
Definition: flash_a.c:1367
uint8_t __FlashCtl_A_remaskData8Post(uint8_t data, uint32_t addr)
Definition: flash_a.c:1483
void FlashCtl_A_initiateMassErase(void)
Definition: flash_a.c:929
uint32_t FlashCtl_A_getReadMode(uint32_t flashBank)
Definition: flash_a.c:912
void FlashCtl_A_getMemoryInfo(uint32_t addr, uint32_t *bankNum, uint32_t *sectorNum)
Definition: flash_a.c:104
bool FlashCtl_A_performMassErase(void)
Definition: flash_a.c:940
void FlashCtl_A_enableReadBuffering(uint_fast8_t memoryBank, uint_fast8_t accessMethod)
Definition: flash_a.c:388
bool FlashCtl_A_setReadMode(uint32_t flashBank, uint32_t readMode)
Definition: flash_a.c:883
uint32_t B0_MAIN_R0
Definition: flash_a.h:155
uint32_t FlashCtl_A_getEnabledInterruptStatus(void)
Definition: flash_a.c:1447
uint8_t __FlashCtl_A_remaskData8Pre(uint8_t data, uint32_t addr)
Definition: flash_a.c:1518
void FlashCtl_A_registerInterrupt(void(*intHandler)(void))
Definition: flash_a.c:1457
bool FlashCtl_A_verifyMemory(void *verifyAddr, uint32_t length, uint_fast8_t pattern)
Definition: flash_a.c:699
struct __sFlashCtl_ProtectionRegister __FlashCtl_ProtectionRegister
void FlashCtl_A_clearInterruptFlag(uint32_t flags)
Definition: flash_a.c:1452
uint32_t B0_MAIN_R6
Definition: flash_a.h:161
uint32_t B1_MAIN_R5
Definition: flash_a.h:168
bool FlashCtl_A_eraseSector(uint32_t addr)
Definition: flash_a.c:1065
void FlashCtl_A_clearProgramVerification(uint32_t verificationSetting)
Definition: flash_a.c:1349
bool FlashCtl_A_isMemoryRangeProtected(uint32_t startAddr, uint32_t endAddr)
Definition: flash_a.c:467
uint32_t B0_MAIN_R1
Definition: flash_a.h:156
uint32_t B1_INFO_R0
Definition: flash_a.h:172
uint32_t B0_MAIN_R4
Definition: flash_a.h:159
uint32_t FlashCtl_A_getInterruptStatus(void)
Definition: flash_a.c:1442
uint32_t B1_MAIN_R3
Definition: flash_a.h:166
uint32_t __FlashCtl_A_remaskData32Post(uint32_t data, uint32_t addr)
Definition: flash_a.c:1553
bool FlashCtl_A_protectMemory(uint32_t startAddr, uint32_t endAddr)
Definition: flash_a.c:592
bool FlashCtl_A_unprotectMemory(uint32_t startAddr, uint32_t endAddr)
Definition: flash_a.c:485
uint32_t B1_MAIN_R2
Definition: flash_a.h:165
void FlashCtl_A_disableReadBuffering(uint_fast8_t memoryBank, uint_fast8_t accessMethod)
Definition: flash_a.c:405
uint32_t B0_MAIN_R2
Definition: flash_a.h:157
void __FlashCtl_A_remaskBurstDataPre(uint32_t addr, uint32_t size)
Definition: flash_a.c:1649
Definition: flash_a.h:153
void FlashCtl_A_disableInterrupt(uint32_t flags)
Definition: flash_a.c:1437
void FlashCtl_A_disableWordProgramming(void)
Definition: flash_a.c:1381
uint32_t B1_MAIN_R6
Definition: flash_a.h:169

Copyright 2019, Texas Instruments Incorporated