📄 main.asm
字号:
//////////////////////////////////////////////////////////////////////////////////////
//NAME: main.asm (ATMEL SPI Flash)
//DATE: 7/29/05
//PURPOSE: Program the SPI Flash for the ADSP-21369 Ezkit
//
//USAGE: Use this file to call the chip functions contained in SPIflash.asm.
//
////////////////////////////////////////////////////////////////////////////////////////
#include "SPIflash.h"
.global _main;
.extern flash_curr_page;
.extern sector_base_addr;
.extern read_base_addr;
.extern read_buffer_addr;
.extern read_buffer_length;
.extern write_buffer_addr;
.extern write_base_addr;
.extern write_buffer_length;
.extern file_data;
.extern file_data_verf;
.extern flash_data_out;
.extern flash_data_verf;
.extern spi_setting;
.extern spi_dma_setting;
.extern status_register;
.extern electronic_signature;
.extern curr_command;
.extern verf_errors;
.extern write_enable;
.extern write_disable;
.extern read_status_register;
.extern write_status_register;
.extern read_data_bytes;
.extern page_program;
.extern flash_program;
.extern sector_erase;
.extern chip_erase;
.extern read_device_id;
.extern setup_spi;
.extern setup_spi_dma;
.extern wait_for_SPIF;
.extern wait_for_WIP;
.extern bit_reverse_command;
.extern _initSRU;
.section/pm seg_pmco;
_main:
call _initSRU;
r15=0; r11=0;
//----------------------------------------
//Choose FLASH algorithms to run here.
//Reset the state of the device with a dummy read
call read_status_register;
//Check to make sure that the correct flash is being used
call read_device_id;
r0=dm(electronic_signature+1);
r1=0x1F; //For Atmel, manufacturer ID is hex 1F
comp(r0,r1);
if EQ jump (pc,2);
jump error_detected;
call read_status_register;
//Chip erase
//Either use chip_erase for the entire device
//or use sector_erase to erase sectors individually
//This example uses chip erase.
call chip_erase;
//r0=0; //Any address in sector to be erased.
//dm(sector_base_addr)=r0;
//call sector_erase;
//Write to FLASH
//The flash_program subroutine requires the user to pass:
//write_base_addr - the base address to write to in the SPI Flash
//write_buffer_addr - the address of buffer holding the data to program
//write_buffer_length - the length of the buffer to program in 32-bit words
//This routine also returns a number of errors encountered in the programming process.
//This is stored in the verf_errors with units in 32-bit words.
r0=0; //Address to write to in the flash
dm(write_base_addr)=r0;
r0=file_data; //Address of the buffer to write from the DSP
dm(write_buffer_addr)=r0;
r0=@file_data; //Length of the buffer to write from the DSP
dm(write_buffer_length)=r0;
call flash_program;
//Read from FLASH
//The read_data_bytes subroutine requires the user to pass:
//read_base_addr - the base address to write to in the SPI Flash
//read_buffer_addr - the address of buffer holding the data to program
//read_buffer_length - the length of the buffer to program in 32-bit words
r0=0; //Address to read from in the flash
dm(read_base_addr)=r0;
r0=file_data_verf; //Address of the buffer to read from in the DSP
dm(read_buffer_addr)=r0;
r0=@file_data_verf; //Length of the buffer to read from in DSP
dm(read_buffer_length)=r0;
call read_data_bytes;
//----------------------------------------
//Use FLAGS to show that the process completed.
//Indicate whether the process was error-free
r0=dm(verf_errors);
r0=pass r0;
if ne jump error_detected;
BIT SET FLAGS 0xAAAAAAAA;
BIT SET FLAGS 0x55555555;
_main.end: jump(pc,0);
error_detected:
BIT SET FLAGS 0xAAAAAAAA;
BIT CLR FLAGS 0x55555555;
error_detected.end: nop;
jump(pc,0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -