WE310F5  39.00.000

This section describes the M2MB APIs related to XFP module. More...

#define XFP_OPERATION_IN_PROGRESS   0
 
#define XFP_OPERATION_BOOTCHARS_DETECTED   1
 
#define XFP_OPERATION_DONE   2
 
#define XFP_OPERATION_FAILED   3
 
typedef M2MB_OS_RESULT_E(* xfp_io_write) (UINT8 *p, UINT32 length)
 IO write callback for XFP. More...
 
typedef VOID(* fwup_xfp_user_cb) (UINT32 response_code)
 This function prototype is Firmware Upgrade callback for XFP user. More...
 
INT32 m2mb_xfp_open (xfp_io_write io_write_cb, M2MB_FWUP_USER_CB_T user_cb, void *user_cb_ctx)
 m2mb_xfp_init is called to initialize XFP module. More...
 
INT32 m2mb_xfp_io_read (uint8_t *buff, uint32_t size)
 m2mb_xfp_io_read reads the XFP data sent by the XFP tool. More...
 

Detailed Description

This section describes the M2MB APIs related to XFP module.

WE310F5_Debug.png
Debug

XFP is the protocol to be followed to upgrade firmware of the device through UART.

Macro Definition Documentation

◆ XFP_OPERATION_BOOTCHARS_DETECTED

#define XFP_OPERATION_BOOTCHARS_DETECTED   1

Definition at line 55 of file m2mb_xfp.h.

◆ XFP_OPERATION_DONE

#define XFP_OPERATION_DONE   2

Definition at line 56 of file m2mb_xfp.h.

◆ XFP_OPERATION_FAILED

#define XFP_OPERATION_FAILED   3

Definition at line 57 of file m2mb_xfp.h.

◆ XFP_OPERATION_IN_PROGRESS

#define XFP_OPERATION_IN_PROGRESS   0

Definition at line 54 of file m2mb_xfp.h.

Typedef Documentation

◆ fwup_xfp_user_cb

typedef VOID(* fwup_xfp_user_cb) (UINT32 response_code)

This function prototype is Firmware Upgrade callback for XFP user.

Firmware Upgrade callback for XFP user. This callback will be called on either success or failure of FWUP operation. response_code is of type 'M2MB_FWUP_STATUS_CODE_T'

Example

static VOID m2mb_fwup_xfp_cb( UINT32 response_code )
{
if( response_code == 0)
{
m2mb_dbg_consol_print("\r\nXFP Successful");
}
}
M2MB_OS_RESULT_E m2mb_xfp_write(UINT8 *data, UINT32 len)
{
int ret = m2mb_uart_write( xfp_uart_handle, data, len, NULL);
if( ret == M2MB_ERROR )
return M2MB_ERROR;
}
int main()
{
INT32 status = 0;
status = m2mb_xfp_init(m2mb_xfp_write, m2mb_fwup_xfp_cb);
...
}

Definition at line 137 of file m2mb_xfp.h.

◆ xfp_io_write

typedef M2MB_OS_RESULT_E(* xfp_io_write) (UINT8 *p, UINT32 length)

IO write callback for XFP.

IO write callback for XFP. This is to send ACK Xfp tool on receiving 512B chunk through UART. p is pointer to ACK and length is the size of ACK. User has to write this ACK sent by XFP to UART port used by XFP, so that tool will send the next chunk.

Parameters
[in]pIt is pointer to ACK.
[in]lengthIt is the size of ACK.

Example

static VOID m2mb_fwup_xfp_cb( UINT32 response_code )
{
if( response_code == 0)
{
m2mb_dbg_consol_print("\r\nXFP Successful");
}
}
M2MB_OS_RESULT_E m2mb_xfp_write(UINT8 *data, UINT32 len)
{
int ret = m2mb_uart_write( xfp_uart_handle, data, len, NULL);
if( ret == M2MB_ERROR )
return M2MB_ERROR;
}
int main()
{
INT32 status = 0;
status = m2mb_xfp_init(m2mb_xfp_write, m2mb_fwup_xfp_cb);
...
}

Definition at line 101 of file m2mb_xfp.h.

Function Documentation

◆ m2mb_xfp_io_read()

INT32 m2mb_xfp_io_read ( uint8_t *  buff,
uint32_t  size 
)

m2mb_xfp_io_read reads the XFP data sent by the XFP tool.

m2mb_xfp_io_read reads the XFP data sent by the XFP tool and sends it to firmware upgrade.

Returns
returns status.
Note
This API has to be called if the XFP is already initialized. Example
int main()
{
INT32 status = 0;
uint8_t *buff;
uint32_t size;
// Read the uart port and get pointer to data in buff and its length in size
status = m2mb_xfp_io_read(buff, size);
}

◆ m2mb_xfp_open()

INT32 m2mb_xfp_open ( xfp_io_write  io_write_cb,
M2MB_FWUP_USER_CB_T  user_cb,
void *  user_cb_ctx 
)

m2mb_xfp_init is called to initialize XFP module.

m2mb_xfp_init initializes the XFP module and registers the callbacks of type xfp_io_write and fwup_xfp_user_cb.

Parameters
[in]io_write_cbcallback set by user of type xfp_io_write. IO write callback for XFP.
[in]user_cbPointer to a Firmware Upgrade callback function of type for fwup_xfp_user_cb.
Note
This API has to be called if the XFP is already initialized. Example
static VOID m2mb_fwup_xfp_cb( UINT32 response_code )
{
if( response_code == 0)
{
m2mb_dbg_consol_print("\r\nXFP Successful");
}
}
M2MB_OS_RESULT_E m2mb_xfp_write(UINT8 *data, UINT32 len)
{
int ret = m2mb_uart_write( xfp_uart_handle, data, len, NULL);
if( ret == M2MB_ERROR )
return M2MB_ERROR;
}
int main()
{
INT32 status = 0;
status = m2mb_xfp_open(m2mb_xfp_write, m2mb_fwup_xfp_cb);
...
}
Returns
returns status.