今天发现之前的之前工程师遗留的问题,他在usb中断的时候调用了写flash,这样会容易出错是吗?正常情况下,中断函数是不运行操作flash的。因为写flash会进入安全模式,安全模式一般会关闭总中断。想和原厂确认一下,是否usb中断不能操作flash。谢谢
case UIS_TOKEN_OUT | 4:
if( U_TOG_OK )
{
len = USB_RX_LEN;
UEP0_CTRL ^= bUEP_R_TOG;/* ·?×? */
UEP0_CTRL = UEP0_CTRL & ~ MASK_UEP_R_RES | UEP_R_RES_NAK;
//state = 1;
//if(Ep0Buffer[64] == 0x05 && Ep0Buffer[65] == 0x01 && Ep0Buffer[66] == 0x01 && Ep0Buffer[67] == 0x00 && Ep0Buffer[68] == 0x08 && Ep0Buffer[69] == 0x05){
//state = 2;
//}else{
//state = 1;
//}
//if(Ep0Buffer[65] == 0x01){
//state = 2;
//}
if(Ep0Buffer[65] == 0x01){
memset(HIDData1,0,sizeof(HIDData1));//°?HIDData1??0
memcpy(HIDData1, &Ep0Buffer[66], Ep0Buffer[64] - 1);
WriteDataFlash(0, &HIDData1, sizeof(HIDData1));
}