Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NVM driver generic module handling

Support functions for the NVM driver.

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

Functions

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

void nvm_common_spm ( uint32_t  addr,
uint8_t  nvm_cmd 
)

Perform SPM write.

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
addrAddress to perform the SPM on.
nvm_cmdNVM 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_flush_buffer(), nvm_flash_split_write_app_page(), nvm_flash_split_write_boot_page(), and nvm_flash_write_user_page().

static void nvm_exec ( void  )
inlinestatic

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.

References ccp_write_io().

Referenced by nvm_eeprom_flush_buffer(), and nvm_eeprom_write_byte().

static void nvm_issue_command ( NVM_CMD_t  nvm_command)
inlinestatic

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_commandNVM Command to execute.

References ccp_write_io().

Referenced by nvm_eeprom_atomic_write_page(), nvm_eeprom_erase_bytes_in_all_pages(), nvm_eeprom_erase_bytes_in_page(), nvm_eeprom_split_write_page(), nvm_fuses_read(), and nvm_lock_bits_write().

uint8_t nvm_read_byte ( uint8_t  nvm_cmd,
uint16_t  address 
)

Read one byte using the LDI instruction.

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_cmdNVM command to load before running LPM
addressByte offset into the signature row

Referenced by nvm_read_production_signature_row(), and nvm_read_user_signature_row().