123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #include "commontypedef.h"
- #include "bsp.h"
- #include "bsp_custom.h"
- #include "osasys.h"
- #include "ostask.h"
- #include "queue.h"
- #include "ps_event_callback.h"
- #include "cmisim.h"
- #include "cmimm.h"
- #include "cmips.h"
- #include "sockets.h"
- #include "psifevent.h"
- #include "ps_lib_api.h"
- #include "lwip/netdb.h"
- #include "debug_log.h"
- #include "slpman_ec616.h"
- #include "plat_config.h"
- #include "ec_tcpip_api.h"
- #include "hal_module_adapter.h"
- #include <stdlib.h>
- #include "numeric.h"
- #include "AppSignal.h"
- #include "hal_uart.h"
- #define PROC_UART_TASK_STACK_SIZE (2048)
- #define BMS_ADDRESS_CODE 0x01
- #define UART_READ_CODE 0x03
- #define UART_WRITE_CODE 0x10
- #define UART_ENCRYPT_CODE 0x05
- #define UART_WRITE_FLAG 0x01
- #define UART_READ_FLAG 0x00
- typedef enum
- {
- PROCESS_UART_STATE_INTI = 0,
- PROCESS_UART_STATE_ENCRYPT,
- PROCESS_UART_STATE_IDLE,
- PROCESS_UART_STATE_READ,
- PROCESS_UART_STATE_WRITE,
- PROCESS_UART_STATE_UPDATE,
- PROCESS_UART_STATE_SLEEP
- }process_Uart;
- typedef struct _UartQueryType
- {
- UINT8 Bms_Address;
- UINT8 Bms_Funcode;
- UINT8 Reg_Begin_H;
- UINT8 Reg_Begin_L;
- UINT8 Reg_Num_H;
- UINT8 Reg_Num_L;
- UINT8 CRC_L;
- UINT8 CRC_H;
- }UartQueryType;
- typedef struct _UartWriteMsgType
- {
- UINT8 Bms_Address;
- UINT8 Bms_Funcode;
- UINT8 Reg_Begin_H;
- UINT8 Reg_Begin_L;
- UINT8 Reg_Num_H;
- UINT8 Reg_Num_L;
- UINT8 Data_Count;
- UINT8 Data[2];
- UINT8 CRC_L;
- UINT8 CRC_H;
- }UartWriteMsgType;
- typedef struct _UartWriteDataType
- {
- volatile UINT8 WriteCmd;
- UINT8 Data[2];
- }UartWriteData_S;
- typedef enum
- {
- UPDATE_STEP_CHECK_VERSION=0,
- UPDATE_STEP_REQUEST_UPDATE,
- UPDATE_STEP_START_UPDATE,
- UPDATE_STEP_CHECK_VERSION_AGAIN,
- UPDATE_STEP_SET_BAUD_RATE,
- UPDATE_STEP_PREPARE_SEND_DATA_LEN,
- UPDATE_STEP_SEND_DATA_LEN,
- UPDATE_STEP_PREPARE_SEND_UPDATE_DATA,
- UPDATE_STEP_SEND_UPDATE_DATA,
- UPDATE_STEP_SEND_DATA_END,
- UPDATE_STEP_START_INSTALL,
- UPDATE_STEP_END,
- UPDATE_STEP_RESET,
- UPDATE_STEP_DOWNLOAD_BREAK_OFF,
- UPDATE_STEP_ERROR
- }UpdateStep;
- typedef enum
- {
- MS_UPDATE_STEP_SEND_FIRMWARE_UPDATE_REQUEST_AND_JUMP_TO_BOOTLOADER = 1,
- MS_UPDATE_STEP_FIRMWARE_UPDATE_REQUEST_ANSWER,
- MS_UPDATE_STEP_SEND_FIRMWARE_INFO,
- MS_UPDATE_STEP_FIRMWARE_INFO_CHECK_AND_UPDATE_REQEST_ANSWER,
- MS_UPDATE_STEP_EREASE_APP_FLASH_REQUEST,
- MS_UPDATE_STEP_EREASE_FLASH_ANSWER,
- MS_UPDATE_STEP_SEND_UPDATE_DATA,
- MS_UPDATE_STEP_UPDATE_DATA_WRITE_ANSWER,
- MS_UPDATE_STEP_SEND_UPDATE_DATA_END_AND_JUMP_TO_APP,
- MS_UPDATE_STEP_JUMP_TO_APP_ANSWER,
- MS_UPDATE_STEP_READ_CURRENT_RUNNING_MODE,
- MS_UPDATE_STEP_CURRENT_RUNNING_MODE_ANSWER,
- MS_UPDATE_STEP_END,
- MS_UPDATE_STEP_ERROR
- }UpdateStep_MS_BMS;
- typedef struct BMS_Update_Recv_Msg_Type
- {
- UINT8 startFlag;
- UINT8 addrFlag;
- UINT8 cmdRW;
- UINT8 dataLen;
- UINT8 cmd;
- UINT8 data;
- UINT8 checkSum;
- UINT8 endFlag;
- }BMS_Update_Recv_Msg_Type;
- typedef enum
- {
- updateOK = 0,
- updateErrorTimeout = 1,
- updateErrorBMSPowerLow = 2,
- updateErrorBMSWarningProtect = 3,
- updateErrorBMSNotSurport = 4,
- updateErrorBMSWorkState = 5,
- updateErrorFirmwareInfoError = 6,
- updateErrorFirmwareSizeError = 7,
- updateErrorAppErease = 8,
- updateErrorPackageCRC = 9,
- updateErrorPackageWrite = 10,
- updateErrorPackageNo = 11,
- updateErrorCheckSumError ,
- updateFailed = 0xFF
- }updateBMSStatus;
- void AppTaskUartInit(void *arg);
- void AppTaskUartDeInit(void *arg);
- UINT8 SP_BMS_Update_CheckSUM(UINT8* pSendData,UINT8 len);
- void SP_BMS_Update_Service();
- updateBMSStatus MS_BMS_Update_Service();
- UINT16 MS_BMS_Update_CRC16(UINT8* pSendData,UINT16 len);
- UINT8 UartAppTrasmit(UINT8* pSend,UINT32 sendLen, UINT8* pRead, UINT32 readLen, UINT32 timeout);
|