元旦放假的时候,终于抽空完成了STM8的SWIM接口支持,并且可以支持SWIM的高速模式。
硬件上,RC版本也基本结束,已经到正式版本的阶段。
SWIM的实现方式很简单,底层Versaloon只是实现SWIM_IN和SWIM_OUT操作,在上位机实现其他所有的操作,这样可以做到硬件设备最简化。贴一小段上位机的SWM命令处理的源代码:
SWIM接口的SRST命令处理:
static RESULT stm8_swim_srst(void)
{
return swim_out(STM8_SWIM_CMD_SRST, STM8_SWIM_CMD_BITLEN);
}
SWIM接口的ROTF命令处理:
static RESULT stm8_swim_rotf(uint32_t addr, uint8_t *buff, uint8_t bytelen)
{
swim_out(STM8_SWIM_CMD_ROTF, STM8_SWIM_CMD_BITLEN);
swim_out(bytelen, 8);
swim_out((addr >> 16) & 0xFF, 8);
swim_out((addr >> 8) & 0xFF, 8);
swim_out((addr >> 0) & 0xFF, 8);
swim_in(buff, bytelen);
return ERROR_OK;
}
SWIM接口的WOTF命令处理:
static RESULT stm8_swim_wotf(uint32_t addr, uint8_t *buff, uint8_t bytelen)
{
uint8_t i;
swim_out(STM8_SWIM_CMD_WOTF, STM8_SWIM_CMD_BITLEN);
swim_out(bytelen, 8);
swim_out((addr >> 16) & 0xFF, 8);
swim_out((addr >> 8) & 0xFF, 8);
swim_out((addr >> 0) & 0xFF, 8);
for (i = 0; i < bytelen; i++)
{
swim_out(buff, 8);
}
return ERROR_OK;
}
还对vsprog和vsgui做了很多的优化,现在代码构架上更加完整了,每种芯片的操作代码更加简单,vsgui不用因为新增加芯片的支持而做任何修改了。
文章评论(0条评论)
登录后参与讨论