?? ppfunctions.c
字號:
///////////////////////////////////////////////////////////////////////////////////////
//NAME: ppfunctions.c (AMD Parallel Flash Programmer)
//DATE: 9/18/03
//PURPOSE: Program the Parallel Flash for the ADSP-21262 Ezkit
//
//USAGE: This file contains the subroutines used to access external devices the
// via the parallel port.
//
////////////////////////////////////////////////////////////////////////////////////////
#include "ppflash.h"
//----------------------------------------
//WRITE TO PARALLEL PORT SUBROUTINE
//Writes the specified amount of words to the parallel port
//Inputs - word_out - address of the buffer holding the 32-bit words to write (pointer)
// flash_address - address to write to in external memory (pointer)
// count32 - number of 32-bit words to write.
//Returns- none
//This example writes to only one byte at a time. When sending the flash commands, the
//only one address is required, so the external modify is set to 0.
void writeToPP(int *word_out, int *flash_address, int count32)
{
//Set up the parallel port for 8-bit writes to external memory
*pPPCTL = PPTRAN|PPBHC|PPDUR20;
//Internal DMA address is passed
*pIIPP = (int) word_out;
//Internal Modify is always 1
*pIMPP = 1;
//Internal count is passed
*pICPP = count32;
//External DMA Address is passed
*pEIPP = (int) flash_address;
//External Modify is always 0
*pEMPP = 0;
//External count is always 4x internal count (PP only transfers 32-bit words)
*pECPP = (count32 * 4);
//Enable the PP for transfer
*pPPCTL |= PPDEN|PPEN;
//Wait for the interrupt semaphore to get set
while(!ppInterruptFlag){};
//Clear the interrupt semaphore and disable the PP
ppInterruptFlag=0;
*pPPCTL=0;
}
//----------------------------------------
//READ FROM PARALLEL PORT SUBROUTINE
//Reads the specified amount of words from the parallel port
//Inputs - flash_address - external byte address to read from (pointer)
//Returns- dataIn - 32-bit word with four copies of the requested byte
// Not masked to 1 byte for use with flash polling during programming
// (the PP always reads 4 bytes and it is necessary to view 2 consecutive byte
// for reading the status of the Flash)
//It is necessary to mask the returned word down to 1 byte (the lowest).
int readFromPP(int *flash_address)
{
//buffer to hold the incoming data
int dataIn;
//Set up the parallel port for 8-bit reads from external memory
*pPPCTL = PPBHC|PPDUR20;
//Internal address is that of the buffer dataIn
*pIIPP = (int) &dataIn;
//Internal modify is 0, do not corrupt any other internal memory accidentally
*pIMPP = 0;
//Only read 1 word at a time
*pICPP = 1;
//External address is passed
*pEIPP = (int) flash_address;
//External count is zero, only reading one byte at a time
*pEMPP = 0;
//External count is always 4x internal count (PP only transfers 32-bit words)
*pECPP = 4;
//Enable the PP for transfer
*pPPCTL |= PPDEN|PPEN;
//Wait for the interrupt semaphore to get set
while(!ppInterruptFlag){};
//Clear the interrupt semaphore and disable the PP
ppInterruptFlag=0;
*pPPCTL=0;
return dataIn;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -