Description
u16_get_can_baudrate()
returns the bootloader setting of the MCAN0 baud rate.
Syntax
u16_get_can_baudrate();
Parameters
none
Returns
uint16_t – baud rate that the bootloader uses for the first CAN bus (MCAN0) in [kBaud].
e.g.: 125 means 125 kBaud.
Example Code
This example shows how to read, set and store the ‘baud rate’ of the bootloader settings.
void setup()
{
Serial.begin();
while (!Serial)
{
yield(); // wait for PC CAN2SER-monitor to open
}
uint16_t u16_baudrate = BOOTLOADER_SETTING.u16_get_can_baudrate();
String s_device_name = BOOTLOADER_SETTING.s_get_device_name();
Serial.println("Bootloader settings:");
Serial.println(" - baudrate: "+ String(u16_baudrate) + " kBaud");
Serial.println(" - device name: " + s_device_name);
delay(2000);
Serial.println("Modify the settings");
BOOTLOADER_SETTING.u8_set_can_baudrate(125); // 125/250/500 or 1000
BOOTLOADER_SETTING.u8_set_device_name("myDICE"); // 6 chars
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
This method returns the RAM copy value of the bootloader settings which are copied into the BOOTLOADER_SETTING object during its instantiation at system start (variant.cpp).
See also
u8_store_bootloader_settings()
u8_set_can_baudrate()
SAMC21_CAN