|
发表于 2007-4-21 13:19:50
|
显示全部楼层
有1个建议,可以增加修改软件版本号主号及次号功能:
stk500protocol.h
#define eeprom_sckDuration ((uint8_t*)0x08)
#define eeprom_MAJOR_MINOR ((uint8_t*)0x09)
#define eeprom_stk500 ((uint8_t*)0x0A)
main.c
int main(void)
{
wdt_enable(WDTO_1S);
odDebugInit();
hardwareInit();
vregInit();
usbInit();
sckDuration=eeprom_read_byte((uint8_t *)eeprom_sckDuration);
if(sckDuration==0xFF)
{
sckDuration=2;
eeprom_write_byte((uint8_t *)eeprom_sckDuration,sckDuration);
}
if(0xFF==eeprom_read_byte((uint8_t *)eeprom_MAJOR_MINOR))
{
eeprom_write_byte((uint8_t *)eeprom_MAJOR_MINOR,0x2A);
}
sei();
stk500protocol.c
/*-----------studio 向 STK500 设置参数-------------- */
static void setParameter(unsigned char index, unsigned char value)
{
switch(index)
{
//利用调节参考电压,作为调节软件版本号主号及次号
case STK_PARAM_VADJUST: //(0x95)
//调节参考电压大于40(4V)软件版本号主号及次号加1
if(value > 39)
{
value=eeprom_read_byte((uint8_t *)eeprom_MAJOR_MINOR);
value++;
eeprom_write_byte((uint8_t *)eeprom_MAJOR_MINOR,value);
}
//调节参考电压小于10(1V)软件版本号主及号次减1
else if(value < 11)
{
value=eeprom_read_byte((uint8_t *)eeprom_MAJOR_MINOR);
value--;
eeprom_write_byte((uint8_t *)eeprom_MAJOR_MINOR,value);
}
break;
/*-----------studio 从 STK500 读取参数-------------- */
static unsigned char getParameter(unsigned char index)
{
unsigned char tmp;
switch(index)
{
case STK_PARAM_SW_MAJOR://(0x91) 软件版本号主
tmp=eeprom_read_byte((uint8_t *)eeprom_MAJOR_MINOR);
tmp >>=4;
break;
case STK_PARAM_SW_MINOR://(0x92) 软件版本号次
tmp=eeprom_read_byte((uint8_t *)eeprom_MAJOR_MINOR);
tmp &=0x0F
break;
-----此内容被andy于2007-04-21,13:23:06编辑过 |
|