# FLASH Module

The Flash driver provides functions to configure the fallback power modes and the active grace periods of flash banks and pump, and the pump wake-up time. This driver also provides functions to configure the flash wait-states, prefetch, cache and ECC features. It also provides functions to access the Flash ECC test mode registers and the Flash ECC error status registers.

group `flash_api`

  Defines

  `FLASHCONFIG_BASE` 0x00057000U

    Flash Trim Defines.

  `FLASH_O_TRIMCTL` 0x1600U
  `FLASH_O_TRIMLOCK` 0x1604U
  `FLASH_O_TRIMCOMMIT` 0x1608U
  `FLASH_TRIMCTL_ENABLE_M` 0x1U
  `FLASH_TRIMCTL_ENABLE_S` 0x0U
  `FLASH_TRIMLOCK_TRIMLOCKREAD_TRIMLOCKOTHER_M` 0x3U
  `FLASH_TRIMLOCK_TRIMLOCKREAD_TRIMLOCKOTHER_S` 0x0U
  `FLASH_TRIMCOMMIT_TRIMCOMMITREAD_TRIMCOMMITOTHER_M` 0x3U
  `FLASH_TRIMCOMMIT_TRIMCOMMITREAD_TRIMCOMMITOTHER_S` 0x0U
  `FLASH_DELAY_CONFIG` __asm(" RPT #7 || NOP")
  `FLASH_SINGLE_BIT_ECC_TEST_EN` 0x1U
  `FLASH_DOUBLE_BIT_ECC_TEST_EN` 0x3U

  Functions

  void `Flash_setWaitstates`(uint32_t ctrlBase, uint16_t waitstates)

    Sets the random read wait state amount.

    This function sets the number of wait states for a flash read access. The

    waitstates parameter is a number between 0 and 15. It is important to look at your device’s datasheet for information about what the required minimum flash wait-state is for your selected SYSCLK frequency.
    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

      - `waitstates`: is the wait-state value.

    By default the wait state amount is configured to the maximum 15.

    Return

      None.

  void `Flash_enablePrefetch`(uint32_t ctrlBase)

    Enables prefetch mechanism.

    Return

      None.

    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

  void `Flash_disablePrefetch`(uint32_t ctrlBase)

    Disables prefetch mechanism.

    Return

      None.

    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

  void `Flash_enableCache`(uint32_t ctrlBase)

    Enables data cache.

    Return

      None.

    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

  void `Flash_disableCache`(uint32_t ctrlBase)

    Disables data cache.

    Return

      None.

    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

  void `Flash_setFLWEPROT`(uint32_t ctrlBase)

    Sets the FLWEPROT value of the FLPROT register.

    Return

      None.

    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

  void `Flash_enableECC`(uint32_t eccBase)

    Enables flash error correction code (ECC) protection.

    Return

      None.

    Parameters

      - `eccBase`: is the base address of the flash wrapper ECC registers.

  void `Flash_disableECC`(uint32_t eccBase)

    Disables flash error correction code (ECC) protection.

    Return

      None.

    Parameters

      - `eccBase`: is the base address of the flash wrapper ECC registers.

  void `Flash_enableSingleBitECCTestMode`(uint32_t eccBase)

    Enables Single Bit ECC Test mode.

    Return

      None.

    Parameters

      - `eccBase`: is the base address of the flash wrapper ECC registers.

  void `Flash_enableDoubleBitECCTestMode`(uint32_t eccBase)

    Enables Double Bit ECC Test mode.

    Return

      None.

    Parameters

      - `eccBase`: is the base address of the flash wrapper ECC registers.

  void `Flash_disableSingleBitECCTestMode`(uint32_t eccBase)

    Disables Single Bit ECC Test mode.

    Return

      None.

    Parameters

      - `eccBase`: is the base address of the flash wrapper ECC registers.

  void `Flash_disableDoubleBitECCTestMode`(uint32_t eccBase)

    Disables Double Bit ECC Test mode.

    Return

      None.

    Parameters

      - `eccBase`: is the base address of the flash wrapper ECC registers.

  void `Flash_initModule`(uint32_t ctrlBase, uint32_t eccBase, uint16_t waitstates)

    Initializes the flash control registers.

    This function initializes the flash control registers. At reset bank and pump are in sleep. A flash access will power up the bank and pump automatically. This function will power up Flash bank and pump and set the fallback mode of flash and pump as active.

    Parameters

      - `ctrlBase`: is the base address of the flash wrapper control registers.

      - `eccBase`: is the base address of the flash wrapper ECC registers.

      - `waitstates`: is the wait-state value.

    This function also sets the number of wait-states for a flash access (see Flash_setWaitstates() for more details), and enables cache, the prefetch mechanism, and ECC.

    Return

      None.

  void `Flash_writeTrims`(uint32_t reg_offset, uint32_t mask, uint32_t shift, uint32_t value)

    Initializes the flash trim registers.

    Return

      None.

The code for this module is contained in driverlib/flash.c, with driverlib/flash.h containing the API declarations for use by applications.