/******************************************************************************
*
* Filename: spi_flash.c
*
* Instantiation of SPI flash control routines supporting AT45DB161B
*
* Revision information:
*
* 17JAN2005 kb_admin initial creation
* adapted from external sources
* tested for basic operation only!!!
*
* BEGIN_KBDD_BLOCK
* No warranty, expressed or implied, is included with this software. It is
* provided "AS IS" and no warranty of any kind including statutory or aspects
* relating to merchantability or fitness for any purpose is provided. All
* intellectual property rights of others is maintained with the respective
* owners. This software is not copyrighted and is intended for reference
* only.
* END_BLOCK
*
* $FreeBSD$
*****************************************************************************/
#include "at91rm9200.h"
#include "spi_flash.h"
#include "lib.h"
/*
* .KB_C_FN_DEFINITION_START
* void SendCommand(spiCommand_t *pCommand)
* Private function sends 8-bit value to the device and returns the 8-bit
* value in response.
* .KB_C_FN_DEFINITION_END
*/
static void
{
// wait for completion
Delay(700);
}
/*
* .KB_C_FN_DEFINITION_START
* char GetFlashStatus(void)
* Private function to return device status.
* .KB_C_FN_DEFINITION_END
*/
static char
GetFlashStatus(void)
{
return (rx_commandBuffer[1]);
}
/*
* .KB_C_FN_DEFINITION_START
* void WaitForDeviceReady(void)
* Private function to poll until the device is ready for next operation.
* .KB_C_FN_DEFINITION_END
*/
static void
WaitForDeviceReady(void)
{
while (!(GetFlashStatus() & 0x80)) ;
}
/*************************** GLOBAL FUNCTIONS ********************************/
/*
* .KB_C_FN_DEFINITION_START
* void SPI_ReadFlash(unsigned flash_addr, unsigned dest_addr, unsigned size)
* Global function to read the SPI flash device using the continuous read
* array command.
* .KB_C_FN_DEFINITION_END
*/
void
{
// determine page address
// determine byte address
#ifdef BOOT_BWCT
tx_commandBuffer[0] = 0xd2;
#else
#endif
}
/*
* .KB_C_FN_DEFINITION_START
* void SPI_WriteFlash(unsigned flash_addr, unsigned src_addr, unsigned size)
* Global function to program the SPI flash device. Notice the warning
* provided in lower-level functions regarding corruption of data in non-
* page aligned write operations.
* .KB_C_FN_DEFINITION_END
*/
void
{
// determine page address
// determine byte address
#ifdef BOOT_BWCT
tx_commandBuffer[0] = 0x82;
#else
#endif
}
/*
* .KB_C_FN_DEFINITION_START
* void SPI_InitFlash(void)
* .KB_C_FN_DEFINITION_END
*/
void
SPI_InitFlash(void)
{
unsigned value;
// enable CS0, CLK, MOSI, MISO
// enable clocks to SPI
// reset the SPI
(0xE << 16);
#ifdef BOOT_BWCT
#else
if (value != 0xBC)
#endif
}