Device Firmware Update (DFU) Middleware Library 5.1
Functions

General Description

API Reference

 Metadata Management
 DFU functions for operation over meta data.
 
 Application Management
 DFU Functions for 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.
/*
* Used to count seconds
*/
uint32_t count = 0;
/* Status codes for DFU API */
/*
* DFU state, one of the:
* - CY_DFU_STATE_NONE
* - CY_DFU_STATE_UPDATING
* - CY_DFU_STATE_FINISHED
* - CY_DFU_STATE_FAILED
*/
uint32_t state;
/* Timeout for Cy_DFU_Continue(), in milliseconds */
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 ];
/* DFU params, used to configure DFU */
/* Initialize dfuParams structure */
dfuParams.timeout = paramsTimeout;
dfuParams.dataBuffer = &buffer[0];
dfuParams.packetBuffer = &packet[0];
status = Cy_DFU_Init(&state, &dfuParams);
/* Stop program execution if DFU init failed */
CY_ASSERT(CY_DFU_SUCCESS == status);
/* Set up the device based on configurator selections */
init_cycfg_all();
/* enable interrupts */
__enable_irq();

◆ 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.

Note
Ensure the Crypto block is properly initialized if CY_DFU_OPT_CRYPTO_HW is set.
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.