RTEMS: bsps/arm/atsam/include/libchip/include/efc.h File Reference

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Macros | Functions
efc.h File Reference
`#include "chip.h"`
`#include <stdint.h>`

Go to the source code of this file.

## Macros
#define | IFLASH_SECTOR_SIZE 65536u
#define | EFC_FCMD_GETD 0x00 /* Get Flash Descriptor */
#define | EFC_FCMD_WP 0x01 /* Write page */
#define | EFC_FCMD_WPL 0x02 /* Write page and lock */
#define | EFC_FCMD_EWP 0x03 /* Erase page and write page */
#define | EFC_FCMD_EWPL 0x04 /* Erase page and write page then lock */
#define | EFC_FCMD_EA 0x05 /* Erase all */
#define | EFC_FCMD_EPA 0x07 /* Erase pages */
#define | EFC_FCMD_SLB 0x08 /* Set Lock Bit */
#define | EFC_FCMD_CLB 0x09 /* Clear Lock Bit */
#define | EFC_FCMD_GLB 0x0A /* Get Lock Bit */
#define | EFC_FCMD_SFB 0x0B /* Set GPNVM Bit */
#define | EFC_FCMD_CFB 0x0C /* Clear GPNVM Bit */
#define | EFC_FCMD_GFB 0x0D /* Get GPNVM Bit */
#define | EFC_FCMD_STUI 0x0E /* Start unique ID */
#define | EFC_FCMD_SPUI 0x0F /* Stop unique ID */
#define | EFC_FCMD_GCALB 0x10 /* Get CALIB Bit */
#define | EFC_FCMD_ES 0x11 /* Erase Sector */
#define | EFC_FCMD_WUS 0x12 /* Write User Signature */
#define | EFC_FCMD_EUS 0x13 /* Erase User Signature */
#define | EFC_FCMD_STUS 0x14 /* Start Read User Signature */
#define | EFC_FCMD_SPUS 0x15 /* Stop Read User Signature */
#define | CHIP_FLASH_IAP_ADDRESS (0x00800008)

## Functions
void | EFC_EnableFrdyIt (Efc *efc)
| Enables the flash ready interrupt source on the EEFC peripheral.
void | EFC_DisableFrdyIt (Efc *efc)
| Disables the flash ready interrupt source on the EEFC peripheral.
void | EFC_SetWaitState (Efc *efc, uint8_t cycles)
| Set read/write wait state on the EEFC peripheral.
void | EFC_TranslateAddress (Efc **pEfc, uint32_t dwAddress, uint16_t *pwPage, uint16_t *pwOffset)
| Translates the given address page and offset values.
void | EFC_ComputeAddress (Efc *efc, uint16_t wPage, uint16_t wOffset, uint32_t *pdwAddress)
| Computes the address of a flash access given the page and offset.
uint32_t | EFC_PerformCommand (Efc *efc, uint32_t dwCommand, uint32_t dwArgument, uint32_t dwUseIAP)
| Performs the given command and wait until its completion (or an error).
uint32_t | EFC_GetStatus (Efc *efc)
| Returns the current status of the EEFC.
uint32_t | EFC_GetResult (Efc *efc)
| Returns the result of the last executed command.
void | EFC_SetFlashAccessMode (Efc *efc, uint32_t dwMode)
| Set flash access mode.

## Detailed Description

# Purpose

Interface for configuration the Enhanced Embedded Flash Controller (EEFC) peripheral.

# Usage

1. Enable/disable flash ready interrupt sources using EFC_EnableFrdyIt() and EFC_DisableFrdyIt().
2. Translates the given address into which EEFC, page and offset values for difference density flash memory using EFC_TranslateAddress().
3. Computes the address of a flash access given the EFC, page and offset for difference density flash memory using EFC_ComputeAddress().
4. Start the executing command with EFC_PerformCommand()
5. Retrieve the current status of the EFC using EFC_GetStatus().
6. Retrieve the result of the last executed command with EFC_GetResult().

## Function Documentation

## ◆ EFC_ComputeAddress()

void EFC_ComputeAddress | ( | Efc * | efc,
|  | uint16_t | wPage,
|  | uint16_t | wOffset,
|  | uint32_t * | pdwAddress
| ) |  |

Computes the address of a flash access given the page and offset.

Parameters

  efc | Pointer to a Efc instance
  page | Page number.
  offset | Byte offset inside page.
  pAddress | Computed address (optional).

## ◆ EFC_DisableFrdyIt()

void EFC_DisableFrdyIt | ( | Efc * | efc | ) |

Disables the flash ready interrupt source on the EEFC peripheral.

Parameters

  efc | Pointer to a Efc instance

## ◆ EFC_EnableFrdyIt()

void EFC_EnableFrdyIt | ( | Efc * | efc | ) |

Enables the flash ready interrupt source on the EEFC peripheral.

Parameters

  efc | Pointer to a Efc instance

## ◆ EFC_GetResult()

uint32_t EFC_GetResult | ( | Efc * | efc | ) |

Returns the result of the last executed command.

Parameters

  efc | Pointer to a Efc instance

## ◆ EFC_GetStatus()

uint32_t EFC_GetStatus | ( | Efc * | efc | ) |

Returns the current status of the EEFC.

Note
  Keep in mind that this function clears the value of some status bits (LOCKE, PROGE).

Parameters

  efc | Pointer to a Efc instance

## ◆ EFC_PerformCommand()

uint32_t EFC_PerformCommand | ( | Efc * | efc,
|  | uint32_t | dwCommand,
|  | uint32_t | dwArgument,
|  | uint32_t | dwUseIAP
| ) |  |

Performs the given command and wait until its completion (or an error).

Parameters

  efc | Pointer to a Efc instance
  command | Command to perform.
  argument | Optional command argument.

Returns
  0 if successful, otherwise returns an error code.

## ◆ EFC_SetFlashAccessMode()

void EFC_SetFlashAccessMode | ( | Efc * | efc,
|  | uint32_t | dwMode
| ) |  |

Set flash access mode.

Parameters

  dwMode | - 0:128-bit, (1<<24):64-bit

## ◆ EFC_SetWaitState()

void EFC_SetWaitState | ( | Efc * | efc,
|  | uint8_t | ucCycles
| ) |  |

Set read/write wait state on the EEFC peripheral.

Parameters

  efc | Pointer to a Efc instance
  cycles | the number of wait states in cycle.

## ◆ EFC_TranslateAddress()

void EFC_TranslateAddress | ( | Efc ** | ppEfc,
|  | uint32_t | dwAddress,
|  | uint16_t * | pwPage,
|  | uint16_t * | pwOffset
| ) |  |

Translates the given address page and offset values.

Note
  The resulting values are stored in the provided variables if they are not null.

Parameters

  efc | Pointer to a Efc instance
  address | Address to translate.
  pPage | First page accessed.
  pOffset | Byte offset in first page.