b.liu | 778645e | 2024-06-21 16:47:42 +0800 | [diff] [blame^] | 1 | #ifndef __HD8040_UPGRADE_H
|
| 2 | #define __HD8040_UPGRADE_H
|
| 3 |
|
| 4 | #include <stdio.h>
|
| 5 | #include <stdlib.h>
|
| 6 | #include <string.h>
|
| 7 | #include "custom_upgrade_api.h"
|
| 8 | #include "stdint.h"
|
| 9 |
|
| 10 | //cfg
|
| 11 | #define SWITCH_BAUD_460800 1
|
| 12 | #define UPG_CHECK_VER 1
|
| 13 |
|
| 14 | typedef int sys_err_t;
|
| 15 |
|
| 16 | #define sys_TRUE (1)
|
| 17 | #define sys_FALSE (0)
|
| 18 |
|
| 19 | #define sys_SUCCESS (0)
|
| 20 | #define sys_FAILED (-1)
|
| 21 |
|
| 22 |
|
| 23 | typedef unsigned char uint8_t;
|
| 24 | typedef unsigned short int uint16_t;
|
| 25 |
|
| 26 | #define HDBD_LOG printf
|
| 27 |
|
| 28 |
|
| 29 | /*
|
| 30 | HDBD_UPG_SUCESS£ºÉý¼¶³É¹¦
|
| 31 | HDBD_UPG_ENTER_BOOTMODE_ERROR£º½øÈëbootʧ°Ü£¨¶ÁÈ¡²»µ½°æ±¾ºÅ»òÕß´®¿Ú·¢ËÍʱÐò²»ÕýÈ·£©
|
| 32 | HDBD_UPG_FAIL£ºÉý¼¶Ê§°Ü
|
| 33 | HDBD_UPG_GETVER_ERROR£ºÉý¼¶Ö®ºó¶ÁÈ¡°æ±¾ºÅʧ°Ü
|
| 34 | HDBD_UPG_COM_CFG_ERROR£º´®¿ÚÅäÖôíÎó
|
| 35 | HDBD_UPG_IN_INFO_ERROR£ºÊäÈëµÄclientID´íÎó»òÕßÊäÈëµÄ°æ±¾²ÎÊý²»ÕýÈ·
|
| 36 | HDBD_BIN_FILE_ERROR£ºBinÎļþ´íÎó*/
|
| 37 | typedef enum {
|
| 38 | HDBD_UPG_SUCESS = 0,
|
| 39 | HDBD_UPG_ENTER_BOOTMODE_ERROR = 1,
|
| 40 | HDBD_UPG_FAIL = 2,
|
| 41 | HDBD_UPG_GETVER_ERROR = 3,
|
| 42 | HDBD_UPG_COM_CFG_ERROR = 4,
|
| 43 | HDBD_UPG_IN_INFO_ERROR = 5,
|
| 44 | HDBD_BIN_FILE_ERROR = 6,
|
| 45 | HDBD_UPG_CHECK_ERR = 7
|
| 46 | }HDBD_RET;
|
| 47 |
|
| 48 | #define COMM_BAUDRATE_PHONE 115200
|
| 49 |
|
| 50 |
|
| 51 | #define ADDR_FLASH_BIN_INFO_ADDR 0x0000000//
|
| 52 |
|
| 53 | /**
|
| 54 | * @brief upgrade entry
|
| 55 | * @param fd:uart fd
|
| 56 | * @param uart_baud_max:uart max baud
|
| 57 | * @param binSize:upgrade file bin size
|
| 58 | * @param upgrade_clientID:need upgrade clientID
|
| 59 | * @param new_ver:upgrade success version
|
| 60 | * @retval hd8040_upgrade.h ERROR_LIST
|
| 61 | */
|
| 62 |
|
| 63 | //#define PYTHON_CALL_BACK_SUPPORT 0
|
| 64 |
|
| 65 | #ifdef PYTHON_CALL_BACK_SUPPORT
|
| 66 | typedef struct python_callback_str
|
| 67 | {
|
| 68 | int (*gnss_gpio_init_callback)();
|
| 69 | int (*gnss_enter_boot_callback)();
|
| 70 | int (*gnss_reset_callback)();
|
| 71 | int (*set_gnss_baud_callback)(int32_t, uint8_t);
|
| 72 | int (*uart_send_callback)(int32_t, uint8_t *, int32_t);
|
| 73 | int (*uart_recv_callback)(int32_t, uint8_t *, int32_t *, int32_t);
|
| 74 | int (*bsp_flash_readbytes_callback)(uint32_t, uint8_t *, uint32_t);
|
| 75 | int (*uart_clear_buf_callback)(int32_t);
|
| 76 | int (*uart_control_callback)(int32_t, uint16_t);
|
| 77 | }PYTHON_CALLBACK;
|
| 78 |
|
| 79 | typedef int (callback)(uint8_t *, uint16_t);
|
| 80 | typedef int (*gnss_gpio_init_callback_)();
|
| 81 | typedef int (*gnss_enter_boot_callback_)();
|
| 82 | typedef int (*gnss_reset_callback_)();
|
| 83 | typedef int (*set_gnss_baud_callback_)(int32_t, uint8_t);
|
| 84 | typedef int (*uart_send_callback_)(int32_t, uint8_t *, int32_t);
|
| 85 | typedef int (*uart_recv_callback_)(int32_t, uint8_t *, int32_t *, int32_t);
|
| 86 | typedef int (*bsp_flash_readbytes_callback_)(uint32_t, uint8_t *, uint32_t);
|
| 87 | typedef int (*uart_clear_buf_callback_)(int32_t);
|
| 88 | typedef int (*uart_control_callback_)(int32_t, uint16_t);
|
| 89 |
|
| 90 | extern PYTHON_CALLBACK g_python_callback;
|
| 91 | extern HDBD_RET hdbd_upgrade_entry(int32_t fd, int32_t uart_baud_max, int32_t binSize, uint8_t *upgrade_clientID, uint8_t *new_ver,
|
| 92 | gnss_gpio_init_callback_ gnss_gpio_init_callback__,
|
| 93 | gnss_enter_boot_callback_ gnss_enter_boot_callback__,
|
| 94 | gnss_reset_callback_ gnss_reset_callback__,
|
| 95 | set_gnss_baud_callback_ set_gnss_baud_callback__,
|
| 96 | uart_send_callback_ uart_send_callback__,
|
| 97 | uart_recv_callback_ uart_recv_callback__,
|
| 98 | bsp_flash_readbytes_callback_ bsp_flash_readbytes_callback__,
|
| 99 | uart_clear_buf_callback_ uart_clear_buf_callback__,
|
| 100 | uart_control_callback_ uart_control_callback__
|
| 101 | );
|
| 102 | #else
|
| 103 | extern HDBD_RET hdbd_upgrade_entry(int32_t fd, int32_t uart_baud_max, int32_t binSize, uint8_t *upgrade_clientID, uint8_t *new_ver);
|
| 104 | #endif
|
| 105 |
|
| 106 | extern HDBD_RET hdbd_enter_boot(int32_t fd, int32_t uart_baud_max, int binSize, uint8_t *upgrade_clientID, uint8_t *new_ver);
|
| 107 |
|
| 108 |
|
| 109 | #endif
|
| 110 |
|