本帖最后由 young_xyj 于 2009-10-24 15:58 编辑
我有一份bootloader代码,其定义的:
// bootloader enable pin definition
#define BL_ENABLE_PORT GPIOD
#define BL_ENABLE_PIN GPIO_PIN_2
我想问下所有的STM8S是否都是用这个管脚来判定是否导向升级?
说明我使用的是STM8S105C6是否也是用这个脚?
附上:
// detect if bootloader is enabled
// enable pull-up on detect pin
GPIO_Init(BL_ENABLE_PORT, BL_ENABLE_PIN, GPIO_MODE_IN_PU_NO_IT);
// detect if pin is in high state - jumper not present = inactive bootloader
if(GPIO_ReadInputData(BL_ENABLE_PORT) & GPIO_PIN_2)
{
//if user application is not virgin - valid reset vector jump
if((*((@far u8*)MainUserApplication)==0x82) || (*((@far u8*)MainUserApplication)==0xAC))
{
GPIO_DeInit(BL_ENABLE_PORT); //de-init pull-up
//reset stack pointer (lower byte - because compiler decreases SP with some bytes)
_asm("LDW X, SP ");
_asm("LD A, $FF");
_asm("LD XL, A ");
_asm("LDW SP, X ");
// then jump to user application
_asm("JPF [_MainUserApplication]");
//MainUserApplication();
}
} |