我使用的开发板是CYUSB3KIT-003。开发板在StreamerExample模式下正常启动后,PC端通过EP0端口给开发板发送一个字节,开发板响应代码如下所示:
if(itype == 64 && itarget == 2 && ireq_type==66 && irequest == 11)
{
CyU3PDebugPrint(6, "switch to bootloader\r\n");
CyU3PUsbAckSetup ();
CyU3PThreadSleep (10);
app_stop();
CyU3PDebugDeInit ();
CyU3PUartDeInit ();
//CyU3PConnectState(CyFalse, CyFalse);
CyU3PUsbSetBooterSwitch (CyTrue);
CyU3PUsbJumpBackToBooter (0x40078000);
//CyU3PDeviceReset(CyTrue);
while (1)
CyU3PThreadSleep (100);
bis_handled = CyTrue;
}
我希望它切换到bootloader模式,结果设备不见了,如下图所示:
怎样用代码从StreamerExample模式切换到bootloader模式呢?如下图所示:
已解决! 转到解答。
Please set the PMODE pins to Z11 (USB Boot) which is equivalent to populating the jumper J4 on the explorer kit. After this, call the API CyU3PDeviceReset (CyFalse); as part of handling the command received from EP0.
请将PMODE引脚设置为Z11(USB boot),这相当于在explorer套件上接跳线J4。然后,调用API CyU3PDeviceReset(CyFalse);作为处理从EP0接收的命令的一部分。
对不起,我不知道这个地方用代码怎么写,请再给一点提示。
我已经查找这个提问:Solved: About PMODE pin condition - Infineon Developer Community,知道了Z的意思,但还不知道如何用代码实现。请问是设置GPIO引脚吗?
请问这个能不能用代码做得到?如果做不到,我就需要转变产品的实现思路。
Yes, you can control it using code.
The PMODE[2:0] lines are input pins that are used by the FX3 bootloader to decide the bootmode once the device comes out of reset. As you are using CYUSB3KIT-003, the J4 jumper can directly be used for setting the PMODE pins. If you are using a custom board, then you can drive the PMODE[2:0] lines externally using a controller or hardwire using pull-up or pull-down resistors. You can refer to the following thread to understand how the PMODE pins are interpreted by the device:
https://community.infineon.com/t5/USB-superspeed-peripherals/About-PMODE-pin-condition/m-p/91343#M72...
可以的。PMODE[2:0]线是输入引脚,FX3引导加载程序使用这些引脚来决定设备复位后的引导模式。当您使用CYUSB3KIT-003时,J4跳线可直接用于设置PMODE引脚。如果您使用的是定制板,那么您可以使用控制器或使用上拉或下拉电阻器的硬线从外部驱动PMODE[2:0]线。您可以参考以下帖子来了解设备如何解释PMODE引脚:
我猜你想实现的是在StreamerExample启动成功的条件下实现更新固件?你只需要在你的这段代码中加入修改EEPROM/Flash的语句,这样在下次重启时SPI boot/I2C boot就会失败,回退到USB boot,这样bootloader device就又出来了。一般实现在线更新的产品都是这么设计的。