104 lines
3.5 KiB
C
104 lines
3.5 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _VC_UPGRADE_H_
|
|
#define _VC_UPGRADE_H_
|
|
|
|
#include "os_types_api.h"
|
|
|
|
/* define uart baudrate for STM32 upgrade */
|
|
#define VC_UPGRD_UART_BAUDRATE 460800
|
|
|
|
/* define stm32 start-up model */
|
|
typedef enum _vc_upgrade_reset_flag_e_ {
|
|
/* start from ROM after reset, then update the user program */
|
|
VC_UPGRD_RESET_TO_DOWNLOAD,
|
|
/* start from flash after reset, then start the user program */
|
|
VC_UPGRD_RESET_TO_POWERUP,
|
|
/* invalid value */
|
|
VC_UPGRD_RESET_MAX,
|
|
} vc_upgrade_reset_flag;
|
|
|
|
/**
|
|
* @brief vc_upgrd_send_func - Function pointer to send upgrading data to stm32.
|
|
* @param p_buf: Pointer of a buffer holding sending data.
|
|
* @param len: Length of buffer.
|
|
* @return ERR_FAIL -- Operation failed.
|
|
* @return ERR_OK -- Operation Successful.
|
|
*/
|
|
typedef uint32_t (*vc_upgrd_send_func)(uint8_t *p_buf, uint32_t len);
|
|
|
|
/**
|
|
* @brief vc_upgrd_receive_func - receiving function registered to VC
|
|
* @param p_buf: Pointer of a buffer received data.
|
|
* @param len: Length of buffer.
|
|
* @return ERR_FAIL -- Operation failed.
|
|
* @return ERR_OK -- Operation Successful.
|
|
*/
|
|
uint32_t vc_upgrd_receive_func(uint8_t *p_buf, uint32_t len);
|
|
|
|
/**
|
|
* @brief vc_upgrade_module_init - init resources required in upgrade process.
|
|
* @return ERR_OK -- init Successful.
|
|
* @return other -- see iot_errno_api.h.
|
|
*/
|
|
uint32_t vc_upgrade_module_init(void);
|
|
|
|
/**
|
|
* @brief vc_upgrade_modele_deinit - release resources used in the upgrade.
|
|
*/
|
|
void vc_upgrade_modele_deinit(void);
|
|
|
|
/**
|
|
* @brief vc_upgrd_ext_chip_reset - reset the external chip
|
|
* and enter the specified mode.
|
|
* @param flag: the specified mode, see vc_upgrade_reset_flag.
|
|
* @return ERR_OK -- Upgrade Successful.
|
|
* @return other -- see iot_errno_api.h.
|
|
*/
|
|
uint32_t vc_upgrd_ext_chip_reset(uint8_t flag);
|
|
|
|
/**
|
|
* @brief vc_upgrd_start - Start upgrading slaver. Before calling this API,
|
|
* the slaver must be a state of waiting for upgrading.
|
|
* @param p_func: Pointer of a function to send upgrading data to stm32.
|
|
* @return ERR_FAIL -- Upgrade failed.
|
|
* @return ERR_OK -- Upgrade Successful.
|
|
*/
|
|
uint32_t vc_upgrd_set_start(vc_upgrd_send_func p_func);
|
|
|
|
/**
|
|
* @brief vc_upgrd_stop - Stop the current upgrading of stm32.
|
|
* @return ERR_FAIL -- Stop failed.
|
|
* @return ERR_OK -- Stop Successful.
|
|
*/
|
|
uint32_t vc_upgrd_set_stop(void);
|
|
|
|
/**
|
|
* @brief vc_upgrd_get_state - Get the state of upgrade module.
|
|
* @return State.
|
|
*/
|
|
vc_upgrd_state_e vc_upgrd_get_state(void);
|
|
|
|
/**
|
|
* @brief vc_upgrd_get_percentage - Get the percentage of sending firmware.
|
|
* @return Percentage. e.g. 80 -> 80%.
|
|
*/
|
|
uint32_t vc_upgrd_get_percentage(void);
|
|
|
|
uint32_t vc_upgrd_get_firmware_info(vc_fw_ver_t *p_fw);
|
|
|
|
#endif /* _VC_UPGRADE_H_ */
|