Macros | |
#define | BLOCKS_FROM_EESIZE(x) |
#define | SIZE_FROM_EESIZE(x) |
#define | OFFSET_FROM_ADDR(x) (((x) >> 2) & 0x0F) |
#define | EEPROM_MASS_ERASE_KEY ((uint32_t)0xE37B << EEPROM_EEDBGME_KEY_S) |
#define | EEPROM_INIT_OK 0 |
#define | EEPROM_INIT_ERROR 2 |
#define | EEPROM_RC_WRBUSY 0x00000020 |
#define | EEPROM_RC_NOPERM 0x00000010 |
#define | EEPROM_RC_WKCOPY 0x00000008 |
#define | EEPROM_RC_WKERASE 0x00000004 |
#define | EEPROM_RC_WORKING 0x00000001 |
#define | EEPROM_PROT_SUPERVISOR_ONLY 0x00000008 |
#define | EEPROM_PROT_RW_LRO_URW 0x00000000 |
#define | EEPROM_PROT_NA_LNA_URW 0x00000001 |
#define | EEPROM_PROT_RO_LNA_URO 0x00000002 |
#define | EEPROM_INT_PROGRAM 0x00000004 |
#define | EEPROMBlockFromAddr(ui32Addr) ((ui32Addr) >> 6) |
#define | EEPROMAddrFromBlock(ui32Block) ((ui32Block) << 6) |
Functions | |
uint32_t | EEPROMInit (void) |
uint32_t | EEPROMSizeGet (void) |
uint32_t | EEPROMBlockCountGet (void) |
void | EEPROMRead (uint32_t *pui32Data, uint32_t ui32Address, uint32_t ui32Count) |
uint32_t | EEPROMProgram (uint32_t *pui32Data, uint32_t ui32Address, uint32_t ui32Count) |
uint32_t | EEPROMProgramNonBlocking (uint32_t ui32Data, uint32_t ui32Address) |
uint32_t | EEPROMMassErase (void) |
uint32_t | EEPROMBlockProtectGet (uint32_t ui32Block) |
uint32_t | EEPROMBlockProtectSet (uint32_t ui32Block, uint32_t ui32Protect) |
uint32_t | EEPROMBlockPasswordSet (uint32_t ui32Block, uint32_t *pui32Password, uint32_t ui32Count) |
uint32_t | EEPROMBlockLock (uint32_t ui32Block) |
uint32_t | EEPROMBlockUnlock (uint32_t ui32Block, uint32_t *pui32Password, uint32_t ui32Count) |
void | EEPROMBlockHide (uint32_t ui32Block) |
void | EEPROMIntEnable (uint32_t ui32IntFlags) |
void | EEPROMIntDisable (uint32_t ui32IntFlags) |
uint32_t | EEPROMIntStatus (bool bMasked) |
void | EEPROMIntClear (uint32_t ui32IntFlags) |
uint32_t | EEPROMStatusGet (void) |
#define BLOCKS_FROM_EESIZE | ( | x | ) |
Referenced by EEPROMBlockCountGet(), EEPROMBlockHide(), EEPROMBlockLock(), EEPROMBlockPasswordSet(), EEPROMBlockProtectGet(), EEPROMBlockProtectSet(), and EEPROMBlockUnlock().
#define SIZE_FROM_EESIZE | ( | x | ) |
Referenced by EEPROMProgram(), EEPROMProgramNonBlocking(), EEPROMRead(), and EEPROMSizeGet().
#define OFFSET_FROM_ADDR | ( | x | ) | (((x) >> 2) & 0x0F) |
Referenced by EEPROMProgram(), EEPROMProgramNonBlocking(), and EEPROMRead().
#define EEPROM_MASS_ERASE_KEY ((uint32_t)0xE37B << EEPROM_EEDBGME_KEY_S) |
Referenced by EEPROMMassErase().
#define EEPROM_INIT_OK 0 |
This value may be returned from a call to EEPROMInit(). It indicates that no previous write operations were interrupted by a reset event and that the EEPROM peripheral is ready for use.
#define EEPROM_INIT_ERROR 2 |
This value may be returned from a call to EEPROMInit(). It indicates that a previous data or protection write operation was interrupted by a reset event and that the EEPROM peripheral was unable to clean up after the problem. This situation may be resolved with another reset or may be fatal depending upon the cause of the problem. For example, if the voltage to the part is unstable, retrying once the voltage has stabilized may clear the error.
#define EEPROM_RC_WRBUSY 0x00000020 |
This return code bit indicates that an attempt was made to read from the EEPROM while a write operation was in progress.
#define EEPROM_RC_NOPERM 0x00000010 |
This return code bit indicates that an attempt was made to write a value but the destination permissions disallow write operations. This may be due to the destination block being locked, access protection set to prohibit writes or an attempt to write a password when one is already written.
#define EEPROM_RC_WKCOPY 0x00000008 |
This return code bit indicates that the EEPROM programming state machine is currently copying to or from the internal copy buffer to make room for a newly written value. It is provided as a status indicator and does not indicate an error.
#define EEPROM_RC_WKERASE 0x00000004 |
This return code bit indicates that the EEPROM programming state machine is currently erasing the internal copy buffer. It is provided as a status indicator and does not indicate an error.
#define EEPROM_RC_WORKING 0x00000001 |
This return code bit indicates that the EEPROM programming state machine is currently working. No new write operations should be attempted until this bit is clear.
#define EEPROM_PROT_SUPERVISOR_ONLY 0x00000008 |
This bit may be ORed with the protection option passed to EEPROMBlockProtectSet() or returned from EEPROMBlockProtectGet(). It restricts EEPROM access to threads running in supervisor mode and prevents access to an EEPROM block when the CPU is in user mode.
#define EEPROM_PROT_RW_LRO_URW 0x00000000 |
This value may be passed to EEPROMBlockProtectSet() or returned from EEPROMBlockProtectGet(). It indicates that the block should offer read/write access when no password is set or when a password is set and the block is unlocked, and read-only access when a password is set but the block is locked.
#define EEPROM_PROT_NA_LNA_URW 0x00000001 |
This value may be passed to EEPROMBlockProtectSet() or returned from EEPROMBlockProtectGet(). It indicates that the block should offer neither read nor write access unless it is protected by a password and unlocked.
#define EEPROM_PROT_RO_LNA_URO 0x00000002 |
This value may be passed to EEPROMBlockProtectSet() or returned from EEPROMBlockProtectGet(). It indicates that the block should offer read-only access when no password is set or when a password is set and the block is unlocked. When a password is set and the block is locked, neither read nor write access is permitted.
#define EEPROM_INT_PROGRAM 0x00000004 |
This value may be passed to EEPROMIntEnable() and EEPROMIntDisable() and is returned by EEPROMIntStatus() if an EEPROM interrupt is currently being signaled.
Referenced by EEPROMIntDisable(), EEPROMIntEnable(), and EEPROMIntStatus().
#define EEPROMBlockFromAddr | ( | ui32Addr | ) | ((ui32Addr) >> 6) |
Returns the EEPROM block number containing a given offset address.
ui32Addr | is the linear, byte address of the EEPROM location whose block number is to be returned. This is a zero-based offset from the start of the EEPROM storage. |
This macro may be used to translate an EEPROM address offset into a block number suitable for use in any of the driver's block protection functions. The address provided is expressed as a byte offset from the base of the EEPROM.
Referenced by EEPROMProgram(), EEPROMProgramNonBlocking(), and EEPROMRead().
#define EEPROMAddrFromBlock | ( | ui32Block | ) | ((ui32Block) << 6) |
Returns the offset address of the first word in an EEPROM block.
ui32Block | is the index of the EEPROM block whose first word address is to be returned. |
This macro may be used to determine the address of the first word in a given EEPROM block. The address returned is expressed as a byte offset from the base of EEPROM storage.
uint32_t EEPROMInit | ( | void | ) |
Performs any necessary recovery in case of power failures during write.
This function must be called after SysCtlPeripheralEnable() and before the EEPROM is accessed. It is used to check for errors in the EEPROM state such as from power failure during a previous write operation. The function detects these errors and performs as much recovery as possible.
If EEPROM_INIT_ERROR is returned, the EEPROM was unable to recover its state. If power is stable when this occurs, this indicates a fatal error and is likely an indication that the EEPROM memory has exceeded its specified lifetime write/erase specification. If the supply voltage is unstable when this return code is observed, retrying the operation once the voltage is stabilized may clear the error.
Failure to call this function after a reset may lead to incorrect operation or permanent data loss if the EEPROM is later written.
References SysCtlDelay().
uint32_t EEPROMSizeGet | ( | void | ) |
Determines the size of the EEPROM.
This function returns the size of the EEPROM in bytes.
References EEPROM_EESIZE, HWREG, and SIZE_FROM_EESIZE.
uint32_t EEPROMBlockCountGet | ( | void | ) |
Determines the number of blocks in the EEPROM.
This function may be called to determine the number of blocks in the EEPROM. Each block is the same size and the number of bytes of storage contained in a block may be determined by dividing the size of the device, obtained via a call to the EEPROMSizeGet() function, by the number of blocks returned by this function.
References BLOCKS_FROM_EESIZE, EEPROM_EESIZE, and HWREG.
void EEPROMRead | ( | uint32_t * | pui32Data, |
uint32_t | ui32Address, | ||
uint32_t | ui32Count | ||
) |
Reads data from the EEPROM.
pui32Data | is a pointer to storage for the data read from the EEPROM. This pointer must point to at least ui32Count bytes of available memory. |
ui32Address | is the byte address within the EEPROM from which data is to be read. This value must be a multiple of 4. |
ui32Count | is the number of bytes of data to read from the EEPROM. This value must be a multiple of 4. |
This function may be called to read a number of words of data from a word-aligned address within the EEPROM. Data read is copied into the buffer pointed to by the pui32Data parameter.
References ASSERT, EEPROM_EEBLOCK, EEPROM_EEOFFSET, EEPROM_EERDWRINC, EEPROM_EESIZE, EEPROMBlockFromAddr, HWREG, OFFSET_FROM_ADDR, and SIZE_FROM_EESIZE.
uint32_t EEPROMProgram | ( | uint32_t * | pui32Data, |
uint32_t | ui32Address, | ||
uint32_t | ui32Count | ||
) |
Writes data to the EEPROM.
pui32Data | points to the first word of data to write to the EEPROM. |
ui32Address | defines the byte address within the EEPROM that the data is to be written to. This value must be a multiple of 4. |
ui32Count | defines the number of bytes of data that is to be written. This value must be a multiple of 4. |
This function may be called to write data into the EEPROM at a given word-aligned address. The call is synchronous and returns only after all data has been written or an error occurs.
References ASSERT, EEPROM_EEBLOCK, EEPROM_EEDONE, EEPROM_EEDONE_NOPERM, EEPROM_EEDONE_WORKING, EEPROM_EEOFFSET, EEPROM_EERDWRINC, EEPROM_EESIZE, EEPROMBlockFromAddr, HWREG, OFFSET_FROM_ADDR, SIZE_FROM_EESIZE, and SysCtlDelay().
uint32_t EEPROMProgramNonBlocking | ( | uint32_t | ui32Data, |
uint32_t | ui32Address | ||
) |
Writes a word to the EEPROM.
ui32Data | is the word to write to the EEPROM. |
ui32Address | defines the byte address within the EEPROM to which the data is to be written. This value must be a multiple of 4. |
This function is intended to allow EEPROM programming under interrupt control. It may be called to start the process of writing a single word of data into the EEPROM at a given word-aligned address. The call is asynchronous and returns immediately without waiting for the write to complete. Completion of the operation is signaled by means of an interrupt from the EEPROM module. The EEPROM peripheral shares a single interrupt vector with the flash memory subsystem, INT_FLASH.
References ASSERT, EEPROM_EEBLOCK, EEPROM_EEDONE, EEPROM_EEOFFSET, EEPROM_EERDWRINC, EEPROM_EESIZE, EEPROMBlockFromAddr, HWREG, OFFSET_FROM_ADDR, and SIZE_FROM_EESIZE.
uint32_t EEPROMMassErase | ( | void | ) |
Erases the EEPROM and returns it to the factory default condition.
This function completely erases the EEPROM and removes any and all access protection on its blocks, leaving the device in the factory default condition. After this operation, all EEPROM words contain the value 0xFFFFFFFF and all blocks are accessible for both read and write operations in all CPU modes. No passwords are active.
The function is synchronous and does not return until the erase operation has completed.
References EEPROM_EEDBGME, EEPROM_EEDBGME_ME, EEPROM_MASS_ERASE_KEY, and HWREG.
uint32_t EEPROMBlockProtectGet | ( | uint32_t | ui32Block | ) |
Returns the current protection level for an EEPROM block.
ui32Block | is the block number for which the protection level is to be queried. |
This function returns the current protection settings for a given EEPROM block. If block 0 is currently locked, it must be unlocked prior to calling this function to query the protection setting for other blocks.
References ASSERT, BLOCKS_FROM_EESIZE, EEPROM_EEBLOCK, EEPROM_EEPROT, EEPROM_EESIZE, and HWREG.
uint32_t EEPROMBlockProtectSet | ( | uint32_t | ui32Block, |
uint32_t | ui32Protect | ||
) |
Set the current protection options for an EEPROM block.
ui32Block | is the block number for which the protection options are to be set. |
ui32Protect | consists of one of the values EEPROM_PROT_RW_LRO_URW, EEPROM_PROT_NA_LNA_URW or EEPROM_PROT_RO_LNA_URO optionally ORed with EEPROM_PROT_SUPERVISOR_ONLY. |
This function sets the protection settings for a given EEPROM block assuming no protection settings have previously been written. Note that protection settings applied to block 0 have special meaning and control access to the EEPROM peripheral as a whole. Protection settings applied to blocks numbered 1 and above are layered above any protection set on block 0 such that the effective protection on each block is the logical OR of the protection flags set for block 0 and for the target block. This protocol allows global protection options to be set for the whole device via block 0 and more restrictive protection settings to be set on a block-by-block basis.
The protection flags indicate access permissions as follow:
EEPROM_PROT_SUPERVISOR_ONLY restricts access to the block to threads running in supervisor mode. If clear, both user and supervisor threads can access the block.
EEPROM_PROT_RW_LRO_URW provides read/write access to the block if no password is set or if a password is set and the block is unlocked. If the block is locked, only read access is permitted.
EEPROM_PROT_NA_LNA_URW provides neither read nor write access unless a password is set and the block is unlocked. If the block is unlocked, both read and write access are permitted.
EEPROM_PROT_RO_LNA_URO provides read access to the block if no password is set or if a password is set and the block is unlocked. If the block is password protected and locked, neither read nor write access is permitted.
References ASSERT, BLOCKS_FROM_EESIZE, EEPROM_EEBLOCK, EEPROM_EEDONE, EEPROM_EEDONE_WORKING, EEPROM_EEPROT, EEPROM_EESIZE, and HWREG.
uint32_t EEPROMBlockPasswordSet | ( | uint32_t | ui32Block, |
uint32_t * | pui32Password, | ||
uint32_t | ui32Count | ||
) |
Sets the password used to protect an EEPROM block.
ui32Block | is the EEPROM block number for which the password is to be set. |
pui32Password | points to an array of uint32_t values comprising the password to set. Each element may be any 32-bit value other than 0xFFFFFFFF. This array must contain the number of elements given by the ui32Count parameter. |
ui32Count | provides the number of uint32_ts in the ui32Password. Valid values are 1, 2 and 3. |
This function allows the password used to unlock an EEPROM block to be set. Valid passwords may be either 32, 64 or 96 bits comprising words with any value other than 0xFFFFFFFF. The password may only be set once. Any further attempts to set the password result in an error. Once the password is set, the block remains unlocked until EEPROMBlockLock() is called for that block or block 0, or a reset occurs.
If a password is set on block 0, this affects locking of the peripheral as a whole. When block 0 is locked, all other EEPROM blocks are inaccessible until block 0 is unlocked. Once block 0 is unlocked, other blocks become accessible according to any passwords set on those blocks and the protection set for that block via a call to EEPROMBlockProtectSet().
References ASSERT, BLOCKS_FROM_EESIZE, EEPROM_EEBLOCK, EEPROM_EEDONE, EEPROM_EEDONE_WORKING, EEPROM_EEPASS0, EEPROM_EESIZE, and HWREG.
uint32_t EEPROMBlockLock | ( | uint32_t | ui32Block | ) |
Locks a password-protected EEPROM block.
ui32Block | is the EEPROM block number which is to be locked. |
This function locks an EEPROM block that has previously been protected by writing a password. Access to the block once it is locked is determined by the protection settings applied via a previous call to the EEPROMBlockProtectSet() function. If no password has previously been set for the block, this function has no effect.
Locking block 0 has the effect of making all other blocks in the EEPROM inaccessible.
References ASSERT, BLOCKS_FROM_EESIZE, EEPROM_EEBLOCK, EEPROM_EESIZE, EEPROM_EEUNLOCK, and HWREG.
uint32_t EEPROMBlockUnlock | ( | uint32_t | ui32Block, |
uint32_t * | pui32Password, | ||
uint32_t | ui32Count | ||
) |
Unlocks a password-protected EEPROM block.
ui32Block | is the EEPROM block number which is to be unlocked. |
pui32Password | points to an array of uint32_t values containing the password for the block. Each element must match the password originally set via a call to EEPROMBlockPasswordSet(). |
ui32Count | provides the number of elements in the pui32Password array and must match the value originally passed to EEPROMBlockPasswordSet(). Valid values are 1, 2 and 3. |
This function unlocks an EEPROM block that has previously been protected by writing a password. Access to the block once it is unlocked is determined by the protection settings applied via a previous call to the EEPROMBlockProtectSet() function.
To successfully unlock an EEPROM block, the password provided must match the password provided on the original call to EEPROMBlockPasswordSet(). If an incorrect password is provided, the block remains locked.
Unlocking block 0 has the effect of making all other blocks in the device accessible according to their own access protection settings. When block 0 is locked, all other EEPROM blocks are inaccessible.
References ASSERT, BLOCKS_FROM_EESIZE, EEPROM_EEBLOCK, EEPROM_EESIZE, EEPROM_EEUNLOCK, and HWREG.
void EEPROMBlockHide | ( | uint32_t | ui32Block | ) |
Hides an EEPROM block until the next reset.
ui32Block | is the EEPROM block number which is to be hidden. |
This function hides an EEPROM block other than block 0. Once hidden, a block is completely inaccessible until the next reset. This mechanism allows initialization code to have access to data which is to be hidden from the rest of the application. Unlike applications using passwords, an application making using of block hiding need not contain any embedded passwords which could be found through disassembly.
References ASSERT, BLOCKS_FROM_EESIZE, EEPROM_EEHIDE, EEPROM_EESIZE, and HWREG.
void EEPROMIntEnable | ( | uint32_t | ui32IntFlags | ) |
Enables the EEPROM interrupt.
ui32IntFlags | indicates which EEPROM interrupt source to enable. This must be EEPROM_INT_PROGRAM currently. |
This function enables the EEPROM interrupt. When enabled, an interrupt is generated when any EEPROM write or erase operation completes. The EEPROM peripheral shares a single interrupt vector with the flash memory subsystem, INT_FLASH. This function is provided as a convenience but the EEPROM interrupt can also be enabled using a call to FlashIntEnable() passing FLASH_INT_EEPROM in the ui32IntFlags parameter.
References ASSERT, EEPROM_EEINT, EEPROM_EEINT_INT, EEPROM_INT_PROGRAM, FLASH_FCIM, FLASH_FCRIS_ERIS, and HWREG.
void EEPROMIntDisable | ( | uint32_t | ui32IntFlags | ) |
Disables the EEPROM interrupt.
ui32IntFlags | indicates which EEPROM interrupt source to disable. This must be EEPROM_INT_PROGRAM currently. |
This function disables the EEPROM interrupt and prevents calls to the interrupt vector when any EEPROM write or erase operation completes. The EEPROM peripheral shares a single interrupt vector with the flash memory subsystem, INT_FLASH. This function is provided as a convenience but the EEPROM interrupt can also be disabled using a call to FlashIntDisable() passing FLASH_INT_EEPROM in the ui32IntFlags parameter.
References ASSERT, EEPROM_EEINT, EEPROM_EEINT_INT, EEPROM_INT_PROGRAM, FLASH_FCIM, FLASH_FCIM_EMASK, and HWREG.
uint32_t EEPROMIntStatus | ( | bool | bMasked | ) |
Reports the state of the EEPROM interrupt.
bMasked | determines whether the masked or unmasked state of the interrupt is to be returned. If bMasked is true, the masked state is returned, otherwise the unmasked state is returned. |
This function allows an application to query the state of the EEPROM interrupt. If active, the interrupt may be cleared by calling EEPROMIntClear().
References EEPROM_EEDONE, EEPROM_EEDONE_WORKING, EEPROM_INT_PROGRAM, FLASH_FCMISC, FLASH_FCMISC_EMISC, and HWREG.
void EEPROMIntClear | ( | uint32_t | ui32IntFlags | ) |
Clears the EEPROM interrupt.
ui32IntFlags | indicates which interrupt sources to clear. Currently, the only valid value is EEPROM_INT_PROGRAM. |
This function allows an application to clear the EEPROM interrupt.
References FLASH_FCMISC, FLASH_FCMISC_EMISC, and HWREG.
uint32_t EEPROMStatusGet | ( | void | ) |
Returns status on the last EEPROM program or erase operation.
This function returns the current status of the last program or erase operation performed by the EEPROM. It is intended to provide error information to applications programming or setting EEPROM protection options under interrupt control.
References EEPROM_EEDONE, and HWREG.