Microchip® Advanced Software Framework

flash.h File Reference

MEGA FLASH DRIVER.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <avr/boot.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>

Macros

#define EEPROM_BUSY_WAIT()   eeprom_busy_wait()
 
#define ENABLE_RWW_SECTION()   boot_rww_enable()
 
#define FLASH_ERASE(addr)   boot_page_erase(addr)
 
#define FLASH_PAGE_FILL(addr, data)   boot_page_fill(addr, data)
 
#define FLASH_PAGE_WRITE(addr)   boot_page_write(addr)
 
#define PGM_READ_BYTE_FAR(x)   pgm_read_byte_far(x)
 
#define SPM_BUSY_WAIT()   boot_spm_busy_wait()
 

Functions

void flash_erase_page (uint32_t)
 Erases a page. More...
 
void flash_fill_page_buffer (uint32_t, uint16_t, uint8_t *)
 Fills the temporary page buffer. More...
 
void flash_program_page (uint32_t)
 Erases and Writes the actual flash page. More...
 
void flash_read (uint32_t, uint32_t, uint8_t *)
 Reads data from the flash memory. More...
 
void flash_write (uint32_t, uint32_t, uint8_t *)
 Writes data to flash location : Performs all activities like filling the page buffer,erasing the flash page and pushing the data to the appropriate page address. More...
 

Variables

void noinline
 

#define EEPROM_BUSY_WAIT ( )    eeprom_busy_wait()
#define ENABLE_RWW_SECTION ( )    boot_rww_enable()
#define FLASH_ERASE (   addr)    boot_page_erase(addr)
#define FLASH_PAGE_FILL (   addr,
  data 
)    boot_page_fill(addr, data)
#define FLASH_PAGE_WRITE (   addr)    boot_page_write(addr)
#define PGM_READ_BYTE_FAR (   x)    pgm_read_byte_far(x)
#define SPM_BUSY_WAIT ( )    boot_spm_busy_wait()

void flash_erase_page ( uint32_t  )

Erases a page.

Parameters
page_numberThe page that has to be erased
void flash_fill_page_buffer ( uint32_t  ,
uint16_t  ,
uint8_t *   
)

Fills the temporary page buffer.

This function fills the temporay flash page buffer.

Parameters
flash_addraddress of flash to be written
lengthLength of provide data buffer
dataPointer to data buffer
void flash_program_page ( uint32_t  )

Erases and Writes the actual flash page.

This function writes the data from the temporary flash page buffer to the actual flash page.

Parameters
page_start_addrStart address of the flash page
void flash_read ( uint32_t  ,
uint32_t  ,
uint8_t *   
)

Reads data from the flash memory.

Parameters
read_addrAddress in the Flash to be read
lenNumber of bytes to be read
ret_bufPointer to the location of the read data

References cpu_irq_restore(), cpu_irq_save(), and PGM_READ_BYTE_FAR.

Referenced by flash_write().

void flash_write ( uint32_t  ,
uint32_t  ,
uint8_t *   
)

Writes data to flash location : Performs all activities like filling the page buffer,erasing the flash page and pushing the data to the appropriate page address.

Parameters
flash_addrFlash address to be written
lengthNumber of bytes to write
dataPointer to data location

References data, flash_fill_page_buffer(), flash_program_page(), and flash_read().

void noinline