Description
u8_set_listen_duration_ms()
allows you to configure time that the bootloader will wait and listen for bootloader protocol messages from the PC at start up. default value is 500.
Syntax
u8_set_listen_duration_ms( ou16_newlistenduration );
Parameters
uint16_t ou16_newlistenduration: the new listening time in milliseconds [ms]. Minimum time is 30 ms. default value is 500ms
Returns
uint8_t return value meaning:
0 – setting changed (accepted).
2 – the value ou16_newlistenduration is out of range (min. 30)
Example Code
This example shows how to read, set and store the ‘listen duration’ of the bootloader settings.
void setup()
{
Serial.begin();
while (!Serial)
{
yield(); // wait for PC CAN2SER-monitor to open
}
Serial.println("Current bootloader settings:");
Serial.print(" - listen duration: ");
Serial.println( String( BOOTLOADER_SETTING.u16_get_listen_duration_ms() ) + "ms");
delay(2000);
Serial.println("Modify the settings");
BOOTLOADER_SETTING.u8_set_listen_duration_ms(500);
delay(2000);
Serial.println("Store the settings in flash");
uint8_t u8_ret = BOOTLOADER_SETTING.u8_store_bootloader_settings();
if(u8_ret != 0)
Serial.println("Error writing into flash");
Serial.println("DONE");
}
void loop ()
{
}
Notes and Warnings
Don’t forget to call the function u8_store_bootloader_settings()
to write the changed settings into flash, so that the bootloader (and app.) has the new values at the next system start / reset.
It is recommended to leave the ‘listen duration’ at the default value (500). This gives the user and the tools time to connect to the device. For example the CAN2SER monitor that is automatically executed after the flash process (within the Arduino IDE) would get enough time to start.
See also
u8_store_bootloader_settings()
u16_get_listen_duration_ms()
SAMC21_CAN