EmSACAN_FirmwareUpdateBegin
Prototype
emsacan_result_t EmSACAN_FirmwareUpdateBegin(
emsacan_handle_t Handle,
emsacan_firmware_type_t FirmwareType,
const uint8_t *DownloadData,
uint32_t DownloadLength,
emsacan_fwupdate_callback_fn Callback,
void *UserContext );
Description
Starts the CAN Dragon firmware update sequence (non-secure application image).
Parameters
| Parameter | Direction | Type | Description |
|---|---|---|---|
Handle | in | emsacan_handle_t | Session handle from EmSACAN_Connect. |
FirmwareType | in | emsacan_firmware_type_t | Must be EMSACAN_FWTYPE_DEVICE for supported updates. |
DownloadData | in | const uint8_t | Image bytes; must remain valid until the callback reports a terminal phase (completed, failed, or cancelled). |
DownloadLength | in | uint32_t | Size of DownloadData in bytes. |
Callback | in | emsacan_fwupdate_callback_fn | Progress and phase notifications. |
UserContext | in | void | Opaque pointer passed to Callback. |
Return value
EMSACAN_OK if the worker started, or another emsacan_result_t code on failure.
Example
void __cdecl FwCb(void *ctx, emsacan_fwupdate_phase_t phase,
emsacan_result_t step, uint32_t done, uint32_t total)
{
if (phase == EMSACAN_FWUPDATE_PHASE_DOWNLOADING)
printf("Download %u / %u\n", done, total);
if (phase == EMSACAN_FWUPDATE_PHASE_COMPLETED ||
phase == EMSACAN_FWUPDATE_PHASE_FAILED)
{ /* terminal — image buffer may be freed */ }
}
/* image[] must stay valid until callback reports terminal phase */
emsacan_result_t rc = EmSACAN_FirmwareUpdateBegin(
handle, EMSACAN_FWTYPE_DEVICE, image, image_len, FwCb, NULL);
