1*5fd0122aSMatthias Ringwald /* --COPYRIGHT--,BSD 2*5fd0122aSMatthias Ringwald * Copyright (c) 2017, Texas Instruments Incorporated 3*5fd0122aSMatthias Ringwald * All rights reserved. 4*5fd0122aSMatthias Ringwald * 5*5fd0122aSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 6*5fd0122aSMatthias Ringwald * modification, are permitted provided that the following conditions 7*5fd0122aSMatthias Ringwald * are met: 8*5fd0122aSMatthias Ringwald * 9*5fd0122aSMatthias Ringwald * * Redistributions of source code must retain the above copyright 10*5fd0122aSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 11*5fd0122aSMatthias Ringwald * 12*5fd0122aSMatthias Ringwald * * Redistributions in binary form must reproduce the above copyright 13*5fd0122aSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 14*5fd0122aSMatthias Ringwald * documentation and/or other materials provided with the distribution. 15*5fd0122aSMatthias Ringwald * 16*5fd0122aSMatthias Ringwald * * Neither the name of Texas Instruments Incorporated nor the names of 17*5fd0122aSMatthias Ringwald * its contributors may be used to endorse or promote products derived 18*5fd0122aSMatthias Ringwald * from this software without specific prior written permission. 19*5fd0122aSMatthias Ringwald * 20*5fd0122aSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21*5fd0122aSMatthias Ringwald * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22*5fd0122aSMatthias Ringwald * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23*5fd0122aSMatthias Ringwald * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24*5fd0122aSMatthias Ringwald * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25*5fd0122aSMatthias Ringwald * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26*5fd0122aSMatthias Ringwald * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27*5fd0122aSMatthias Ringwald * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28*5fd0122aSMatthias Ringwald * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29*5fd0122aSMatthias Ringwald * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30*5fd0122aSMatthias Ringwald * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*5fd0122aSMatthias Ringwald * --/COPYRIGHT--*/ 32*5fd0122aSMatthias Ringwald #ifndef __FLASH_A_H__ 33*5fd0122aSMatthias Ringwald #define __FLASH_A_H__ 34*5fd0122aSMatthias Ringwald 35*5fd0122aSMatthias Ringwald #include <stdbool.h> 36*5fd0122aSMatthias Ringwald #include <ti/devices/msp432p4xx/inc/msp.h> 37*5fd0122aSMatthias Ringwald 38*5fd0122aSMatthias Ringwald /* Define to ensure that our current MSP432 has the FLCTL_A module. This 39*5fd0122aSMatthias Ringwald definition is included in the device specific header file */ 40*5fd0122aSMatthias Ringwald #ifdef __MCU_HAS_FLCTL_A__ 41*5fd0122aSMatthias Ringwald 42*5fd0122aSMatthias Ringwald //***************************************************************************** 43*5fd0122aSMatthias Ringwald // 44*5fd0122aSMatthias Ringwald //! \addtogroup flash_a_api 45*5fd0122aSMatthias Ringwald //! @{ 46*5fd0122aSMatthias Ringwald // 47*5fd0122aSMatthias Ringwald //***************************************************************************** 48*5fd0122aSMatthias Ringwald 49*5fd0122aSMatthias Ringwald //***************************************************************************** 50*5fd0122aSMatthias Ringwald // 51*5fd0122aSMatthias Ringwald // If building with a C++ compiler, make all of the definitions in this header 52*5fd0122aSMatthias Ringwald // have a C binding. 53*5fd0122aSMatthias Ringwald // 54*5fd0122aSMatthias Ringwald //***************************************************************************** 55*5fd0122aSMatthias Ringwald #ifdef __cplusplus 56*5fd0122aSMatthias Ringwald extern "C" 57*5fd0122aSMatthias Ringwald { 58*5fd0122aSMatthias Ringwald #endif 59*5fd0122aSMatthias Ringwald 60*5fd0122aSMatthias Ringwald //***************************************************************************** 61*5fd0122aSMatthias Ringwald // 62*5fd0122aSMatthias Ringwald // Control specific variables 63*5fd0122aSMatthias Ringwald // 64*5fd0122aSMatthias Ringwald //***************************************************************************** 65*5fd0122aSMatthias Ringwald #define FLASH_A_BURST_PRG_BIT 0x03 66*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR_SIZE 4096 67*5fd0122aSMatthias Ringwald 68*5fd0122aSMatthias Ringwald /* Interrupts */ 69*5fd0122aSMatthias Ringwald #define FLASH_A_PROGRAM_ERROR FLCTL_A_IFG_PRG_ERR 70*5fd0122aSMatthias Ringwald #define FLASH_A_BENCHMARK_INT FLCTL_A_IFG_BMRK 71*5fd0122aSMatthias Ringwald #define FLASH_A_ERASE_COMPLETE FLCTL_A_IFG_ERASE 72*5fd0122aSMatthias Ringwald #define FLASH_A_BRSTPRGM_COMPLETE FLCTL_A_IFG_PRGB 73*5fd0122aSMatthias Ringwald #define FLASH_A_WRDPRGM_COMPLETE FLCTL_A_IFG_PRG 74*5fd0122aSMatthias Ringwald #define FLASH_A_POSTVERIFY_FAILED FLCTL_A_IFG_AVPST 75*5fd0122aSMatthias Ringwald #define FLASH_A_PREVERIFY_FAILED FLCTL_A_IFG_AVPRE 76*5fd0122aSMatthias Ringwald #define FLASH_A_BRSTRDCMP_COMPLETE FLCTL_A_IFG_RDBRST 77*5fd0122aSMatthias Ringwald 78*5fd0122aSMatthias Ringwald #define FLASH_A_NORMAL_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_0 79*5fd0122aSMatthias Ringwald #define FLASH_A_MARGIN0_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_1 80*5fd0122aSMatthias Ringwald #define FLASH_A_MARGIN1_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_2 81*5fd0122aSMatthias Ringwald #define FLASH_A_PROGRAM_VERIFY_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_3 82*5fd0122aSMatthias Ringwald #define FLASH_A_ERASE_VERIFY_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_4 83*5fd0122aSMatthias Ringwald #define FLASH_A_LEAKAGE_VERIFY_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_5 84*5fd0122aSMatthias Ringwald #define FLASH_A_MARGIN0B_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_9 85*5fd0122aSMatthias Ringwald #define FLASH_A_MARGIN1B_READ_MODE FLCTL_A_BANK0_RDCTL_RD_MODE_10 86*5fd0122aSMatthias Ringwald 87*5fd0122aSMatthias Ringwald #define FLASH_A_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE FLCTL_A_PRGBRST_CTLSTAT_BURST_STATUS_7 88*5fd0122aSMatthias Ringwald 89*5fd0122aSMatthias Ringwald #define FLASH_A_BANK0 0x00 90*5fd0122aSMatthias Ringwald #define FLASH_A_BANK1 0x01 91*5fd0122aSMatthias Ringwald #define FLASH_A_DATA_READ 0x00 92*5fd0122aSMatthias Ringwald #define FLASH_A_INSTRUCTION_FETCH 0x01 93*5fd0122aSMatthias Ringwald 94*5fd0122aSMatthias Ringwald #define FLASH_A_MAIN_MEMORY_SPACE_BANK0 0x01 95*5fd0122aSMatthias Ringwald #define FLASH_A_MAIN_MEMORY_SPACE_BANK1 0x02 96*5fd0122aSMatthias Ringwald #define FLASH_A_INFO_MEMORY_SPACE_BANK0 0x03 97*5fd0122aSMatthias Ringwald #define FLASH_A_INFO_MEMORY_SPACE_BANK1 0x04 98*5fd0122aSMatthias Ringwald 99*5fd0122aSMatthias Ringwald #define FLASH_A_MAIN_SPACE FLCTL_A_RDBRST_CTLSTAT_MEM_TYPE_0 100*5fd0122aSMatthias Ringwald #define FLASH_A_INFO_SPACE FLCTL_A_RDBRST_CTLSTAT_MEM_TYPE_1 101*5fd0122aSMatthias Ringwald #define FLASH_A_1_PATTERN FLCTL_A_RDBRST_CTLSTAT_DATA_CMP 102*5fd0122aSMatthias Ringwald #define FLASH_A_0_PATTERN 0x00 103*5fd0122aSMatthias Ringwald 104*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR0 FLCTL_A_BANK0_MAIN_WEPROT_PROT0 105*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR1 FLCTL_A_BANK0_MAIN_WEPROT_PROT1 106*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR2 FLCTL_A_BANK0_MAIN_WEPROT_PROT2 107*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR3 FLCTL_A_BANK0_MAIN_WEPROT_PROT3 108*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR4 FLCTL_A_BANK0_MAIN_WEPROT_PROT4 109*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR5 FLCTL_A_BANK0_MAIN_WEPROT_PROT5 110*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR6 FLCTL_A_BANK0_MAIN_WEPROT_PROT6 111*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR7 FLCTL_A_BANK0_MAIN_WEPROT_PROT7 112*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR8 FLCTL_A_BANK0_MAIN_WEPROT_PROT8 113*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR9 FLCTL_A_BANK0_MAIN_WEPROT_PROT9 114*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR10 FLCTL_A_BANK0_MAIN_WEPROT_PROT10 115*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR11 FLCTL_A_BANK0_MAIN_WEPROT_PROT11 116*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR12 FLCTL_A_BANK0_MAIN_WEPROT_PROT12 117*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR13 FLCTL_A_BANK0_MAIN_WEPROT_PROT13 118*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR14 FLCTL_A_BANK0_MAIN_WEPROT_PROT14 119*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR15 FLCTL_A_BANK0_MAIN_WEPROT_PROT15 120*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR16 FLCTL_A_BANK0_MAIN_WEPROT_PROT16 121*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR17 FLCTL_A_BANK0_MAIN_WEPROT_PROT17 122*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR18 FLCTL_A_BANK0_MAIN_WEPROT_PROT18 123*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR19 FLCTL_A_BANK0_MAIN_WEPROT_PROT19 124*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR20 FLCTL_A_BANK0_MAIN_WEPROT_PROT20 125*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR21 FLCTL_A_BANK0_MAIN_WEPROT_PROT21 126*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR22 FLCTL_A_BANK0_MAIN_WEPROT_PROT22 127*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR23 FLCTL_A_BANK0_MAIN_WEPROT_PROT23 128*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR24 FLCTL_A_BANK0_MAIN_WEPROT_PROT24 129*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR25 FLCTL_A_BANK0_MAIN_WEPROT_PROT25 130*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR26 FLCTL_A_BANK0_MAIN_WEPROT_PROT26 131*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR27 FLCTL_A_BANK0_MAIN_WEPROT_PROT27 132*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR28 FLCTL_A_BANK0_MAIN_WEPROT_PROT28 133*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR29 FLCTL_A_BANK0_MAIN_WEPROT_PROT29 134*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR30 FLCTL_A_BANK0_MAIN_WEPROT_PROT30 135*5fd0122aSMatthias Ringwald #define FLASH_A_SECTOR31 FLCTL_A_BANK0_MAIN_WEPROT_PROT31 136*5fd0122aSMatthias Ringwald 137*5fd0122aSMatthias Ringwald #define FLASH_A_NOVER 0 138*5fd0122aSMatthias Ringwald #define FLASH_A_BURSTPOST FLCTL_A_PRGBRST_CTLSTAT_AUTO_PST 139*5fd0122aSMatthias Ringwald #define FLASH_A_BURSTPRE FLCTL_A_PRGBRST_CTLSTAT_AUTO_PRE 140*5fd0122aSMatthias Ringwald #define FLASH_A_REGPRE FLCTL_A_PRG_CTLSTAT_VER_PRE 141*5fd0122aSMatthias Ringwald #define FLASH_A_REGPOST FLCTL_A_PRG_CTLSTAT_VER_PST 142*5fd0122aSMatthias Ringwald #define FLASH_A_FULLVER (FLCTL_A_PRGBRST_CTLSTAT_AUTO_PST | \ 143*5fd0122aSMatthias Ringwald FLCTL_A_PRGBRST_CTLSTAT_AUTO_PRE | FLCTL_A_PRG_CTLSTAT_VER_PRE \ 144*5fd0122aSMatthias Ringwald | FLCTL_A_PRG_CTLSTAT_VER_PST) 145*5fd0122aSMatthias Ringwald 146*5fd0122aSMatthias Ringwald #define FLASH_A_COLLATED_WRITE_MODE 0x01 147*5fd0122aSMatthias Ringwald #define FLASH_A_IMMEDIATE_WRITE_MODE 0x02 148*5fd0122aSMatthias Ringwald 149*5fd0122aSMatthias Ringwald /* Internal parameters/definitions */ 150*5fd0122aSMatthias Ringwald #define __INFO_FLASH_A_TECH_START__ 0x00200000 151*5fd0122aSMatthias Ringwald #define __INFO_FLASH_A_TECH_MIDDLE__ 0x00204000 152*5fd0122aSMatthias Ringwald 153*5fd0122aSMatthias Ringwald typedef struct __sFlashCtl_ProtectionRegister 154*5fd0122aSMatthias Ringwald { 155*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R0; 156*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R1; 157*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R2; 158*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R3; 159*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R4; 160*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R5; 161*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R6; 162*5fd0122aSMatthias Ringwald uint32_t B0_MAIN_R7; 163*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R0; 164*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R1; 165*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R2; 166*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R3; 167*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R4; 168*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R5; 169*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R6; 170*5fd0122aSMatthias Ringwald uint32_t B1_MAIN_R7; 171*5fd0122aSMatthias Ringwald uint32_t B0_INFO_R0; 172*5fd0122aSMatthias Ringwald uint32_t B1_INFO_R0; 173*5fd0122aSMatthias Ringwald } __FlashCtl_ProtectionRegister; 174*5fd0122aSMatthias Ringwald 175*5fd0122aSMatthias Ringwald //***************************************************************************** 176*5fd0122aSMatthias Ringwald // 177*5fd0122aSMatthias Ringwald // Prototypes for the APIs. 178*5fd0122aSMatthias Ringwald // 179*5fd0122aSMatthias Ringwald //***************************************************************************** 180*5fd0122aSMatthias Ringwald 181*5fd0122aSMatthias Ringwald //***************************************************************************** 182*5fd0122aSMatthias Ringwald // 183*5fd0122aSMatthias Ringwald //! Calculates the flash bank and sector number given an address. Stores the 184*5fd0122aSMatthias Ringwald //! results into the two pointers given as parameters. The user must provide 185*5fd0122aSMatthias Ringwald //! a valid memory address (an address in SRAM for example will give an invalid 186*5fd0122aSMatthias Ringwald //! result). 187*5fd0122aSMatthias Ringwald //! 188*5fd0122aSMatthias Ringwald //! \param addr Address to calculate the bank/sector information for 189*5fd0122aSMatthias Ringwald //! 190*5fd0122aSMatthias Ringwald //! \param bankNum The bank number will be stored in here after the function 191*5fd0122aSMatthias Ringwald //! completes. 192*5fd0122aSMatthias Ringwald //! 193*5fd0122aSMatthias Ringwald //! \param sectorNum The sector number will be stored in here after the function 194*5fd0122aSMatthias Ringwald //! completes. 195*5fd0122aSMatthias Ringwald //! 196*5fd0122aSMatthias Ringwald //! \note For simplicity, this API only works with address in MAIN flash memory. 197*5fd0122aSMatthias Ringwald //! For calculating the sector/bank number of an address in info memory, 198*5fd0122aSMatthias Ringwald //! please refer to your device datasheet/ 199*5fd0122aSMatthias Ringwald //! 200*5fd0122aSMatthias Ringwald //! \return None. 201*5fd0122aSMatthias Ringwald // 202*5fd0122aSMatthias Ringwald //***************************************************************************** 203*5fd0122aSMatthias Ringwald extern void FlashCtl_A_getMemoryInfo(uint32_t addr, uint32_t *bankNum, 204*5fd0122aSMatthias Ringwald uint32_t *sectorNum); 205*5fd0122aSMatthias Ringwald 206*5fd0122aSMatthias Ringwald //***************************************************************************** 207*5fd0122aSMatthias Ringwald // 208*5fd0122aSMatthias Ringwald //! Enables read buffering on accesses to a specified bank of flash memory 209*5fd0122aSMatthias Ringwald //! 210*5fd0122aSMatthias Ringwald //! \param memoryBank is the value of the memory bank to enable read 211*5fd0122aSMatthias Ringwald //! buffering. Must be only one of the following values: 212*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK0, 213*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK1 214*5fd0122aSMatthias Ringwald //! 215*5fd0122aSMatthias Ringwald //! \param accessMethod is the value of the access type to enable read 216*5fd0122aSMatthias Ringwald //! buffering. Must be only one of the following values: 217*5fd0122aSMatthias Ringwald //! - \b FLASH_A_DATA_READ, 218*5fd0122aSMatthias Ringwald //! - \b FLASH_A_INSTRUCTION_FETCH 219*5fd0122aSMatthias Ringwald //! 220*5fd0122aSMatthias Ringwald //! \return None. 221*5fd0122aSMatthias Ringwald // 222*5fd0122aSMatthias Ringwald //***************************************************************************** 223*5fd0122aSMatthias Ringwald extern void FlashCtl_A_enableReadBuffering(uint_fast8_t memoryBank, 224*5fd0122aSMatthias Ringwald uint_fast8_t accessMethod); 225*5fd0122aSMatthias Ringwald 226*5fd0122aSMatthias Ringwald //***************************************************************************** 227*5fd0122aSMatthias Ringwald // 228*5fd0122aSMatthias Ringwald //! Disables read buffering on accesses to a specified bank of flash memory 229*5fd0122aSMatthias Ringwald //! 230*5fd0122aSMatthias Ringwald //! \param memoryBank is the value of the memory bank to disable read 231*5fd0122aSMatthias Ringwald //! buffering. Must be only one of the following values: 232*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK0, 233*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK1 234*5fd0122aSMatthias Ringwald //! 235*5fd0122aSMatthias Ringwald //! \param accessMethod is the value of the access type to disable read 236*5fd0122aSMatthias Ringwald //! buffering. Must ne only one of the following values: 237*5fd0122aSMatthias Ringwald //! - \b FLASH_A_DATA_READ, 238*5fd0122aSMatthias Ringwald //! - \b FLASH_A_INSTRUCTION_FETCH 239*5fd0122aSMatthias Ringwald //! 240*5fd0122aSMatthias Ringwald //! \return None. 241*5fd0122aSMatthias Ringwald // 242*5fd0122aSMatthias Ringwald //***************************************************************************** 243*5fd0122aSMatthias Ringwald extern void FlashCtl_A_disableReadBuffering(uint_fast8_t memoryBank, 244*5fd0122aSMatthias Ringwald uint_fast8_t accessMethod); 245*5fd0122aSMatthias Ringwald 246*5fd0122aSMatthias Ringwald //***************************************************************************** 247*5fd0122aSMatthias Ringwald // 248*5fd0122aSMatthias Ringwald //! Enables protection on the given flash memory range from writes. Note that 249*5fd0122aSMatthias Ringwald //! this function only works on flash memory and giving in an address to ROM 250*5fd0122aSMatthias Ringwald //! or SRAM will result in unreliable behavior. 251*5fd0122aSMatthias Ringwald //! 252*5fd0122aSMatthias Ringwald //! \param startAddr is the start address of the memory to protect 253*5fd0122aSMatthias Ringwald //! 254*5fd0122aSMatthias Ringwald //! \param endAddr is the end address of the memory to protect 255*5fd0122aSMatthias Ringwald //! 256*5fd0122aSMatthias Ringwald //! \note Flash memory is organized by protection by sector sizes. This means 257*5fd0122aSMatthias Ringwald //! that you will only be able to protect/unprotect memory based off 258*5fd0122aSMatthias Ringwald //! 4096 aligned boundaries. 259*5fd0122aSMatthias Ringwald //! 260*5fd0122aSMatthias Ringwald //! \return true if sector protection enabled false otherwise. 261*5fd0122aSMatthias Ringwald // 262*5fd0122aSMatthias Ringwald //***************************************************************************** 263*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_protectMemory(uint32_t startAddr, uint32_t endAddr); 264*5fd0122aSMatthias Ringwald 265*5fd0122aSMatthias Ringwald //***************************************************************************** 266*5fd0122aSMatthias Ringwald // 267*5fd0122aSMatthias Ringwald //! Disables protection on the given flash memory range from writes. Note that 268*5fd0122aSMatthias Ringwald //! this function only works on flash memory and giving in an address to ROM 269*5fd0122aSMatthias Ringwald //! or SRAM will result in unreliable behavior. 270*5fd0122aSMatthias Ringwald //! 271*5fd0122aSMatthias Ringwald //! \param startAddr is the start address of the memory to unprotect 272*5fd0122aSMatthias Ringwald //! 273*5fd0122aSMatthias Ringwald //! \param endAddr is the end address of the memory to unprotect 274*5fd0122aSMatthias Ringwald //! 275*5fd0122aSMatthias Ringwald //! \note Flash memory is organized by protection by sector sizes. This means 276*5fd0122aSMatthias Ringwald //! that you will only be able to protect/unprotect memory based off 277*5fd0122aSMatthias Ringwald //! 4096 aligned boundaries. 278*5fd0122aSMatthias Ringwald //! 279*5fd0122aSMatthias Ringwald //! \return true if sector protection enabled false otherwise. 280*5fd0122aSMatthias Ringwald // 281*5fd0122aSMatthias Ringwald //***************************************************************************** 282*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_unprotectMemory(uint32_t startAddr, uint32_t endAddr); 283*5fd0122aSMatthias Ringwald 284*5fd0122aSMatthias Ringwald //***************************************************************************** 285*5fd0122aSMatthias Ringwald // 286*5fd0122aSMatthias Ringwald //! Scans over the given memory range and returns false if any of the inclusive 287*5fd0122aSMatthias Ringwald //! memory addresses is protect from writes. 288*5fd0122aSMatthias Ringwald //! 289*5fd0122aSMatthias Ringwald //! \param startAddr is the start address to scan 290*5fd0122aSMatthias Ringwald //! 291*5fd0122aSMatthias Ringwald //! \param endAddr is the end address to scan 292*5fd0122aSMatthias Ringwald //! 293*5fd0122aSMatthias Ringwald //! \return true if sector protection enabled on any of the incluseive memory 294*5fd0122aSMatthias Ringwald //! addresses, false otherwise. 295*5fd0122aSMatthias Ringwald // 296*5fd0122aSMatthias Ringwald //***************************************************************************** 297*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_isMemoryRangeProtected(uint32_t startAddr, 298*5fd0122aSMatthias Ringwald uint32_t endAddr); 299*5fd0122aSMatthias Ringwald 300*5fd0122aSMatthias Ringwald //***************************************************************************** 301*5fd0122aSMatthias Ringwald // 302*5fd0122aSMatthias Ringwald //! Scans over the given memory range and returns false if any of the inclusive 303*5fd0122aSMatthias Ringwald //! memory addresses is protect from writes. 304*5fd0122aSMatthias Ringwald //! 305*5fd0122aSMatthias Ringwald //! \param startAddr is the start address to scan 306*5fd0122aSMatthias Ringwald //! 307*5fd0122aSMatthias Ringwald //! \param endAddr is the end address to scan 308*5fd0122aSMatthias Ringwald //! 309*5fd0122aSMatthias Ringwald //! \return true if sector protection enabled on any of the incluseive memory 310*5fd0122aSMatthias Ringwald //! addresses, false otherwise. 311*5fd0122aSMatthias Ringwald // 312*5fd0122aSMatthias Ringwald //***************************************************************************** 313*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_isMemoryProtected(uint32_t addr); 314*5fd0122aSMatthias Ringwald 315*5fd0122aSMatthias Ringwald //***************************************************************************** 316*5fd0122aSMatthias Ringwald // 317*5fd0122aSMatthias Ringwald //! Verifies a given segment of memory based off either a high (1) or low (0) 318*5fd0122aSMatthias Ringwald //! state. 319*5fd0122aSMatthias Ringwald //! 320*5fd0122aSMatthias Ringwald //! \param verifyAddr Start address where verification will begin 321*5fd0122aSMatthias Ringwald //! 322*5fd0122aSMatthias Ringwald //! \param length Length in bytes to verify based off the pattern 323*5fd0122aSMatthias Ringwald //! 324*5fd0122aSMatthias Ringwald //! \param pattern The pattern which verification will check versus. This can 325*5fd0122aSMatthias Ringwald //! either be a low pattern (each register will be checked versus a pattern 326*5fd0122aSMatthias Ringwald //! of 32 zeros, or a high pattern (each register will be checked versus a 327*5fd0122aSMatthias Ringwald //! pattern of 32 ones). Valid values are: FLASH_A_0_PATTERN, FLASH_A_1_PATTERN 328*5fd0122aSMatthias Ringwald //! 329*5fd0122aSMatthias Ringwald //! \note There are no sector/boundary restrictions for this function, 330*5fd0122aSMatthias Ringwald //! however it is encouraged to proved a start address aligned on 32-bit 331*5fd0122aSMatthias Ringwald //! boundaries. Providing an unaligned address will result in unaligned data 332*5fd0122aSMatthias Ringwald //! accesses and detriment efficiency. 333*5fd0122aSMatthias Ringwald //! 334*5fd0122aSMatthias Ringwald //! \note This function is blocking and will not exit until operation has 335*5fd0122aSMatthias Ringwald //! either completed or failed due to an error. Furthermore, given the 336*5fd0122aSMatthias Ringwald //! complex verification requirements of the flash controller, master 337*5fd0122aSMatthias Ringwald //! interrupts are disabled throughout execution of this function. The original 338*5fd0122aSMatthias Ringwald //! interrupt context is saved at the start of execution and restored prior 339*5fd0122aSMatthias Ringwald //! to exit of the API. 340*5fd0122aSMatthias Ringwald //! 341*5fd0122aSMatthias Ringwald //! \note Due to the hardware limitations of the flash controller, this 342*5fd0122aSMatthias Ringwald //! function cannot verify a memory adress in the same flash bank that it 343*5fd0122aSMatthias Ringwald //! is executing from. If using the ROM version of this API (by using the 344*5fd0122aSMatthias Ringwald //! (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides 345*5fd0122aSMatthias Ringwald //! in flash then special care needs to be taken to ensure no code execution 346*5fd0122aSMatthias Ringwald //! or reads happen in the flash bank being programmed while this API is 347*5fd0122aSMatthias Ringwald //! being executed. 348*5fd0122aSMatthias Ringwald //! 349*5fd0122aSMatthias Ringwald //! \return true if memory verification is successful, false otherwise. 350*5fd0122aSMatthias Ringwald // 351*5fd0122aSMatthias Ringwald //***************************************************************************** 352*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_verifyMemory(void* verifyAddr, uint32_t length, 353*5fd0122aSMatthias Ringwald uint_fast8_t pattern); 354*5fd0122aSMatthias Ringwald 355*5fd0122aSMatthias Ringwald //***************************************************************************** 356*5fd0122aSMatthias Ringwald // 357*5fd0122aSMatthias Ringwald //! Performs a mass erase on all unprotected flash sectors. Protected sectors 358*5fd0122aSMatthias Ringwald //! are ignored. 359*5fd0122aSMatthias Ringwald //! 360*5fd0122aSMatthias Ringwald //! \note This function is blocking and will not exit until operation has 361*5fd0122aSMatthias Ringwald //! either completed or failed due to an error. Furthermore, given the 362*5fd0122aSMatthias Ringwald //! complex verification requirements of the flash controller, master 363*5fd0122aSMatthias Ringwald //! interrupts are disabled throughout execution of this function. The original 364*5fd0122aSMatthias Ringwald //! interrupt context is saved at the start of execution and restored prior 365*5fd0122aSMatthias Ringwald //! to exit of the API. 366*5fd0122aSMatthias Ringwald //! 367*5fd0122aSMatthias Ringwald //! \note Due to the hardware limitations of the flash controller, this 368*5fd0122aSMatthias Ringwald //! function cannot erase a memory adress in the same flash bank that it 369*5fd0122aSMatthias Ringwald //! is executing from. If using the ROM version of this API (by using the 370*5fd0122aSMatthias Ringwald //! (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides 371*5fd0122aSMatthias Ringwald //! in flash then special care needs to be taken to ensure no code execution 372*5fd0122aSMatthias Ringwald //! or reads happen in the flash bank being programmed while this API is 373*5fd0122aSMatthias Ringwald //! being executed. 374*5fd0122aSMatthias Ringwald //! 375*5fd0122aSMatthias Ringwald //! \return true if mass erase completes successfully, false otherwise 376*5fd0122aSMatthias Ringwald // 377*5fd0122aSMatthias Ringwald //***************************************************************************** 378*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_performMassErase(void); 379*5fd0122aSMatthias Ringwald 380*5fd0122aSMatthias Ringwald //***************************************************************************** 381*5fd0122aSMatthias Ringwald // 382*5fd0122aSMatthias Ringwald //! Initiates a mass erase and returns control back to the program. This is a 383*5fd0122aSMatthias Ringwald //! non-blocking function, however it is the user's responsibility to perform 384*5fd0122aSMatthias Ringwald //! the necessary verification requirements after the interrupt is set to 385*5fd0122aSMatthias Ringwald //! signify completion. 386*5fd0122aSMatthias Ringwald //! 387*5fd0122aSMatthias Ringwald //! \return None 388*5fd0122aSMatthias Ringwald // 389*5fd0122aSMatthias Ringwald //***************************************************************************** 390*5fd0122aSMatthias Ringwald extern void FlashCtl_A_initiateMassErase(void); 391*5fd0122aSMatthias Ringwald 392*5fd0122aSMatthias Ringwald //***************************************************************************** 393*5fd0122aSMatthias Ringwald // 394*5fd0122aSMatthias Ringwald //! Erases a sector of MAIN or INFO flash memory. 395*5fd0122aSMatthias Ringwald //! 396*5fd0122aSMatthias Ringwald //! \param addr The start of the sector to erase. Note that with flash, 397*5fd0122aSMatthias Ringwald //! the minimum allowed size that can be erased is a flash sector 398*5fd0122aSMatthias Ringwald //! (which is 4KB on the MSP432 family). If an address is provided to 399*5fd0122aSMatthias Ringwald //! this function which is not on a 4KB boundary, the entire sector 400*5fd0122aSMatthias Ringwald //! will still be erased. 401*5fd0122aSMatthias Ringwald //! 402*5fd0122aSMatthias Ringwald //! \note This function is blocking and will not exit until operation has 403*5fd0122aSMatthias Ringwald //! either completed or failed due to an error. Furthermore, given the 404*5fd0122aSMatthias Ringwald //! complex verification requirements of the flash controller, master 405*5fd0122aSMatthias Ringwald //! interrupts are disabled throughout execution of this function. The original 406*5fd0122aSMatthias Ringwald //! interrupt context is saved at the start of execution and restored prior 407*5fd0122aSMatthias Ringwald //! to exit of the API. 408*5fd0122aSMatthias Ringwald //! 409*5fd0122aSMatthias Ringwald //! \note Due to the hardware limitations of the flash controller, this 410*5fd0122aSMatthias Ringwald //! function cannot erase a memory adress in the same flash bank that it 411*5fd0122aSMatthias Ringwald //! is executing from. If using the ROM version of this API (by using the 412*5fd0122aSMatthias Ringwald //! (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides 413*5fd0122aSMatthias Ringwald //! in flash then special care needs to be taken to ensure no code execution 414*5fd0122aSMatthias Ringwald //! or reads happen in the flash bank being programmed while this API is 415*5fd0122aSMatthias Ringwald //! being executed. 416*5fd0122aSMatthias Ringwald //! 417*5fd0122aSMatthias Ringwald //! \return true if sector erase is successful, false otherwise. 418*5fd0122aSMatthias Ringwald // 419*5fd0122aSMatthias Ringwald //***************************************************************************** 420*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_eraseSector(uint32_t addr); 421*5fd0122aSMatthias Ringwald 422*5fd0122aSMatthias Ringwald //***************************************************************************** 423*5fd0122aSMatthias Ringwald // 424*5fd0122aSMatthias Ringwald //! Program a portion of flash memory with the provided data 425*5fd0122aSMatthias Ringwald //! 426*5fd0122aSMatthias Ringwald //! \param src Pointer to the data source to program into flash 427*5fd0122aSMatthias Ringwald //! 428*5fd0122aSMatthias Ringwald //! \param dest Pointer to the destination in flash to program 429*5fd0122aSMatthias Ringwald //! 430*5fd0122aSMatthias Ringwald //! \param length Length in bytes to program 431*5fd0122aSMatthias Ringwald //! 432*5fd0122aSMatthias Ringwald //! \note There are no sector/boundary restrictions for this function, 433*5fd0122aSMatthias Ringwald //! however it is encouraged to proved a start address aligned on 32-bit 434*5fd0122aSMatthias Ringwald //! boundaries. Providing an unaligned address will result in unaligned data 435*5fd0122aSMatthias Ringwald //! accesses and detriment efficiency. 436*5fd0122aSMatthias Ringwald //! 437*5fd0122aSMatthias Ringwald //! \note This function is blocking and will not exit until operation has 438*5fd0122aSMatthias Ringwald //! either completed or failed due to an error. Furthermore, given the 439*5fd0122aSMatthias Ringwald //! complex verification requirements of the flash controller, master 440*5fd0122aSMatthias Ringwald //! interrupts are disabled throughout execution of this function. The original 441*5fd0122aSMatthias Ringwald //! interrupt context is saved at the start of execution and restored prior 442*5fd0122aSMatthias Ringwald //! to exit of the API. 443*5fd0122aSMatthias Ringwald //! 444*5fd0122aSMatthias Ringwald //! \note Due to the hardware limitations of the flash controller, this 445*5fd0122aSMatthias Ringwald //! function cannot program a memory adress in the same flash bank that it 446*5fd0122aSMatthias Ringwald //! is executing from. If using the ROM version of this API (by using the 447*5fd0122aSMatthias Ringwald //! (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides 448*5fd0122aSMatthias Ringwald //! in flash then special care needs to be taken to ensure no code execution 449*5fd0122aSMatthias Ringwald //! or reads happen in the flash bank being programmed while this API is 450*5fd0122aSMatthias Ringwald //! being executed. 451*5fd0122aSMatthias Ringwald //! 452*5fd0122aSMatthias Ringwald //! \return Whether or not the program succeeded 453*5fd0122aSMatthias Ringwald // 454*5fd0122aSMatthias Ringwald //***************************************************************************** 455*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_programMemory(void* src, void* dest, 456*5fd0122aSMatthias Ringwald uint32_t length); 457*5fd0122aSMatthias Ringwald 458*5fd0122aSMatthias Ringwald //***************************************************************************** 459*5fd0122aSMatthias Ringwald // 460*5fd0122aSMatthias Ringwald //! Setups pre/post verification of burst and regular flash programming 461*5fd0122aSMatthias Ringwald //! instructions. Note that this API is for advanced users that are programming 462*5fd0122aSMatthias Ringwald //! their own flash drivers. The program/erase APIs are not affected by this 463*5fd0122aSMatthias Ringwald //! setting and take care of the verification requirements. 464*5fd0122aSMatthias Ringwald //! 465*5fd0122aSMatthias Ringwald //! \param verificationSetting Verification setting to set. This value can 466*5fd0122aSMatthias Ringwald //! be a bitwise OR of the following values: 467*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BURSTPOST, 468*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BURSTPRE, 469*5fd0122aSMatthias Ringwald //! - \b FLASH_A_REGPRE, 470*5fd0122aSMatthias Ringwald //! - \b FLASH_A_REGPOST 471*5fd0122aSMatthias Ringwald //! - \b FLASH_A_NOVER No verification enabled 472*5fd0122aSMatthias Ringwald //! - \b FLASH_A_FULLVER Full verification enabled 473*5fd0122aSMatthias Ringwald //! 474*5fd0122aSMatthias Ringwald //! \return none 475*5fd0122aSMatthias Ringwald // 476*5fd0122aSMatthias Ringwald //***************************************************************************** 477*5fd0122aSMatthias Ringwald extern void FlashCtl_A_setProgramVerification(uint32_t verificationSetting); 478*5fd0122aSMatthias Ringwald 479*5fd0122aSMatthias Ringwald //***************************************************************************** 480*5fd0122aSMatthias Ringwald // 481*5fd0122aSMatthias Ringwald //! Clears pre/post verification of burst and regular flash programming 482*5fd0122aSMatthias Ringwald //! instructions. Note that this API is for advanced users that are programming 483*5fd0122aSMatthias Ringwald //! their own flash drivers. The program/erase APIs are not affected by this 484*5fd0122aSMatthias Ringwald //! setting and take care of the verification requirements. 485*5fd0122aSMatthias Ringwald //! 486*5fd0122aSMatthias Ringwald //! \param verificationSetting Verification setting to clear. This value can 487*5fd0122aSMatthias Ringwald //! be a bitwise OR of the following values: 488*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BURSTPOST, 489*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BURSTPRE, 490*5fd0122aSMatthias Ringwald //! - \b FLASH_A_REGPRE, 491*5fd0122aSMatthias Ringwald //! - \b FLASH_A_REGPOST 492*5fd0122aSMatthias Ringwald //! - \b FLASH_A_NOVER No verification enabled 493*5fd0122aSMatthias Ringwald //! - \b FLASH_A_FULLVER Full verification enabled 494*5fd0122aSMatthias Ringwald //! 495*5fd0122aSMatthias Ringwald //! \return none 496*5fd0122aSMatthias Ringwald // 497*5fd0122aSMatthias Ringwald //***************************************************************************** 498*5fd0122aSMatthias Ringwald extern void FlashCtl_A_clearProgramVerification( 499*5fd0122aSMatthias Ringwald uint32_t verificationSetting); 500*5fd0122aSMatthias Ringwald 501*5fd0122aSMatthias Ringwald //***************************************************************************** 502*5fd0122aSMatthias Ringwald // 503*5fd0122aSMatthias Ringwald //! Enables word programming of flash memory. 504*5fd0122aSMatthias Ringwald //! 505*5fd0122aSMatthias Ringwald //! This function will enable word programming of the flash memory and set the 506*5fd0122aSMatthias Ringwald //! mode of behavior when the flash write occurs. 507*5fd0122aSMatthias Ringwald //! 508*5fd0122aSMatthias Ringwald //! \param mode The mode specifies the behavior of the flash controller when 509*5fd0122aSMatthias Ringwald //! programming words to flash. In \b FLASH_A_IMMEDIATE_WRITE_MODE, the 510*5fd0122aSMatthias Ringwald //! program operation happens immediately on the write to flash while 511*5fd0122aSMatthias Ringwald //! in \b FLASH_A_COLLATED_WRITE_MODE the write will be delayed until a full 512*5fd0122aSMatthias Ringwald //! 128-bits have been collated. Possible values include: 513*5fd0122aSMatthias Ringwald //! - \b FLASH_A_IMMEDIATE_WRITE_MODE 514*5fd0122aSMatthias Ringwald //! - \b FLASH_A_COLLATED_WRITE_MODE 515*5fd0122aSMatthias Ringwald //! 516*5fd0122aSMatthias Ringwald //! 517*5fd0122aSMatthias Ringwald //! Refer to the user's guide for further documentation. 518*5fd0122aSMatthias Ringwald //! 519*5fd0122aSMatthias Ringwald //! \return none 520*5fd0122aSMatthias Ringwald // 521*5fd0122aSMatthias Ringwald //***************************************************************************** 522*5fd0122aSMatthias Ringwald extern void FlashCtl_A_enableWordProgramming(uint32_t mode); 523*5fd0122aSMatthias Ringwald 524*5fd0122aSMatthias Ringwald //***************************************************************************** 525*5fd0122aSMatthias Ringwald // 526*5fd0122aSMatthias Ringwald //! Disables word programming of flash memory. 527*5fd0122aSMatthias Ringwald //! 528*5fd0122aSMatthias Ringwald //! Refer to FlashCtl_A_enableWordProgramming and the user's guide for description 529*5fd0122aSMatthias Ringwald //! on the difference between full word and immediate programming 530*5fd0122aSMatthias Ringwald //! 531*5fd0122aSMatthias Ringwald //! \return None. 532*5fd0122aSMatthias Ringwald // 533*5fd0122aSMatthias Ringwald //***************************************************************************** 534*5fd0122aSMatthias Ringwald extern void FlashCtl_A_disableWordProgramming(void); 535*5fd0122aSMatthias Ringwald 536*5fd0122aSMatthias Ringwald //***************************************************************************** 537*5fd0122aSMatthias Ringwald // 538*5fd0122aSMatthias Ringwald //! Returns if word programming mode is enabled (and if it is, the specific mode) 539*5fd0122aSMatthias Ringwald //! 540*5fd0122aSMatthias Ringwald //! Refer to FlashCtl_A_enableWordProgramming and the user's guide for description 541*5fd0122aSMatthias Ringwald //! on the difference between full word and immediate programming 542*5fd0122aSMatthias Ringwald //! 543*5fd0122aSMatthias Ringwald //! \return a zero value if word programming is disabled, 544*5fd0122aSMatthias Ringwald //! - \b FLASH_A_IMMEDIATE_WRITE_MODE 545*5fd0122aSMatthias Ringwald //! - \b FLASH_A_COLLATED_WRITE_MODE 546*5fd0122aSMatthias Ringwald //! 547*5fd0122aSMatthias Ringwald // 548*5fd0122aSMatthias Ringwald //***************************************************************************** 549*5fd0122aSMatthias Ringwald extern uint32_t FlashCtl_A_isWordProgrammingEnabled(void); 550*5fd0122aSMatthias Ringwald 551*5fd0122aSMatthias Ringwald //***************************************************************************** 552*5fd0122aSMatthias Ringwald // 553*5fd0122aSMatthias Ringwald //! Sets the flash read mode to be used by default flash read operations. 554*5fd0122aSMatthias Ringwald //! Note that the proper wait states must be set prior to entering this 555*5fd0122aSMatthias Ringwald //! function. 556*5fd0122aSMatthias Ringwald //! 557*5fd0122aSMatthias Ringwald //! \param flashBank Flash bank to set read mode for. Valid values are: 558*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK0 559*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK1 560*5fd0122aSMatthias Ringwald //! 561*5fd0122aSMatthias Ringwald //! \param readMode The read mode to set. Valid values are: 562*5fd0122aSMatthias Ringwald //! - \b FLASH_A_NORMAL_READ_MODE, 563*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN0_READ_MODE, 564*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN1_READ_MODE, 565*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_VERIFY_READ_MODE, 566*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_VERIFY_READ_MODE, 567*5fd0122aSMatthias Ringwald //! - \b FLASH_A_LEAKAGE_VERIFY_READ_MODE, 568*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN0B_READ_MODE, 569*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN1B_READ_MODE 570*5fd0122aSMatthias Ringwald //! 571*5fd0122aSMatthias Ringwald //! \return None. 572*5fd0122aSMatthias Ringwald // 573*5fd0122aSMatthias Ringwald //***************************************************************************** 574*5fd0122aSMatthias Ringwald extern bool FlashCtl_A_setReadMode(uint32_t flashBank, uint32_t readMode); 575*5fd0122aSMatthias Ringwald 576*5fd0122aSMatthias Ringwald //***************************************************************************** 577*5fd0122aSMatthias Ringwald // 578*5fd0122aSMatthias Ringwald //! Gets the flash read mode to be used by default flash read operations. 579*5fd0122aSMatthias Ringwald //! 580*5fd0122aSMatthias Ringwald //! \param flashBank Flash bank to set read mode for. Valid values are: 581*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK0 582*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK1 583*5fd0122aSMatthias Ringwald //! 584*5fd0122aSMatthias Ringwald //! \return Returns the read mode to set. Valid values are: 585*5fd0122aSMatthias Ringwald //! - \b FLASH_A_NORMAL_READ_MODE, 586*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN0_READ_MODE, 587*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN1_READ_MODE, 588*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_VERIFY_READ_MODE, 589*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_VERIFY_READ_MODE, 590*5fd0122aSMatthias Ringwald //! - \b FLASH_A_LEAKAGE_VERIFY_READ_MODE, 591*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN0B_READ_MODE, 592*5fd0122aSMatthias Ringwald //! - \b FLASH_A_MARGIN1B_READ_MODE 593*5fd0122aSMatthias Ringwald //! 594*5fd0122aSMatthias Ringwald // 595*5fd0122aSMatthias Ringwald //***************************************************************************** 596*5fd0122aSMatthias Ringwald extern uint32_t FlashCtl_A_getReadMode(uint32_t flashBank); 597*5fd0122aSMatthias Ringwald 598*5fd0122aSMatthias Ringwald //***************************************************************************** 599*5fd0122aSMatthias Ringwald // 600*5fd0122aSMatthias Ringwald //! Changes the number of wait states that are used by the flash controller 601*5fd0122aSMatthias Ringwald //! for read operations. When changing frequency ranges of the clock, this 602*5fd0122aSMatthias Ringwald //! functions must be used in order to allow for readable flash memory. 603*5fd0122aSMatthias Ringwald //! 604*5fd0122aSMatthias Ringwald //! \param waitState The number of wait states to set. Note that only 605*5fd0122aSMatthias Ringwald //! bits 0-3 are used. 606*5fd0122aSMatthias Ringwald //! 607*5fd0122aSMatthias Ringwald //! \param flashBank Flash bank to set wait state for. Valid values are: 608*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK0 609*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK1 610*5fd0122aSMatthias Ringwald //! 611*5fd0122aSMatthias Ringwald // 612*5fd0122aSMatthias Ringwald //***************************************************************************** 613*5fd0122aSMatthias Ringwald extern void FlashCtl_A_setWaitState(uint32_t bank, uint32_t waitState); 614*5fd0122aSMatthias Ringwald 615*5fd0122aSMatthias Ringwald //***************************************************************************** 616*5fd0122aSMatthias Ringwald // 617*5fd0122aSMatthias Ringwald //! Returns the set number of flash wait states for the given flash bank. 618*5fd0122aSMatthias Ringwald //! 619*5fd0122aSMatthias Ringwald //! \param flashBank Flash bank to set wait state for. Valid values are: 620*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK0 621*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BANK1 622*5fd0122aSMatthias Ringwald //! 623*5fd0122aSMatthias Ringwald //! \return The wait state setting for the specified flash bank 624*5fd0122aSMatthias Ringwald // 625*5fd0122aSMatthias Ringwald //***************************************************************************** 626*5fd0122aSMatthias Ringwald extern uint32_t FlashCtl_A_getWaitState(uint32_t bank); 627*5fd0122aSMatthias Ringwald 628*5fd0122aSMatthias Ringwald //***************************************************************************** 629*5fd0122aSMatthias Ringwald // 630*5fd0122aSMatthias Ringwald //! Enables individual flash control interrupt sources. 631*5fd0122aSMatthias Ringwald //! 632*5fd0122aSMatthias Ringwald //! \param flags is a bit mask of the interrupt sources to be enabled. Must 633*5fd0122aSMatthias Ringwald //! be a logical OR of: 634*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_ERROR, 635*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BENCHMARK_INT, 636*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_COMPLETE, 637*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTPRGM_COMPLETE, 638*5fd0122aSMatthias Ringwald //! - \b FLASH_A_WRDPRGM_COMPLETE, 639*5fd0122aSMatthias Ringwald //! - \b FLASH_A_POSTVERIFY_FAILED, 640*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PREVERIFY_FAILED, 641*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTRDCMP_COMPLETE 642*5fd0122aSMatthias Ringwald //! 643*5fd0122aSMatthias Ringwald //! This function enables the indicated flash system interrupt sources. Only 644*5fd0122aSMatthias Ringwald //! the sources that are enabled can be reflected to the processor interrupt; 645*5fd0122aSMatthias Ringwald //! disabled sources have no effect on the processor. 646*5fd0122aSMatthias Ringwald //! 647*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 648*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 649*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 650*5fd0122aSMatthias Ringwald //! 651*5fd0122aSMatthias Ringwald //! \return None. 652*5fd0122aSMatthias Ringwald // 653*5fd0122aSMatthias Ringwald //***************************************************************************** 654*5fd0122aSMatthias Ringwald extern void FlashCtl_A_enableInterrupt(uint32_t flags); 655*5fd0122aSMatthias Ringwald 656*5fd0122aSMatthias Ringwald //***************************************************************************** 657*5fd0122aSMatthias Ringwald // 658*5fd0122aSMatthias Ringwald //! Disables individual flash system interrupt sources. 659*5fd0122aSMatthias Ringwald //! 660*5fd0122aSMatthias Ringwald //! \param flags is a bit mask of the interrupt sources to be disabled. Must 661*5fd0122aSMatthias Ringwald //! be a logical OR of: 662*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_ERROR, 663*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BENCHMARK_INT, 664*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_COMPLETE, 665*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTPRGM_COMPLETE, 666*5fd0122aSMatthias Ringwald //! - \b FLASH_A_WRDPRGM_COMPLETE, 667*5fd0122aSMatthias Ringwald //! - \b FLASH_A_POSTVERIFY_FAILED, 668*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PREVERIFY_FAILED, 669*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTRDCMP_COMPLETE 670*5fd0122aSMatthias Ringwald //! 671*5fd0122aSMatthias Ringwald //! This function disables the indicated flash system interrupt sources. 672*5fd0122aSMatthias Ringwald //! Only the sources that are enabled can be reflected to the processor 673*5fd0122aSMatthias Ringwald //! interrupt; disabled sources have no effect on the processor. 674*5fd0122aSMatthias Ringwald //! 675*5fd0122aSMatthias Ringwald //! 676*5fd0122aSMatthias Ringwald //! \return None. 677*5fd0122aSMatthias Ringwald // 678*5fd0122aSMatthias Ringwald //***************************************************************************** 679*5fd0122aSMatthias Ringwald extern void FlashCtl_A_disableInterrupt(uint32_t flags); 680*5fd0122aSMatthias Ringwald 681*5fd0122aSMatthias Ringwald //***************************************************************************** 682*5fd0122aSMatthias Ringwald // 683*5fd0122aSMatthias Ringwald //! Gets the current interrupt status masked with the enabled interrupts. 684*5fd0122aSMatthias Ringwald //! This function is useful to call in ISRs to get a list 685*5fd0122aSMatthias Ringwald //! of pending interrupts that are actually enabled and could have caused the 686*5fd0122aSMatthias Ringwald //! ISR. 687*5fd0122aSMatthias Ringwald //! 688*5fd0122aSMatthias Ringwald //! \return The current interrupt status, enumerated as a bit field of 689*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_ERROR, 690*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BENCHMARK_INT, 691*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_COMPLETE, 692*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTPRGM_COMPLETE, 693*5fd0122aSMatthias Ringwald //! - \b FLASH_A_WRDPRGM_COMPLETE, 694*5fd0122aSMatthias Ringwald //! - \b FLASH_A_POSTVERIFY_FAILED, 695*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PREVERIFY_FAILED, 696*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTRDCMP_COMPLETE 697*5fd0122aSMatthias Ringwald //! 698*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 699*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 700*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 701*5fd0122aSMatthias Ringwald // 702*5fd0122aSMatthias Ringwald //***************************************************************************** 703*5fd0122aSMatthias Ringwald extern uint32_t FlashCtl_A_getEnabledInterruptStatus(void); 704*5fd0122aSMatthias Ringwald 705*5fd0122aSMatthias Ringwald //***************************************************************************** 706*5fd0122aSMatthias Ringwald // 707*5fd0122aSMatthias Ringwald //! Gets the current interrupt status. 708*5fd0122aSMatthias Ringwald //! 709*5fd0122aSMatthias Ringwald //! \return The current interrupt status, enumerated as a bit field of: 710*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_ERROR, 711*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BENCHMARK_INT, 712*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_COMPLETE, 713*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTPRGM_COMPLETE, 714*5fd0122aSMatthias Ringwald //! - \b FLASH_A_WRDPRGM_COMPLETE, 715*5fd0122aSMatthias Ringwald //! - \b FLASH_A_POSTVERIFY_FAILED, 716*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PREVERIFY_FAILED, 717*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTRDCMP_COMPLETE 718*5fd0122aSMatthias Ringwald //! 719*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 720*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 721*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 722*5fd0122aSMatthias Ringwald // 723*5fd0122aSMatthias Ringwald //***************************************************************************** 724*5fd0122aSMatthias Ringwald extern uint32_t FlashCtl_A_getInterruptStatus(void); 725*5fd0122aSMatthias Ringwald 726*5fd0122aSMatthias Ringwald //***************************************************************************** 727*5fd0122aSMatthias Ringwald // 728*5fd0122aSMatthias Ringwald //! Clears flash system interrupt sources. 729*5fd0122aSMatthias Ringwald //! 730*5fd0122aSMatthias Ringwald //! \param flags is a bit mask of the interrupt sources to be cleared. Must 731*5fd0122aSMatthias Ringwald //! be a logical OR of: 732*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PROGRAM_ERROR, 733*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BENCHMARK_INT, 734*5fd0122aSMatthias Ringwald //! - \b FLASH_A_ERASE_COMPLETE, 735*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTPRGM_COMPLETE, 736*5fd0122aSMatthias Ringwald //! - \b FLASH_A_WRDPRGM_COMPLETE, 737*5fd0122aSMatthias Ringwald //! - \b FLASH_A_POSTVERIFY_FAILED, 738*5fd0122aSMatthias Ringwald //! - \b FLASH_A_PREVERIFY_FAILED, 739*5fd0122aSMatthias Ringwald //! - \b FLASH_A_BRSTRDCMP_COMPLETE 740*5fd0122aSMatthias Ringwald //! 741*5fd0122aSMatthias Ringwald //! The specified flash system interrupt sources are cleared, so that they no 742*5fd0122aSMatthias Ringwald //! longer assert. This function must be called in the interrupt handler to 743*5fd0122aSMatthias Ringwald //! keep it from being called again immediately upon exit. 744*5fd0122aSMatthias Ringwald //! 745*5fd0122aSMatthias Ringwald //! \note Because there is a write buffer in the Cortex-M processor, it may 746*5fd0122aSMatthias Ringwald //! take several clock cycles before the interrupt source is actually cleared. 747*5fd0122aSMatthias Ringwald //! Therefore, it is recommended that the interrupt source be cleared early in 748*5fd0122aSMatthias Ringwald //! the interrupt handler (as opposed to the very last action) to avoid 749*5fd0122aSMatthias Ringwald //! returning from the interrupt handler before the interrupt source is 750*5fd0122aSMatthias Ringwald //! actually cleared. Failure to do so may result in the interrupt handler 751*5fd0122aSMatthias Ringwald //! being immediately reentered (because the interrupt controller still sees 752*5fd0122aSMatthias Ringwald //! the interrupt source asserted). 753*5fd0122aSMatthias Ringwald //! 754*5fd0122aSMatthias Ringwald //! \note The interrupt sources vary based on the part in use. 755*5fd0122aSMatthias Ringwald //! Please consult the data sheet for the part you are using to determine 756*5fd0122aSMatthias Ringwald //! which interrupt sources are available. 757*5fd0122aSMatthias Ringwald //! 758*5fd0122aSMatthias Ringwald //! \return None. 759*5fd0122aSMatthias Ringwald // 760*5fd0122aSMatthias Ringwald //***************************************************************************** 761*5fd0122aSMatthias Ringwald extern void FlashCtl_A_clearInterruptFlag(uint32_t flags); 762*5fd0122aSMatthias Ringwald 763*5fd0122aSMatthias Ringwald //***************************************************************************** 764*5fd0122aSMatthias Ringwald // 765*5fd0122aSMatthias Ringwald //! Registers an interrupt handler for flash clock system interrupt. 766*5fd0122aSMatthias Ringwald //! 767*5fd0122aSMatthias Ringwald //! \param intHandler is a pointer to the function to be called when the clock 768*5fd0122aSMatthias Ringwald //! system interrupt occurs. 769*5fd0122aSMatthias Ringwald //! 770*5fd0122aSMatthias Ringwald //! This function registers the handler to be called when a clock system 771*5fd0122aSMatthias Ringwald //! interrupt occurs. This function enables the global interrupt in the 772*5fd0122aSMatthias Ringwald //! interrupt controller; specific flash controller interrupts must be enabled 773*5fd0122aSMatthias Ringwald //! via FlashCtl_A_enableInterrupt(). It is the interrupt handler's 774*5fd0122aSMatthias Ringwald //! responsibility to clear the interrupt source via 775*5fd0122aSMatthias Ringwald //! FlashCtl_A_clearInterruptFlag(). 776*5fd0122aSMatthias Ringwald //! 777*5fd0122aSMatthias Ringwald //! \sa Interrupt_registerInterrupt() for important information about 778*5fd0122aSMatthias Ringwald //! registering interrupt handlers. 779*5fd0122aSMatthias Ringwald //! 780*5fd0122aSMatthias Ringwald //! \return None. 781*5fd0122aSMatthias Ringwald // 782*5fd0122aSMatthias Ringwald //***************************************************************************** 783*5fd0122aSMatthias Ringwald extern void FlashCtl_A_registerInterrupt(void (*intHandler)(void)); 784*5fd0122aSMatthias Ringwald 785*5fd0122aSMatthias Ringwald //***************************************************************************** 786*5fd0122aSMatthias Ringwald // 787*5fd0122aSMatthias Ringwald //! Unregisters the interrupt handler for the flash system. 788*5fd0122aSMatthias Ringwald //! 789*5fd0122aSMatthias Ringwald //! This function unregisters the handler to be called when a clock system 790*5fd0122aSMatthias Ringwald //! interrupt occurs. This function also masks off the interrupt in the 791*5fd0122aSMatthias Ringwald //! interrupt controller so that the interrupt handler no longer is called. 792*5fd0122aSMatthias Ringwald //! 793*5fd0122aSMatthias Ringwald //! \sa Interrupt_registerInterrupt() for important information about 794*5fd0122aSMatthias Ringwald //! registering interrupt handlers. 795*5fd0122aSMatthias Ringwald //! 796*5fd0122aSMatthias Ringwald //! \return None. 797*5fd0122aSMatthias Ringwald // 798*5fd0122aSMatthias Ringwald //***************************************************************************** 799*5fd0122aSMatthias Ringwald extern void FlashCtl_A_unregisterInterrupt(void); 800*5fd0122aSMatthias Ringwald 801*5fd0122aSMatthias Ringwald //***************************************************************************** 802*5fd0122aSMatthias Ringwald // 803*5fd0122aSMatthias Ringwald //! Initiates a sector erase of MAIN or INFO flash memory. Note that this 804*5fd0122aSMatthias Ringwald //! function simply initaites the sector erase, but does no verification 805*5fd0122aSMatthias Ringwald //! which is required by the flash controller. The user must manually set 806*5fd0122aSMatthias Ringwald //! and enable interrupts on the flash controller to fire on erase completion 807*5fd0122aSMatthias Ringwald //! and then use the FlashCtl_A_verifyMemory function to verify that the sector 808*5fd0122aSMatthias Ringwald //! was actually erased 809*5fd0122aSMatthias Ringwald //! 810*5fd0122aSMatthias Ringwald //! \param addr The start of the sector to erase. Note that with flash, 811*5fd0122aSMatthias Ringwald //! the minimum allowed size that can be erased is a flash sector 812*5fd0122aSMatthias Ringwald //! (which is 4KB on the MSP432 family). If an address is provided to 813*5fd0122aSMatthias Ringwald //! this function which is not on a 4KB boundary, the entire sector 814*5fd0122aSMatthias Ringwald //! will still be erased. 815*5fd0122aSMatthias Ringwald //! 816*5fd0122aSMatthias Ringwald //! \return None 817*5fd0122aSMatthias Ringwald // 818*5fd0122aSMatthias Ringwald //***************************************************************************** 819*5fd0122aSMatthias Ringwald extern void FlashCtl_A_initiateSectorErase(uint32_t addr); 820*5fd0122aSMatthias Ringwald 821*5fd0122aSMatthias Ringwald /* The following functions are advanced functions that are used by the flash 822*5fd0122aSMatthias Ringwald * driver to remask a failed bit in the event of a post or pre verification 823*5fd0122aSMatthias Ringwald * failure. They are meant to be advanced functions and should not be used 824*5fd0122aSMatthias Ringwald * by the majority of users (unless you are writing your own flash driver). 825*5fd0122aSMatthias Ringwald */ 826*5fd0122aSMatthias Ringwald extern uint8_t __FlashCtl_A_remaskData8Post(uint8_t data, uint32_t addr); 827*5fd0122aSMatthias Ringwald extern uint8_t __FlashCtl_A_remaskData8Pre(uint8_t data, uint32_t addr); 828*5fd0122aSMatthias Ringwald extern uint32_t __FlashCtl_A_remaskData32Post(uint32_t data, uint32_t addr); 829*5fd0122aSMatthias Ringwald extern uint32_t __FlashCtl_A_remaskData32Pre(uint32_t data, uint32_t addr); 830*5fd0122aSMatthias Ringwald extern void __FlashCtl_A_remaskBurstDataPost(uint32_t addr, uint32_t size); 831*5fd0122aSMatthias Ringwald extern void __FlashCtl_A_remaskBurstDataPre(uint32_t addr, uint32_t size); 832*5fd0122aSMatthias Ringwald 833*5fd0122aSMatthias Ringwald //***************************************************************************** 834*5fd0122aSMatthias Ringwald // 835*5fd0122aSMatthias Ringwald // Mark the end of the C bindings section for C++ compilers. 836*5fd0122aSMatthias Ringwald // 837*5fd0122aSMatthias Ringwald //***************************************************************************** 838*5fd0122aSMatthias Ringwald #ifdef __cplusplus 839*5fd0122aSMatthias Ringwald } 840*5fd0122aSMatthias Ringwald #endif 841*5fd0122aSMatthias Ringwald 842*5fd0122aSMatthias Ringwald //***************************************************************************** 843*5fd0122aSMatthias Ringwald // 844*5fd0122aSMatthias Ringwald // Close the Doxygen group. 845*5fd0122aSMatthias Ringwald //! @} 846*5fd0122aSMatthias Ringwald // 847*5fd0122aSMatthias Ringwald //***************************************************************************** 848*5fd0122aSMatthias Ringwald 849*5fd0122aSMatthias Ringwald #endif /* __MCU_HAS_FLCTL_A__ */ 850*5fd0122aSMatthias Ringwald 851*5fd0122aSMatthias Ringwald #endif // __FLASH_A_H__ 852