Xmega Application Note


NVM driver generic module handling
[NVM driver]

Support functions for the NVM driver. More...

Collaboration diagram for NVM driver generic module handling:

Functions

void nvm_common_spm (uint32_t addr, uint8_t nvm_cmd)
 Perform SPM write.
static void nvm_exec (void)
 Non-Volatile Memory Execute Command.
static void nvm_issue_command (NVM_CMD_t nvm_command)
 Non-Volatile Memory Execute Specific Command.
uint8_t nvm_read_byte_near (uint8_t nvm_cmd, uint8_t address)
 Read one byte using the LDI instruction.
static void nvm_wait_until_ready (void)
 Wait for any NVM access to finish.

Detailed Description

Support functions for the NVM driver.

These functions are helper functions for the functions of the NVM driver.


Function Documentation

void nvm_common_spm ( uint32_t  addr,
uint8_t  nvm_cmd 
)

Perform SPM write.

For internal use only.

This function sets the specified NVM_CMD, sets CCP and then runs the SPM instruction to write to flash.

Note:
Interrupts should be disabled before running this function if program memory/NVM controller is accessed from ISRs.
Parameters:
addr Address to perform the SPM on.
nvm_cmd NVM command to use in the NVM_CMD register

Referenced by nvm_flash_atomic_write_app_page(), nvm_flash_atomic_write_boot_page(), nvm_flash_erase_app(), nvm_flash_erase_app_page(), nvm_flash_erase_boot_page(), nvm_flash_erase_user_section(), nvm_flash_split_write_app_page(), nvm_flash_split_write_boot_page(), and nvm_flash_write_user_page().

static void nvm_exec ( void   )  [inline, static]

Non-Volatile Memory Execute Command.

This function sets the CCP register before setting the CMDEX bit in the NVM.CTRLA register.

Note:
The correct NVM command must be set in the NVM.CMD register before calling this function.

Definition at line 97 of file nvm.h.

References ccp_write_io().

00098 {
00099         ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm);
00100 }

Here is the call graph for this function:

static void nvm_issue_command ( NVM_CMD_t  nvm_command  )  [inline, static]

Non-Volatile Memory Execute Specific Command.

This function sets a command in the NVM.CMD register, then performs an execute command by writing the CMDEX bit to the NVM.CTRLA register.

Note:
The function saves and restores the NVM.CMD register, but if this function is called from an interrupt, interrupts must be disabled before this function is called.
Parameters:
nvm_command NVM Command to execute.

Definition at line 114 of file nvm.h.

References ccp_write_io().

00115 {
00116         uint8_t old_cmd;
00117 
00118         old_cmd = NVM.CMD;
00119         NVM.CMD = nvm_command;
00120         ccp_write_io((uint8_t *)&NVM.CTRLA, NVM_CMDEX_bm);
00121         NVM.CMD = old_cmd;
00122 }

Here is the call graph for this function:

uint8_t nvm_read_byte_near ( uint8_t  nvm_cmd,
uint8_t  address 
)

Read one byte using the LDI instruction.

For internal use only.

This function sets the specified NVM_CMD, reads one byte using at the specified byte address with the LPM instruction. NVM_CMD is restored after use.

Note:
Interrupts should be disabled before running this function if program memory/NVM controller is accessed from ISRs.
Parameters:
nvm_cmd NVM commad to load before running LPM
address Byte offset into the signature row

Referenced by nvm_read_production_signature_row(), and nvm_read_user_signature_row().

static void nvm_wait_until_ready ( void   )  [inline, static]

Wait for any NVM access to finish.

This function is blocking and waits for any NVM access to finish. Use this function before any NVM accesses, if you are not certain that any previous operations are finished yet.

Definition at line 81 of file nvm.h.

Referenced by nvm_flash_atomic_write_app_page(), nvm_flash_atomic_write_boot_page(), nvm_flash_erase_app(), nvm_flash_erase_app_page(), nvm_flash_erase_boot_page(), nvm_flash_erase_user_section(), nvm_flash_split_write_app_page(), nvm_flash_split_write_boot_page(), and nvm_flash_write_user_page().

00082 {
00083         do {
00084                 // Block execution while waiting for the NVM to be ready
00085         } while ((NVM.STATUS & NVM_NVMBUSY_bm) == NVM_NVMBUSY_bm);
00086 }

@DOC_TITLE@
Generated on Fri Oct 22 12:15:26 2010 for AVR1300 Using the Xmega ADC by doxygen 1.6.3