Device Firmware Update (DFU) Middleware Library 6.0
Functions

General Description

API Reference

 Application Management
 DFU functions for the application management.
 
 Memory Operations
 DFU functions for memory operations These IO functions have to be re-implemented in the user's code.
 
 Transport Management
 DFU functions for the communication interface.
 
 Custom commands
 The DFU protocol provides a set of pre-defined commands.
 

Functions

cy_en_dfu_status_t Cy_DFU_Init (uint32_t *state, cy_stc_dfu_params_t *params)
 This function starts the application download and install operations. More...
 
cy_en_dfu_status_t Cy_DFU_Continue (uint32_t *state, cy_stc_dfu_params_t *params)
 The function processes Host Commands according to Host Command/Response Protocol. More...
 
uint32_t Cy_DFU_DataChecksum (const uint8_t *address, uint32_t length, cy_stc_dfu_params_t *params)
 This function computes a CRC-32C for the provided number of bytes contained in the provided buffer. More...
 

Function Documentation

◆ Cy_DFU_Init()

cy_en_dfu_status_t Cy_DFU_Init ( uint32_t *  state,
cy_stc_dfu_params_t params 
)

This function starts the application download and install operations.

Make subsequent calls to Cy_DFU_Continue() to continue the process.
Returns immediately, reporting success or failure.
Only one updating operation can be done at a time - the user's code must ensure this.

Parameters
stateThe pointer to a state variable, that is updated by the function. See DFU State
paramsThe pointer to a DFU parameters structure See cy_stc_dfu_params_t
Returns
See cy_en_dfu_status_t.
static cy_stc_dfu_params_t dfuParams;
static cy_en_dfu_status_t dfuStatus;
/*
* DFU state, one of the:
* - CY_DFU_STATE_NONE
* - CY_DFU_STATE_UPDATING
* - CY_DFU_STATE_FINISHED
* - CY_DFU_STATE_FAILED
*/
static uint32_t state = CY_DFU_STATE_NONE;
/* Timeout for Cy_DFU_Continue(), in milliseconds */
static const uint32_t paramsTimeout = 20U;
/* Buffer to store DFU commands */
CY_ALIGN(4) static uint8_t buffer[CY_DFU_SIZEOF_DATA_BUFFER];
/* Buffer for DFU data packets for transport API */
CY_ALIGN(4) static uint8_t packet[CY_DFU_SIZEOF_CMD_BUFFER];
/* Initialize dfuParams structure */
dfuParams.timeout = paramsTimeout;
dfuParams.dataBuffer = &buffer[0];
dfuParams.packetBuffer = &packet[0];
dfuStatus = Cy_DFU_Init(&state, &dfuParams);
if (CY_DFU_SUCCESS != dfuStatus)
{
CY_DFU_LOG_ERR("DFU initialization is failed");
/* Stop program execution if DFU init failed */
CY_ASSERT(0U);
}

◆ Cy_DFU_Continue()

cy_en_dfu_status_t Cy_DFU_Continue ( uint32_t *  state,
cy_stc_dfu_params_t params 
)

The function processes Host Commands according to Host Command/Response Protocol.

The function waits for the Host data packet till timeout occurs. If valid packet is received, it decodes received command, processes it and transfer back a response if needed. See description of Host Command/Response Protocol in AN213924 DFU SDK User Guide.

Parameters
stateThe pointer to a state variable, that is updated by the function. See DFU State.
paramsThe pointer to a DFU parameters structure. See cy_stc_dfu_params_t.
Returns
See cy_en_dfu_status_t

◆ Cy_DFU_DataChecksum()

uint32_t Cy_DFU_DataChecksum ( const uint8_t *  address,
uint32_t  length,
cy_stc_dfu_params_t params 
)

This function computes a CRC-32C for the provided number of bytes contained in the provided buffer.


This function is used to validate the Program Data and Verify Data DFU commands and a metadata row.

Parameters
addressThe pointer to a buffer containing the data to compute the checksum for.
lengthThe number of bytes in the buffer to compute the checksum for.
paramsThe pointer to a DFU parameters structure. See cy_stc_dfu_params_t .
Returns
CRC-32C for the provided data.