Datasheet

I2C Bootloader
Document Number: 001-13258 Rev. *J Page 27 of 39
Here is an implementation of an BootLdrI2C User Module written in C:
//----------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all user modules
BYTE result;
WORD wAddr, wByteCount, cTemperature, wByteReadCount;
BYTE pbDataDest[10], pbData[10];
void main(void)
{
//example application consists of an EEPROM UM, an LED UM,
//and a 16-bit timer UM.
//the EEPROM demonstrates that the EEPROM UM can co-exist
//with the bootloader, the timer sets a duty cycle and the
//LED blinks at the set duty cycle.
//The bootloader UM provides the capability to modify
//the project (LED duty cycles are conveniently visible.)
//and use the bootloader to download the modified project.
//by the time the main() function is executed the project
//has already been checksummed and verified by the bootloader.
//init EEPROM data
wAddr = 0;
wByteCount = 64;
wByteReadCount = 10;
cTemperature = 25;
//start the bootloader running in the background
BootLdrI2C_1_Start();
BootLdrI2C_1_EnableSlave();
BootLdrI2C_1_EnableInt();
//start blinking the LED
Counter24_1_Start();
Counter24_1_EnableInt();
LED_1_Start();
M8C_EnableGInt;
#define INCLUDE_LIB_API
#ifdef INCLUDE_LIB_API
E2PROM_1_Start();
result = E2PROM_1_bE2Write( wAddr, pbData, wByteCount, cTemperature);
E2PROM_1_E2Read( wAddr, pbDataDest, wByteReadCount);
// Insert your main routine code here.
#endif
#define BUSMODE 0xf5
while(1)
{