- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying the Bootloader and the Bootloadable programs of "USB HID Bootloader".
If the SW_2 is pushed, the Bootloader is executed and the Bootloadable application is programmed by using the Bootloader Host.
If it is not pushed, the Bootloadable application is executed directly.
Please see main.c of the Bootloader below. It can run well.
I wonder if this is correct. Please tell me if there is something that I should bring.
int main()
{
/* Indicates that the bootloader is running. */
PWM_Start();
PWM_TriggerCommand(PWM_MASK,PWM_CMD_START);
if(Pin_SW_Read()== 0){
/* Enters the bootloader to wait for the application update. */
Bootloader_SET_RUN_TYPE(Bootloader_START_BTLDR);
Bootloader_Start();
}
else{
Bootloader_SET_RUN_TYPE(Bootloader_START_APP);
Bootloader_Start();
}
/* Bootloader_Start() never returns. */
for (;;)
{
}
}
Best regards,
Yocchi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Yocchi-San,
Please make use of appended code and attached workspace.
#include <project.h>
#define Bootloader_activeApp (Bootloader_MD_BTLDB_ACTIVE_0)
int main()
{
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
CyGlobalIntEnable;
if(Pin_Read()==0)
{
/* Turn on blue LED */
Bootloader_Status_Blue_Write(0u);
CyDelay(500);
/* Start bootloader communication. This will wait for bootloading as configured by Wait for command*/
Bootloader_Start();
}
else
{
/* Turn on red LED */
Bootloader_Status_Green_Write(0u);
CyDelay(500);
/* Validate and schedule bootloadable. Perform software reset*/
if(CYRET_SUCCESS == Bootloader_ValidateBootloadable(Bootloader_activeApp))
{
Bootloader_SET_RUN_TYPE(Bootloader_SCHEDULE_BTLDB);
CySoftwareReset();
}
}
for(;;)
{
/* Place your application code here. */
}
}