www.ti.com
Bootloader Code Listing (V3.0)
Uint16 recvData;
// Send Read command/dummy word to EEPROM to fetch a byte
SpiaRegs.SPITXBUF = cmdData;
while( (SpiaRegs.SPISTS.bit.INT_FLAG) !=1);
// Clear SPIINT flag and capture received byte
recvData = SpiaRegs.SPIRXBUF;
return recvData;
}
//#################################################
// void SPIA_ReservedFn(void)
//-------------------------------------------------
// This function reads 8 reserved words in the header.
// The first word has parameters for LOSPCP
// and SPIBRR register 0xMSB:LSB, LSB = is a three
// bit field for LOSPCP change MSB = is a 6bit field
// for SPIBRR register update
//
// If either byte is the default value of the register
// then no speed change occurs.
The default values
// are LOSPCP = 0x02 and SPIBRR = 0x7F
// The remaining reserved words are read and discarded
// and then returns to the main routine.
//-------------------------------------------------
inline void SPIA_ReservedFn()
{
Uint16 speedData;
Uint16 I;
// update LOSPCP register
speedData = SPIA_Transmit((Uint16)0x0000);
EALLOW;
SysCtrlRegs.LOSPCP.all = speedData;
EDIS;
asm("
RPT #0x0F ||NOP");
// update SPIBRR register
speedData = SPIA_Transmit((Uint16)0x0000);
SpiaRegs.SPIBRR
= speedData;
asm("
RPT #0x0F ||NOP");
// Read and discard the next 7 reserved words.
for(I = 1; I <= 7; I++)
{
SPIA_GetWordData();
}
return;
}
//#################################################
// Uint16 SPIA_GetWordData(void)
//-----------------------------------------------
// This routine fetches two bytes from the SPI-A
// port and puts them together to form a single
// 16-bit value.
It is assumed that the host is
// sending the data in the form MSB:LSB.
//-----------------------------------------------
Uint16 SPIA_GetWordData()
{
Uint16 wordData;
// Fetch the LSB
wordData =
SPIA_Transmit(0x0000);
// Fetch the MSB
wordData |= (SPIA_Transmit(0x0000) << 8);
SPRU722C – November 2004 – Revised October 2006
Bootloader Code Overview
69