Module for erasing, programming, verifying and configuring different functionalities of the Flash IP.
More...
|
void | FlashCtl_getMemoryInfo (uint32_t addr, uint32_t *bankNum, uint32_t *sectorNum) |
|
void | FlashCtl_enableReadBuffering (uint_fast8_t memoryBank, uint_fast8_t accessMethod) |
|
void | FlashCtl_disableReadBuffering (uint_fast8_t memoryBank, uint_fast8_t accessMethod) |
|
bool | FlashCtl_unprotectSector (uint_fast8_t memorySpace, uint32_t sectorMask) |
|
bool | FlashCtl_protectSector (uint_fast8_t memorySpace, uint32_t sectorMask) |
|
bool | FlashCtl_isSectorProtected (uint_fast8_t memorySpace, uint32_t sector) |
|
bool | FlashCtl_verifyMemory (void *verifyAddr, uint32_t length, uint_fast8_t pattern) |
|
bool | FlashCtl_performMassErase (void) |
|
void | FlashCtl_initiateMassErase (void) |
|
bool | FlashCtl_eraseSector (uint32_t addr) |
|
bool | FlashCtl_programMemory (void *src, void *dest, uint32_t length) |
|
void | FlashCtl_setProgramVerification (uint32_t verificationSetting) |
|
void | FlashCtl_clearProgramVerification (uint32_t verificationSetting) |
|
void | FlashCtl_enableWordProgramming (uint32_t mode) |
|
void | FlashCtl_disableWordProgramming (void) |
|
uint32_t | FlashCtl_isWordProgrammingEnabled (void) |
|
bool | FlashCtl_setReadMode (uint32_t flashBank, uint32_t readMode) |
|
uint32_t | FlashCtl_getReadMode (uint32_t flashBank) |
|
void | FlashCtl_setWaitState (uint32_t bank, uint32_t waitState) |
|
uint32_t | FlashCtl_getWaitState (uint32_t bank) |
|
void | FlashCtl_enableInterrupt (uint32_t flags) |
|
void | FlashCtl_disableInterrupt (uint32_t flags) |
|
uint32_t | FlashCtl_getEnabledInterruptStatus (void) |
|
uint32_t | FlashCtl_getInterruptStatus (void) |
|
void | FlashCtl_clearInterruptFlag (uint32_t flags) |
|
void | FlashCtl_registerInterrupt (void(*intHandler)(void)) |
|
void | FlashCtl_unregisterInterrupt (void) |
|
void | FlashCtl_initiateSectorErase (uint32_t addr) |
|
uint8_t | __FlashCtl_remaskData8Post (uint8_t data, uint32_t addr) |
|
uint8_t | __FlashCtl_remaskData8Pre (uint8_t data, uint32_t addr) |
|
uint32_t | __FlashCtl_remaskData32Post (uint32_t data, uint32_t addr) |
|
uint32_t | __FlashCtl_remaskData32Pre (uint32_t data, uint32_t addr) |
|
void | __FlashCtl_remaskBurstDataPost (uint32_t addr, uint32_t size) |
|
void | __FlashCtl_remaskBurstDataPre (uint32_t addr, uint32_t size) |
|
Module for erasing, programming, verifying and configuring different functionalities of the Flash IP.
Module Operation
The MSP432 DriverLib Flash Controller peripheral is designed to simplify the process or writing, erasing, and configuring the flash memory on the MSP432 part. Many of the stringent verification requirements/preconditions are handled entirely inside the FlashCtl APIs.
Flash Controller Limitations
When utilizing the flash controller for MSP432, the user program has to take special consideration on a few critical limitations. The biggest obstacle that the user has to be mindful of is the stringent verification requirements imposed by the flash controller. Many operations (such as program and verify) will take multiple cycles to complete successfully and the usage is somewhat complicated for a normal user program. For this reason, it is strongly recommended that the user uses the DriverLib APIs for programming and erasing flash. Using the flash controller directly is strongly discouraged as the level of overhead and attention to verification requirements make for a very intricate user experience.
Furthermore, when using the FlashCtl APIs, the user must take special consideration of where the API is being executed. For the critical APIs (such as erase and program), the DriverLib APIs are required to be executed from either SRAM or ROM (using the ROM_ prefix). Due to the verification requirements of the flash controller, running these APIs out of Flash is not currently supported.
Wait State Considerations
When changing read modes on the MSP432 microcontroller, some read modes (such as erase verify) require an additional number of wait states. The wait states of the flash controller can be configured using the FlashCtl_setWaitState command. When using the DriverLib APIs, the wait states are automatically changed within the API.
Programming Examples
The DriverLib package contains a variety of different code examples that demonstrate the usage of the FlashCtl module. These code examples are accessible under the examples/ folder of the SDK release as well as through TI Resource Explorer if using Code Composer Studio. These code examples provide a comprehensive list of use cases as well as practical applications involving each module.
Below is a very brief code example showing how to unprotect a sector and issue a mass erase with the FlashCtl module:
#define FLASH_BURST_PRG_BIT 0x03 |
#define FLASH_PROGRAM_ERROR FLCTL_IFG_PRG_ERR |
#define FLASH_BENCHMARK_INT FLCTL_IFG_BMRK |
#define FLASH_ERASE_COMPLETE FLCTL_IFG_ERASE |
#define FLASH_BRSTPRGM_COMPLETE FLCTL_IFG_PRGB |
#define FLASH_WRDPRGM_COMPLETE FLCTL_IFG_PRG |
#define FLASH_POSTVERIFY_FAILED FLCTL_IFG_AVPST |
#define FLASH_PREVERIFY_FAILED FLCTL_IFG_AVPRE |
#define FLASH_BRSTRDCMP_COMPLETE FLCTL_IFG_RDBRST |
#define FLASH_NORMAL_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_0 |
#define FLASH_MARGIN0_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_1 |
#define FLASH_MARGIN1_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_2 |
#define FLASH_PROGRAM_VERIFY_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_3 |
#define FLASH_ERASE_VERIFY_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_4 |
#define FLASH_LEAKAGE_VERIFY_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_5 |
#define FLASH_MARGIN0B_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_9 |
#define FLASH_MARGIN1B_READ_MODE FLCTL_BANK0_RDCTL_RD_MODE_10 |
#define FLASH_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE FLCTL_PRGBRST_CTLSTAT_BURST_STATUS_7 |
Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), FlashCtl_disableReadBuffering(), FlashCtl_enableReadBuffering(), FlashCtl_getMemoryInfo(), FlashCtl_getReadMode(), FlashCtl_getWaitState(), FlashCtl_setReadMode(), FlashCtl_setWaitState(), and FlashCtl_verifyMemory().
Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), FlashCtl_disableReadBuffering(), FlashCtl_enableReadBuffering(), FlashCtl_getMemoryInfo(), FlashCtl_getReadMode(), FlashCtl_getWaitState(), FlashCtl_setReadMode(), FlashCtl_setWaitState(), and FlashCtl_verifyMemory().
#define FLASH_DATA_READ 0x00 |
#define FLASH_INSTRUCTION_FETCH 0x01 |
#define FLASH_MAIN_MEMORY_SPACE_BANK0 0x01 |
#define FLASH_MAIN_MEMORY_SPACE_BANK1 0x02 |
#define FLASH_INFO_MEMORY_SPACE_BANK0 0x03 |
#define FLASH_INFO_MEMORY_SPACE_BANK1 0x04 |
#define FLASH_MAIN_SPACE FLCTL_RDBRST_CTLSTAT_MEM_TYPE_0 |
#define FLASH_INFO_SPACE FLCTL_RDBRST_CTLSTAT_MEM_TYPE_1 |
#define FLASH_1_PATTERN FLCTL_RDBRST_CTLSTAT_DATA_CMP |
#define FLASH_0_PATTERN 0x00 |
#define FLASH_SECTOR0 FLCTL_BANK0_MAIN_WEPROT_PROT0 |
#define FLASH_SECTOR1 FLCTL_BANK0_MAIN_WEPROT_PROT1 |
#define FLASH_SECTOR2 FLCTL_BANK0_MAIN_WEPROT_PROT2 |
#define FLASH_SECTOR3 FLCTL_BANK0_MAIN_WEPROT_PROT3 |
#define FLASH_SECTOR4 FLCTL_BANK0_MAIN_WEPROT_PROT4 |
#define FLASH_SECTOR5 FLCTL_BANK0_MAIN_WEPROT_PROT5 |
#define FLASH_SECTOR6 FLCTL_BANK0_MAIN_WEPROT_PROT6 |
#define FLASH_SECTOR7 FLCTL_BANK0_MAIN_WEPROT_PROT7 |
#define FLASH_SECTOR8 FLCTL_BANK0_MAIN_WEPROT_PROT8 |
#define FLASH_SECTOR9 FLCTL_BANK0_MAIN_WEPROT_PROT9 |
#define FLASH_SECTOR10 FLCTL_BANK0_MAIN_WEPROT_PROT10 |
#define FLASH_SECTOR11 FLCTL_BANK0_MAIN_WEPROT_PROT11 |
#define FLASH_SECTOR12 FLCTL_BANK0_MAIN_WEPROT_PROT12 |
#define FLASH_SECTOR13 FLCTL_BANK0_MAIN_WEPROT_PROT13 |
#define FLASH_SECTOR14 FLCTL_BANK0_MAIN_WEPROT_PROT14 |
#define FLASH_SECTOR15 FLCTL_BANK0_MAIN_WEPROT_PROT15 |
#define FLASH_SECTOR16 FLCTL_BANK0_MAIN_WEPROT_PROT16 |
#define FLASH_SECTOR17 FLCTL_BANK0_MAIN_WEPROT_PROT17 |
#define FLASH_SECTOR18 FLCTL_BANK0_MAIN_WEPROT_PROT18 |
#define FLASH_SECTOR19 FLCTL_BANK0_MAIN_WEPROT_PROT19 |
#define FLASH_SECTOR20 FLCTL_BANK0_MAIN_WEPROT_PROT20 |
#define FLASH_SECTOR21 FLCTL_BANK0_MAIN_WEPROT_PROT21 |
#define FLASH_SECTOR22 FLCTL_BANK0_MAIN_WEPROT_PROT22 |
#define FLASH_SECTOR23 FLCTL_BANK0_MAIN_WEPROT_PROT23 |
#define FLASH_SECTOR24 FLCTL_BANK0_MAIN_WEPROT_PROT24 |
#define FLASH_SECTOR25 FLCTL_BANK0_MAIN_WEPROT_PROT25 |
#define FLASH_SECTOR26 FLCTL_BANK0_MAIN_WEPROT_PROT26 |
#define FLASH_SECTOR27 FLCTL_BANK0_MAIN_WEPROT_PROT27 |
#define FLASH_SECTOR28 FLCTL_BANK0_MAIN_WEPROT_PROT28 |
#define FLASH_SECTOR29 FLCTL_BANK0_MAIN_WEPROT_PROT29 |
#define FLASH_SECTOR30 FLCTL_BANK0_MAIN_WEPROT_PROT30 |
#define FLASH_SECTOR31 FLCTL_BANK0_MAIN_WEPROT_PROT31 |
#define FLASH_BURSTPOST FLCTL_PRGBRST_CTLSTAT_AUTO_PST |
#define FLASH_BURSTPRE FLCTL_PRGBRST_CTLSTAT_AUTO_PRE |
#define FLASH_REGPRE FLCTL_PRG_CTLSTAT_VER_PRE |
#define FLASH_REGPOST FLCTL_PRG_CTLSTAT_VER_PST |
Value:(FLCTL_PRGBRST_CTLSTAT_AUTO_PST | \
FLCTL_PRGBRST_CTLSTAT_AUTO_PRE | FLCTL_PRG_CTLSTAT_VER_PRE \
| FLCTL_PRG_CTLSTAT_VER_PST)
#define FLASH_COLLATED_WRITE_MODE 0x01 |
#define FLASH_IMMEDIATE_WRITE_MODE 0x02 |
#define __INFO_FLASH_TECH_START__ 0x00200000 |
#define __INFO_FLASH_TECH_MIDDLE__ 0x00202000 |
void FlashCtl_getMemoryInfo |
( |
uint32_t |
addr, |
|
|
uint32_t * |
bankNum, |
|
|
uint32_t * |
sectorNum |
|
) |
| |
Calculates the flash bank and sector number given an address. Stores the results into the two pointers given as parameters. The user must provide a valid memory address (an address in SRAM for example will give an invalid result).
- Parameters
-
addr | Address to calculate the bank/sector information for |
bankNum | The bank number will be stored in here after the function completes. |
sectorNum | The sector number will be stored in here after the function completes. |
- Note
- For simplicity, this API only works with address in MAIN flash memory. For calculating the sector/bank number of an address in info memory, please refer to your device datasheet/
- Returns
- None.
References FLASH_BANK0, FLASH_BANK1, and SysCtl_getFlashSize().
void FlashCtl_enableReadBuffering |
( |
uint_fast8_t |
memoryBank, |
|
|
uint_fast8_t |
accessMethod |
|
) |
| |
Enables read buffering on accesses to a specified bank of flash memory
- Parameters
-
memoryBank | is the value of the memory bank to enable read buffering. Must be only one of the following values:
|
accessMethod | is the value of the access type to enable read buffering. Must be only one of the following values:
- FLASH_DATA_READ,
- FLASH_INSTRUCTION_FETCH
|
- Returns
- None.
References ASSERT, FLASH_BANK0, FLASH_BANK1, FLASH_DATA_READ, and FLASH_INSTRUCTION_FETCH.
void FlashCtl_disableReadBuffering |
( |
uint_fast8_t |
memoryBank, |
|
|
uint_fast8_t |
accessMethod |
|
) |
| |
Disables read buffering on accesses to a specified bank of flash memory
- Parameters
-
memoryBank | is the value of the memory bank to disable read buffering. Must be only one of the following values:
|
accessMethod | is the value of the access type to disable read buffering. Must ne only one of the following values:
- FLASH_DATA_READ,
- FLASH_INSTRUCTION_FETCH
|
- Returns
- None.
References ASSERT, FLASH_BANK0, FLASH_BANK1, FLASH_DATA_READ, and FLASH_INSTRUCTION_FETCH.
bool FlashCtl_unprotectSector |
( |
uint_fast8_t |
memorySpace, |
|
|
uint32_t |
sectorMask |
|
) |
| |
Disables program protection on the given sector mask. This setting can be applied on a sector-wise bases on a given memory space (INFO or MAIN).
- Parameters
-
memorySpace | is the value of the memory bank to disable program protection. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
sectorMask | is a bit mask of the sectors to disable program protection. Must be a bitfield of the following values:
- FLASH_SECTOR0,
- FLASH_SECTOR1,
- FLASH_SECTOR2,
- FLASH_SECTOR3,
- FLASH_SECTOR4,
- FLASH_SECTOR5,
- FLASH_SECTOR6,
- FLASH_SECTOR7,
- FLASH_SECTOR8,
- FLASH_SECTOR9,
- FLASH_SECTOR10,
- FLASH_SECTOR11,
- FLASH_SECTOR12,
- FLASH_SECTOR13,
- FLASH_SECTOR14,
- FLASH_SECTOR15,
- FLASH_SECTOR16,
- FLASH_SECTOR17,
- FLASH_SECTOR18,
- FLASH_SECTOR19,
- FLASH_SECTOR20,
- FLASH_SECTOR21,
- FLASH_SECTOR22,
- FLASH_SECTOR23,
- FLASH_SECTOR24,
- FLASH_SECTOR25,
- FLASH_SECTOR26,
- FLASH_SECTOR27,
- FLASH_SECTOR28,
- FLASH_SECTOR29,
- FLASH_SECTOR30,
- FLASH_SECTOR31
|
- Note
- Flash sector sizes are 4KB and the number of sectors may vary depending on the specific device. Also, for INFO memory space, only sectors FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
-
Not all devices will contain a dedicated INFO memory. Please check the device datasheet to see if your device has INFO memory available for use. For devices without INFO memory, any operation related to the INFO memory will be ignored by the hardware.
- Returns
- true if sector protection disabled false otherwise.
References ASSERT, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_MAIN_MEMORY_SPACE_BANK0, FLASH_MAIN_MEMORY_SPACE_BANK1, and FlashCtl_isSectorProtected().
bool FlashCtl_protectSector |
( |
uint_fast8_t |
memorySpace, |
|
|
uint32_t |
sectorMask |
|
) |
| |
Enables program protection on the given sector mask. This setting can be applied on a sector-wise bases on a given memory space (INFO or MAIN).
- Parameters
-
memorySpace | is the value of the memory bank to enable program protection. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
sectorMask | is a bit mask of the sectors to enable program protection. Must be a bitfield of the following values:
- FLASH_SECTOR0,
- FLASH_SECTOR1,
- FLASH_SECTOR2,
- FLASH_SECTOR3,
- FLASH_SECTOR4,
- FLASH_SECTOR5,
- FLASH_SECTOR6,
- FLASH_SECTOR7,
- FLASH_SECTOR8,
- FLASH_SECTOR9,
- FLASH_SECTOR10,
- FLASH_SECTOR11,
- FLASH_SECTOR12,
- FLASH_SECTOR13,
- FLASH_SECTOR14,
- FLASH_SECTOR15,
- FLASH_SECTOR16,
- FLASH_SECTOR17,
- FLASH_SECTOR18,
- FLASH_SECTOR19,
- FLASH_SECTOR20,
- FLASH_SECTOR21,
- FLASH_SECTOR22,
- FLASH_SECTOR23,
- FLASH_SECTOR24,
- FLASH_SECTOR25,
- FLASH_SECTOR26,
- FLASH_SECTOR27,
- FLASH_SECTOR28,
- FLASH_SECTOR29,
- FLASH_SECTOR30,
- FLASH_SECTOR31
|
- Note
- Flash sector sizes are 4KB and the number of sectors may vary depending on the specific device. Also, for INFO memory space, only sectors FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
-
Not all devices will contain a dedicated INFO memory. Please check the device datasheet to see if your device has INFO memory available for use. For devices without INFO memory, any operation related to the INFO memory will be ignored by the hardware.
- Returns
- true if sector protection enabled false otherwise.
References ASSERT, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_MAIN_MEMORY_SPACE_BANK0, FLASH_MAIN_MEMORY_SPACE_BANK1, and FlashCtl_isSectorProtected().
bool FlashCtl_isSectorProtected |
( |
uint_fast8_t |
memorySpace, |
|
|
uint32_t |
sector |
|
) |
| |
Returns the sector protection for given sector mask and memory space
- Parameters
-
memorySpace | is the value of the memory bank to check for program protection. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
sector | is the sector to check for program protection. Must be one of the following values:
- FLASH_SECTOR0,
- FLASH_SECTOR1,
- FLASH_SECTOR2,
- FLASH_SECTOR3,
- FLASH_SECTOR4,
- FLASH_SECTOR5,
- FLASH_SECTOR6,
- FLASH_SECTOR7,
- FLASH_SECTOR8,
- FLASH_SECTOR9,
- FLASH_SECTOR10,
- FLASH_SECTOR11,
- FLASH_SECTOR12,
- FLASH_SECTOR13,
- FLASH_SECTOR14,
- FLASH_SECTOR15,
- FLASH_SECTOR16,
- FLASH_SECTOR17,
- FLASH_SECTOR18,
- FLASH_SECTOR19,
- FLASH_SECTOR20,
- FLASH_SECTOR21,
- FLASH_SECTOR22,
- FLASH_SECTOR23,
- FLASH_SECTOR24,
- FLASH_SECTOR25,
- FLASH_SECTOR26,
- FLASH_SECTOR27,
- FLASH_SECTOR28,
- FLASH_SECTOR29,
- FLASH_SECTOR30,
- FLASH_SECTOR31
|
Note that flash sector sizes are 4KB and the number of sectors may vary depending on the specific device. Also, for INFO memory space, only sectors FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
- Note
- Not all devices will contain a dedicated INFO memory. Please check the device datasheet to see if your device has INFO memory available for use. For devices without INFO memory, any operation related to the INFO memory will be ignored by the hardware.
- Returns
- true if sector protection enabled false otherwise.
References ASSERT, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_MAIN_MEMORY_SPACE_BANK0, and FLASH_MAIN_MEMORY_SPACE_BANK1.
Referenced by FlashCtl_protectSector(), and FlashCtl_unprotectSector().
bool FlashCtl_verifyMemory |
( |
void * |
verifyAddr, |
|
|
uint32_t |
length, |
|
|
uint_fast8_t |
pattern |
|
) |
| |
Verifies a given segment of memory based off either a high (1) or low (0) state.
- Parameters
-
verifyAddr | Start address where verification will begin |
length | Length in bytes to verify based off the pattern |
pattern | The pattern which verification will check versus. This can either be a low pattern (each register will be checked versus a pattern of 32 zeros, or a high pattern (each register will be checked versus a pattern of 32 ones). Valid values are: FLASH_0_PATTERN, FLASH_1_PATTERN |
- Note
- There are no sector/boundary restrictions for this function, however it is encouraged to proved a start address aligned on 32-bit boundaries. Providing an unaligned address will result in unaligned data accesses and detriment efficiency.
-
This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
-
Due to the hardware limitations of the flash controller, this function cannot verify a memory address in the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
- Returns
- true if memory verification is successful, false otherwise.
References __INFO_FLASH_TECH_MIDDLE__, __INFO_FLASH_TECH_START__, ASSERT, CPU_primask(), FLASH_0_PATTERN, FLASH_1_PATTERN, FLASH_BANK0, FLASH_BANK1, FLASH_ERASE_VERIFY_READ_MODE, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, FLASH_PROGRAM_VERIFY_READ_MODE, FlashCtl_getReadMode(), FlashCtl_getWaitState(), FlashCtl_setReadMode(), FlashCtl_setWaitState(), HWREG32, HWREG8, Interrupt_disableMaster(), Interrupt_enableMaster(), and SysCtl_getFlashSize().
Referenced by FlashCtl_eraseSector(), and FlashCtl_performMassErase().
bool FlashCtl_performMassErase |
( |
void |
| ) |
|
Performs a mass erase on all unprotected flash sectors. Protected sectors are ignored.
- Note
- This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
-
Due to the hardware limitations of the flash controller, this function cannot erase a memory address in the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
- Returns
- true if mass erase completes successfully, false otherwise
References __INFO_FLASH_TECH_START__, CPU_primask(), FLASH_1_PATTERN, FlashCtl_eraseSector(), FlashCtl_verifyMemory(), Interrupt_disableMaster(), Interrupt_enableMaster(), and SysCtl_getFlashSize().
void FlashCtl_initiateMassErase |
( |
void |
| ) |
|
Initiates a mass erase and returns control back to the program. This is a non-blocking function, however it is the user's responsibility to perform the necessary verification requirements after the interrupt is set to signify completion.
- Returns
- None
bool FlashCtl_eraseSector |
( |
uint32_t |
addr | ) |
|
Erases a sector of MAIN or INFO flash memory.
- Parameters
-
addr | The start of the sector to erase. Note that with flash, the minimum allowed size that can be erased is a flash sector (which is 4KB on the MSP432 family). If an address is provided to this function which is not on a 4KB boundary, the entire sector will still be erased. |
- Note
- This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
-
Due to the hardware limitations of the flash controller, this function cannot erase a memory addressin the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
- Returns
- true if sector erase is successful, false otherwise.
References __INFO_FLASH_TECH_START__, CPU_primask(), FLASH_1_PATTERN, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, FlashCtl_verifyMemory(), Interrupt_disableMaster(), Interrupt_enableMaster(), SysCtl_FlashTLV_Info::maxErasePulses, SysCtl_getFlashSize(), SysCtl_getTLVInfo(), and TLV_TAG_FLASHCTL.
Referenced by FlashCtl_performMassErase().
bool FlashCtl_programMemory |
( |
void * |
src, |
|
|
void * |
dest, |
|
|
uint32_t |
length |
|
) |
| |
Program a portion of flash memory with the provided data
- Parameters
-
src | Pointer to the data source to program into flash |
dest | Pointer to the destination in flash to program |
length | Length in bytes to program |
- Note
- There are no sector/boundary restrictions for this function, however it is encouraged to proved a start address aligned on 32-bit boundaries. Providing an unaligned address will result in unaligned data accesses and detriment efficiency.
-
This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
-
Due to the hardware limitations of the flash controller, this function cannot program a memory addressin the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
- Returns
- Whether or not the program succeeded
References CPU_primask(), FLASH_IMMEDIATE_WRITE_MODE, FlashCtl_disableWordProgramming(), FlashCtl_enableWordProgramming(), Interrupt_disableMaster(), Interrupt_enableMaster(), SysCtl_FlashTLV_Info::maxProgramPulses, SysCtl_getTLVInfo(), and TLV_TAG_FLASHCTL.
void FlashCtl_setProgramVerification |
( |
uint32_t |
verificationSetting | ) |
|
Setups pre/post verification of burst and regular flash programming instructions. Note that this API is for advanced users that are programming their own flash drivers. The program/erase APIs are not affected by this setting and take care of the verification requirements.
- Parameters
-
verificationSetting | Verification setting to set. This value can be a bitwise OR of the following values:
- FLASH_BURSTPOST,
- FLASH_BURSTPRE,
- FLASH_REGPRE,
- FLASH_REGPOST
- FLASH_NOVER No verification enabled
- FLASH_FULLVER Full verification enabled
|
- Returns
- none
References FLASH_BURSTPOST, FLASH_BURSTPRE, FLASH_REGPOST, and FLASH_REGPRE.
void FlashCtl_clearProgramVerification |
( |
uint32_t |
verificationSetting | ) |
|
Clears pre/post verification of burst and regular flash programming instructions. Note that this API is for advanced users that are programming their own flash drivers. The program/erase APIs are not affected by this setting and take care of the verification requirements.
- Parameters
-
verificationSetting | Verification setting to clear. This value can be a bitwise OR of the following values:
- FLASH_BURSTPOST,
- FLASH_BURSTPRE,
- FLASH_REGPRE,
- FLASH_REGPOST
- FLASH_NOVER No verification enabled
- FLASH_FULLVER Full verification enabled
|
- Returns
- none
References FLASH_BURSTPOST, FLASH_BURSTPRE, FLASH_REGPOST, and FLASH_REGPRE.
void FlashCtl_enableWordProgramming |
( |
uint32_t |
mode | ) |
|
Enables word programming of flash memory.
This function will enable word programming of the flash memory and set the mode of behavior when the flash write occurs.
- Parameters
-
mode | The mode specifies the behavior of the flash controller when programming words to flash. In FLASH_IMMEDIATE_WRITE_MODE, the program operation happens immediately on the write to flash while in FLASH_COLLATED_WRITE_MODE the write will be delayed until a full 128-bits have been collated. Possible values include:
- FLASH_IMMEDIATE_WRITE_MODE
- FLASH_COLLATED_WRITE_MODE
|
Refer to the user's guide for further documentation.
- Returns
- none
References FLASH_COLLATED_WRITE_MODE, and FLASH_IMMEDIATE_WRITE_MODE.
Referenced by FlashCtl_programMemory().
void FlashCtl_disableWordProgramming |
( |
void |
| ) |
|
Disables word programming of flash memory.
Refer to FlashCtl_enableWordProgramming and the user's guide for description on the difference between full word and immediate programming
- Returns
- None.
Referenced by FlashCtl_programMemory().
uint32_t FlashCtl_isWordProgrammingEnabled |
( |
void |
| ) |
|
Returns if word programming mode is enabled (and if it is, the specific mode)
Refer to FlashCtl_enableWordProgramming and the user's guide for description on the difference between full word and immediate programming
- Returns
- a zero value if word programming is disabled,
- FLASH_IMMEDIATE_WRITE_MODE
- FLASH_COLLATED_WRITE_MODE
References FLASH_COLLATED_WRITE_MODE, and FLASH_IMMEDIATE_WRITE_MODE.
bool FlashCtl_setReadMode |
( |
uint32_t |
flashBank, |
|
|
uint32_t |
readMode |
|
) |
| |
Sets the flash read mode to be used by default flash read operations. Note that the proper wait states must be set prior to entering this function.
- Parameters
-
flashBank | Flash bank to set read mode for. Valid values are:
|
readMode | The read mode to set. Valid values are:
- FLASH_NORMAL_READ_MODE,
- FLASH_MARGIN0_READ_MODE,
- FLASH_MARGIN1_READ_MODE,
- FLASH_PROGRAM_VERIFY_READ_MODE,
- FLASH_ERASE_VERIFY_READ_MODE,
- FLASH_LEAKAGE_VERIFY_READ_MODE,
- FLASH_MARGIN0B_READ_MODE,
- FLASH_MARGIN1B_READ_MODE
|
- Returns
- None.
References ASSERT, FLASH_BANK0, and FLASH_BANK1.
Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), and FlashCtl_verifyMemory().
uint32_t FlashCtl_getReadMode |
( |
uint32_t |
flashBank | ) |
|
Gets the flash read mode to be used by default flash read operations.
- Parameters
-
flashBank | Flash bank to set read mode for. Valid values are:
|
- Returns
- Returns the read mode to set. Valid values are:
- FLASH_NORMAL_READ_MODE,
- FLASH_MARGIN0_READ_MODE,
- FLASH_MARGIN1_READ_MODE,
- FLASH_PROGRAM_VERIFY_READ_MODE,
- FLASH_ERASE_VERIFY_READ_MODE,
- FLASH_LEAKAGE_VERIFY_READ_MODE,
- FLASH_MARGIN0B_READ_MODE,
- FLASH_MARGIN1B_READ_MODE
References ASSERT, FLASH_BANK0, and FLASH_BANK1.
Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), and FlashCtl_verifyMemory().
void FlashCtl_setWaitState |
( |
uint32_t |
bank, |
|
|
uint32_t |
waitState |
|
) |
| |
uint32_t FlashCtl_getWaitState |
( |
uint32_t |
bank | ) |
|
void FlashCtl_enableInterrupt |
( |
uint32_t |
flags | ) |
|
Enables individual flash control interrupt sources.
- Parameters
-
flags | is a bit mask of the interrupt sources to be enabled. Must be a logical OR of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
|
This function enables the indicated flash system interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.
- Note
- The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
- Returns
- None.
void FlashCtl_disableInterrupt |
( |
uint32_t |
flags | ) |
|
Disables individual flash system interrupt sources.
- Parameters
-
flags | is a bit mask of the interrupt sources to be disabled. Must be a logical OR of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
|
This function disables the indicated flash system interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.
- Returns
- None.
uint32_t FlashCtl_getEnabledInterruptStatus |
( |
void |
| ) |
|
Gets the current interrupt status masked with the enabled interrupts. This function is useful to call in ISRs to get a list of pending interrupts that are actually enabled and could have caused the ISR.
- Returns
- The current interrupt status, enumerated as a bit field of
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
- Note
- The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
References FlashCtl_getInterruptStatus().
uint32_t FlashCtl_getInterruptStatus |
( |
void |
| ) |
|
Gets the current interrupt status.
- Returns
- The current interrupt status, enumerated as a bit field of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
- Note
- The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
Referenced by FlashCtl_getEnabledInterruptStatus().
void FlashCtl_clearInterruptFlag |
( |
uint32_t |
flags | ) |
|
Clears flash system interrupt sources.
- Parameters
-
flags | is a bit mask of the interrupt sources to be cleared. Must be a logical OR of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
|
The specified flash system interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep it from being called again immediately upon exit.
- Note
- Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
-
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
- Returns
- None.
void FlashCtl_registerInterrupt |
( |
void(*)(void) |
intHandler | ) |
|
void FlashCtl_unregisterInterrupt |
( |
void |
| ) |
|
void FlashCtl_initiateSectorErase |
( |
uint32_t |
addr | ) |
|
Initiates a sector erase of MAIN or INFO flash memory. Note that this function simply initaites the sector erase, but does no verification which is required by the flash controller. The user must manually set and enable interrupts on the flash controller to fire on erase completion and then use the FlashCtl_verifyMemory function to verify that the sector was actually erased
- Parameters
-
addr | The start of the sector to erase. Note that with flash, the minimum allowed size that can be erased is a flash sector (which is 4KB on the MSP432 family). If an address is provided to this function which is not on a 4KB boundary, the entire sector will still be erased. |
- Returns
- None
References __INFO_FLASH_TECH_START__, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, and SysCtl_getFlashSize().
uint8_t __FlashCtl_remaskData8Post |
( |
uint8_t |
data, |
|
|
uint32_t |
addr |
|
) |
| |
uint8_t __FlashCtl_remaskData8Pre |
( |
uint8_t |
data, |
|
|
uint32_t |
addr |
|
) |
| |
uint32_t __FlashCtl_remaskData32Post |
( |
uint32_t |
data, |
|
|
uint32_t |
addr |
|
) |
| |
uint32_t __FlashCtl_remaskData32Pre |
( |
uint32_t |
data, |
|
|
uint32_t |
addr |
|
) |
| |
void __FlashCtl_remaskBurstDataPost |
( |
uint32_t |
addr, |
|
|
uint32_t |
size |
|
) |
| |
void __FlashCtl_remaskBurstDataPre |
( |
uint32_t |
addr, |
|
|
uint32_t |
size |
|
) |
| |