Xmega Application Note | |||||
Go to the source code of this file.
Defines | |
#define | APPTABLE_SECTION_START 0x01E000 |
#define | FLASH_PAGE_SIZE 512 |
Functions | |
uint32_t | SP_ApplicationCRC (void) |
Generate CRC from application section. | |
uint32_t | SP_BootCRC (void) |
Generate CRC from boot section. | |
void | SP_EraseApplicationPage (uint32_t address) |
Erase page at byte address in application or application table section. | |
void | SP_EraseApplicationSection (void) |
Erase entire application section. | |
void | SP_EraseBootPage (uint32_t address) |
Erase page at byte address in boot section. | |
void | SP_EraseFlashBuffer (void) |
Flush Flash page buffer. | |
void | SP_EraseUserSignatureRow (void) |
Erase user signature row. | |
void | SP_EraseWriteApplicationPage (uint32_t address) |
Erase and write page buffer to application or application table section at byte address. | |
void | SP_EraseWriteBootPage (uint32_t address) |
Erase and write page buffer to boot section at byte address. | |
uint32_t | SP_FlashRangeCRC (uint32_t StartByteAddress, uint32_t EndByteAddress) |
Generate CRC of an application section. | |
void | SP_LoadFlashPage (const uint8_t *data) |
Load entire page from SRAM buffer into Flash page buffer. | |
void | SP_LoadFlashWord (uint16_t address, uint16_t data) |
Load one word into Flash page buffer. | |
void | SP_LockSPM (void) |
Lock SPM instruction. | |
uint8_t | SP_ReadByte (uint32_t address) |
Read a byte from flash. | |
uint8_t | SP_ReadCalibrationByte (uint8_t index) |
Read calibration byte at given index. | |
void | SP_ReadFlashPage (const uint8_t *data, uint32_t address) |
Read entire Flash page into SRAM buffer. | |
uint8_t | SP_ReadFuseByte (uint8_t index) |
Read fuse byte from given index. | |
uint8_t | SP_ReadLockBits (void) |
Read lock bits. | |
uint8_t | SP_ReadUserSignatureByte (uint16_t index) |
Read user signature at given index. | |
uint16_t | SP_ReadWord (uint32_t address) |
Read a word from flash. | |
void | SP_WaitForSPM (void) |
Wait for SPM to finish. | |
void | SP_WriteApplicationPage (uint32_t address) |
Write page buffer to application or application table section at byte address. | |
void | SP_WriteBootPage (uint32_t address) |
Write page buffer to boot section at byte address. | |
void | SP_WriteLockBits (uint8_t data) |
Write lock bits. | |
void | SP_WriteUserSignatureRow (void) |
Write user signature row. |
This file contains the function prototypes for the XMEGA Self-programming driver. If any SPM instructions are used, the linker file must define a segment named BOOT which must be located in the device boot section.
None of these functions clean up the NVM Command Register after use. It is therefore important to write NVMCMD_NO_OPERATION (0x00) to this register when you are finished using any of the functions in this driver.
For all functions, it is important that no interrupt handlers perform any NVM operations. The user must implement a scheme for mutually exclusive access to the NVM. However, the 4-cycle timeout will work fine, since writing to the Configuration Change Protection register (CCP) automatically disables interrupts for 4 instruction cycles.
Copyright (c) 2008, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file sp_driver.h.
#define APPTABLE_SECTION_START 0x01E000 |
Definition at line 77 of file sp_driver.h.
#define FLASH_PAGE_SIZE 512 |
Definition at line 68 of file sp_driver.h.
uint32_t SP_ApplicationCRC | ( | void | ) |
Generate CRC from application section.
24-bit | CRC value |
uint32_t SP_BootCRC | ( | void | ) |
Generate CRC from boot section.
24-bit | CRC value |
void SP_EraseApplicationPage | ( | uint32_t | address | ) |
Erase page at byte address in application or application table section.
This function erase one page given by the byte address.
address | Byte address for flash page. |
Referenced by main().
void SP_EraseApplicationSection | ( | void | ) |
Erase entire application section.
This function erases the entire application and application table section
void SP_EraseBootPage | ( | uint32_t | address | ) |
Erase page at byte address in boot section.
This function erase one page given by the byte address.
address | Byte address for flash page. |
void SP_EraseFlashBuffer | ( | void | ) |
Flush Flash page buffer.
This function flush the Flash page buffer.
void SP_EraseUserSignatureRow | ( | void | ) |
Erase user signature row.
This function erase the entire user signature row.
void SP_EraseWriteApplicationPage | ( | uint32_t | address | ) |
Erase and write page buffer to application or application table section at byte address.
This function does a combined erase and write to a flash page in the application or application table section.
address | Byte address for flash page. |
void SP_EraseWriteBootPage | ( | uint32_t | address | ) |
Erase and write page buffer to boot section at byte address.
This function does a combined erase and write to a flash page in the boot section.
address | Byte address for flash page. |
uint32_t SP_FlashRangeCRC | ( | uint32_t | StartByteAddress, | |
uint32_t | EndByteAddress | |||
) |
Generate CRC of an application section.
StartByteAddress | - Start byte address | |
EndByteAddress | - End byte address |
24-bit | CRC value |
void SP_LoadFlashPage | ( | const uint8_t * | data | ) |
Load entire page from SRAM buffer into Flash page buffer.
This function load an entire page from SRAM.
data | Pointer to the data to put in buffer. |
void SP_LoadFlashWord | ( | uint16_t | address, | |
uint16_t | data | |||
) |
Load one word into Flash page buffer.
This function Loads one word into the Flash page buffer.
address | Position in inside the flash page buffer. | |
data | Value to be put into the buffer. |
Referenced by BlockLoad(), and main().
void SP_LockSPM | ( | void | ) |
Lock SPM instruction.
This function locks the SPM instruction, and will disable the use of SPM until the next reset occurs.
Referenced by main().
uint8_t SP_ReadByte | ( | uint32_t | address | ) |
Read a byte from flash.
This function reads one byte from the flash.
address | Address to the location of the byte to read. |
Byte | read from flash. |
Referenced by BlockRead(), and main().
uint8_t SP_ReadCalibrationByte | ( | uint8_t | index | ) |
Read calibration byte at given index.
This function reads one calibration byte from the Calibration signature row.
index | Index of the byte in the calibration signature row. |
Calibration | byte |
void SP_ReadFlashPage | ( | const uint8_t * | data, | |
uint32_t | address | |||
) |
Read entire Flash page into SRAM buffer.
This function reads an entire flash page and puts it to SRAM.
data | Pointer to where to store the data. | |
address | Address to page to read from flash. |
uint8_t SP_ReadFuseByte | ( | uint8_t | index | ) |
Read fuse byte from given index.
This function reads the fuse byte at the given index.
index | Index of the fuse byte. |
Fuse | byte |
Referenced by main().
uint8_t SP_ReadLockBits | ( | void | ) |
uint8_t SP_ReadUserSignatureByte | ( | uint16_t | index | ) |
Read user signature at given index.
This function reads one byte from the user signature row.
index | Index of the byte in the user signature row. |
User | signature byte |
uint16_t SP_ReadWord | ( | uint32_t | address | ) |
Read a word from flash.
This function reads one word from the flash.
address | Address to the location of the word to read. |
word | read from flash. |
void SP_WaitForSPM | ( | void | ) |
Wait for SPM to finish.
This routine waits for the SPM to finish and clears the command register.
Referenced by BlockLoad(), and main().
void SP_WriteApplicationPage | ( | uint32_t | address | ) |
Write page buffer to application or application table section at byte address.
This function writes the Flash page buffer to a page in the application or application table section given by the byte address.
address | Byte address for flash page. |
Referenced by BlockLoad(), and main().
void SP_WriteBootPage | ( | uint32_t | address | ) |
Write page buffer to boot section at byte address.
This function writes the Flash page buffer to a page in the boot section given by the byte address.
address | Byte address for flash page. |
void SP_WriteLockBits | ( | uint8_t | data | ) |
Write lock bits.
This function changes the lock bits.
data | The new value of the lock bits. |
Referenced by main().
void SP_WriteUserSignatureRow | ( | void | ) |
Write user signature row.
This function write the flash buffer in the user signature row.
Generated on Fri Mar 27 14:05:26 2009 for AVR1605: XMEGA BOOTLOADER by ![]() |