www.ti.com
Bootloader Code Listing (V3.0)
inline void
I2C_Init(void);
inline Uint16 I2C_CheckKeyVal(void);
inline void
I2C_ReservedFn(void);
Uint16 I2C_GetWord(void);
// External functions
extern void
CopyData(void);
extern Uint32 GetLongData(void);
//#################################################
// Uint32 I2C_Boot(void)
//--------------------------------------------
// This module is the main I2C boot routine.
// It will load code via the I2C-A port.
//
// It will return an entry point address back
// to the ExitBoot routine.
//--------------------------------------------
Uint32 I2C_Boot(void)
{
Uint32 EntryAddr;
// Assign GetWordData to the I2C-A version of the
// function.
GetWordData is a pointer to a function.
GetWordData = I2C_GetWord;
// Init I2C pins, clock, and registers
I2C_Init();
// Check for 0x08AA data header, else go to flash
if (I2C_CheckKeyVal() == ERROR) { return FLASH_ENTRY_POINT; }
// Check for clock and prescaler speed changes and reserved words
I2C_ReservedFn();
// Get point of entry address after load
EntryAddr = GetLongData();
// Receive and copy one or more code sections to
destination addresses
CopyData();
return EntryAddr;
}
//#################################################
// void I2C_Init(void)
//----------------------------------------------
// Initialize the I2C-A port for communications
// with the host.
//----------------------------------------------
inline void I2C_Init(void)
{
// Configure I2C pins and turn on I2C clock
EALLOW;
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1;
// Configure as SDA pin
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1;
// Configure as SCL pin
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;
// Turn SDA pullup on
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;
// Turn SCL pullup on
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;
// Asynch
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;
// Asynch
SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;
// Turn I2C module clock on
EDIS;
SPRU722C – November 2004 – Revised October 2006
Bootloader Code Overview
79