#include "sys.h" #include "usart.h" #include "led.h" #include "can.h" #include "string.h" #include "adc.h" #include "dc300.h" #include "KC.h" #include "kC_Features.h" #include "Flash_StorageData.h" ////////////////////////////////////////////////////////////////////////////////// //Èç¹ûʹÓÃucos,Ôò°üÀ¨ÏÂÃæµÄÍ·Îļþ¼´¿É. #if SYSTEM_SUPPORT_UCOS #include "includes.h" //ucos ʹÓà #endif ////////////////////////////////////////////////////////////////// //¼ÓÈëÒÔÏ´úÂë,Ö§³Öprintfº¯Êý,¶ø²»ÐèҪѡÔñuse MicroLIB #if 1 #pragma import(__use_no_semihosting) //±ê×¼¿âÐèÒªµÄÖ§³Öº¯Êý struct __FILE { int handle; }; FILE __stdout; //¶¨Òå_sys_exit()ÒÔ±ÜÃâʹÓðëÖ÷»úģʽ _sys_exit(int x) { x = x; } #include "sd.h" //Öض¨Òåfputcº¯Êý int fputc(int ch, FILE *f) { static u8 debug_info[250]={0}; static u8 debug_count ; static uint32_t timer = 0; /* ½«PrintfÄÚÈÝ·¢Íù´®¿Ú */ USART_SendData(UART4, (unsigned char) ch); while (!(UART4->SR & USART_FLAG_TXE)); if(SysParaPileD.Debug_Page_function ==1)//µ÷ÊÔ½çÃæ { if(BluetoothInfo.ConnectServerState == BLUE_WECHATAPPLET_ONLINE) { if(debug_count < 150 ) { debug_info[debug_count++] = ch; } else { UpdataDebugInfoToServer(debug_info,debug_count); BluetoothInfo.connetcOvertimeFlag++; debug_count =0; } } else { SysParaPileD.Debug_Page_function =0; } } return ch; } #endif uint8_t stopChargeReason =0; /*ʹÓÃmicroLibµÄ·½·¨*/ /* int fputc(int ch, FILE *f) { USART_SendData(USART1, (uint8_t) ch); while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {} return ch; } int GetKey (void) { while (!(USART1->SR & USART_FLAG_RXNE)); return ((int)(USART1->DR & 0x1FF)); } */ // SAMPLE: '1','2','3','4' -----> 1234 uint32_t StringToInt(uint8_t *sptr, uint8_t len); static uint8_t ShellCommad(void); void ResetShell(void); void UART4SendByte(unsigned char Byte); void UpdProcess(u8 type,u8 *Pdata, u16 length); typedef struct _UpdInfo { u8 FileType ; u8 FileVer ; u32 FileTotalByte ; u16 FileCrc ; u32 FileTotalPag ; u16 FilePaglen ; u32 RecePagNum ; u32 ReceBakPagNum ; u32 CurrByteLen ; u16 FlashBakPage ; u32 CurrBakByteLen ; }UpdInfo_s; UpdInfo_s UpdHead; #define UpdBaseAddr 0x8026000 //// 152k #define UpdInfoAddr 0x8025800 //// 150k #define UpdDataFlag 0x11223344 //// 150k u8 GprsCommGetAscMSB (u8 uHex ) { uHex = uHex >> 4 ; if (uHex > 9 ) //A~F { return (uHex + 0x37) ; } else //0~9 { return (uHex + 0x30) ; } } u8 GprsCommGetAscLSB (u8 uHex ) { uHex &= 0X0F ; if (uHex > 9 ) //A~F { return (uHex + 0x37) ; } else //0~9 { return (uHex + 0x30) ; } } void debugdataprocess(u8 *data,u16 len) { u16 i; u8 *ptr; u8 hdata,ldata; UART4SendByte('\r'); UART4SendByte('\n'); ptr = data; for(i = 0; i < len ; i++){ hdata = GprsCommGetAscMSB(*ptr); ldata = GprsCommGetAscLSB(*ptr); UART4SendByte(hdata); UART4SendByte(ldata); ptr++; } UART4SendByte('\r'); UART4SendByte('\n'); } #if EN_USART1_RX //Èç¹ûʹÄÜÁ˽ÓÊÕ //´®¿Ú1ÖжϷþÎñ³ÌÐò //×¢Òâ,¶ÁÈ¡USARTx->SRÄܱÜÃâĪÃûÆäÃîµÄ´íÎó u8 USART_RX_BUF[USART_REC_LEN]; //½ÓÊÕ»º³å,×î´óUSART_REC_LEN¸ö×Ö½Ú. //½ÓÊÕ״̬ //bit15£¬ ½ÓÊÕÍê³É±êÖ¾ //bit14£¬ ½ÓÊÕµ½0x0d //bit13~0£¬ ½ÓÊÕµ½µÄÓÐЧ×Ö½ÚÊýÄ¿ u16 USART_RX_STA=0; //½ÓÊÕ״̬±ê¼Ç void uart_init(u32 bound){ //GPIO¶Ë¿ÚÉèÖà GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE); //ʹÄÜUSART1£¬GPIOAʱÖÓ //USART1_TX PA.9 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //¸´ÓÃÍÆÍìÊä³ö GPIO_Init(GPIOA, &GPIO_InitStructure); //USART1_RX PA.10 // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//¸¡¿ÕÊäÈë // GPIO_Init(GPIOA, &GPIO_InitStructure); //Usart1 NVIC ÅäÖà NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3 ;//ÇÀÕ¼ÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //×ÓÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨµÀʹÄÜ NVIC_Init(&NVIC_InitStructure); //¸ù¾ÝÖ¸¶¨µÄ²ÎÊý³õʼ»¯VIC¼Ä´æÆ÷ //USART ³õʼ»¯ÉèÖà USART_InitStructure.USART_BaudRate = bound;//Ò»°ãÉèÖÃΪ9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×Ö³¤Îª8λÊý¾Ý¸ñʽ USART_InitStructure.USART_StopBits = USART_StopBits_1;//Ò»¸öֹͣλ USART_InitStructure.USART_Parity = USART_Parity_No;//ÎÞÆæżУÑéλ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//ÎÞÓ²¼þÊý¾ÝÁ÷¿ØÖÆ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //ÊÕ·¢Ä£Ê½ USART_Init(USART1, &USART_InitStructure); //³õʼ»¯´®¿Ú USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//¿ªÆôÖÐ¶Ï USART_Cmd(USART1, ENABLE); //ʹÄÜ´®¿Ú } void USART1_IRQHandler(void) //´®¿Ú1ÖжϷþÎñ³ÌÐò { u8 Res; #ifdef OS_TICKS_PER_SEC //Èç¹ûʱÖÓ½ÚÅÄÊý¶¨ÒåÁË,˵Ã÷ҪʹÓÃucosIIÁË. OSIntEnter(); #endif if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //½ÓÊÕÖжÏ(½ÓÊÕµ½µÄÊý¾Ý±ØÐëÊÇ0x0d 0x0a½áβ) { Res =USART_ReceiveData(USART1);//(USART1->DR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý if((USART_RX_STA&0x8000)==0)//½ÓÊÕδÍê³É { if(USART_RX_STA&0x4000)//½ÓÊÕµ½ÁË0x0d { if(Res!=0x0a)USART_RX_STA=0;//½ÓÊÕ´íÎó,ÖØпªÊ¼ else USART_RX_STA|=0x8000; //½ÓÊÕÍê³ÉÁË } else //»¹Ã»ÊÕµ½0X0D { if(Res==0x0d)USART_RX_STA|=0x4000; else { USART_RX_BUF[USART_RX_STA&0X3FFF]=Res ; USART_RX_STA++; if(USART_RX_STA>(USART_REC_LEN-1))USART_RX_STA=0;//½ÓÊÕÊý¾Ý´íÎó,ÖØпªÊ¼½ÓÊÕ } } } } #ifdef OS_TICKS_PER_SEC //Èç¹ûʱÖÓ½ÚÅÄÊý¶¨ÒåÁË,˵Ã÷ҪʹÓÃucosIIÁË. OSIntExit(); #endif } #endif ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////USART2,PD5¡¢PD6///////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// #if EN_USART2_RX //Èç¹ûʹÄÜÁ˽ÓÊÕ //´®¿Ú2ÖжϷþÎñ³ÌÐò //×¢Òâ,¶ÁÈ¡USARTx->SRÄܱÜÃâĪÃûÆäÃîµÄ´íÎó u8 USART2_RX_BUF[USART2_REC_LEN]; //½ÓÊÕ»º³å,×î´óUSART2_REC_LEN¸ö×Ö½Ú. //½ÓÊÕ״̬ //bit15£¬ ½ÓÊÕÍê³É±êÖ¾ //bit14£¬ ½ÓÊÕµ½0x0d //bit13~0£¬ ½ÓÊÕµ½µÄÓÐЧ×Ö½ÚÊýÄ¿ u16 USART2_RX_STA = 0; //½ÓÊÕ״̬±ê¼Ç u8 USART2_RX_FLAG = 0; void USART2SendByte(unsigned char Byte) { USART_SendData(USART2, Byte); while (!(USART2->SR & USART_FLAG_TXE)); } void RS232_Uart2_Write(uint8_t* buff, int length) { int i = 0; for(i =0;iSRÄܱÜÃâĪÃûÆäÃîµÄ´íÎó u8 USART3_RX_BUF[USART3_REC_LEN]; //½ÓÊÕ»º³å,×î´óUSART_REC_LEN¸ö×Ö½Ú. //½ÓÊÕ״̬ //bit15£¬ ½ÓÊÕÍê³É±êÖ¾ //bit14£¬ ½ÓÊÕµ½0x0d //bit13~0£¬ ½ÓÊÕµ½µÄÓÐЧ×Ö½ÚÊýÄ¿ u16 USART3_RX_STA=0; //½ÓÊÕ״̬±ê¼Ç u8 USART3_RX_FLAG=0; u16 USART3_RX_LEN=0; //½ÓÊÕ³¤¶È void uart3_init(u32 bound){ //GPIO¶Ë¿ÚÉèÖà GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE); //ʹÄÜUSART3£¬GPIOE,BʱÖÓ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); //ʹÄÜUSART3ʱÖÓ // GPIO_PinRemapConfig(GPIO_FullRemap_USART3,ENABLE); //USART3_TX PB.10 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PB.10 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //¸´ÓÃÍÆÍìÊä³ö GPIO_Init(GPIOB, &GPIO_InitStructure); //USART3_RX PB.11 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//¸¡¿ÕÊäÈë GPIO_Init(GPIOB, &GPIO_InitStructure); //Usart3 NVIC ÅäÖà NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1 ;//ÇÀÕ¼ÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //×ÓÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨµÀʹÄÜ NVIC_Init(&NVIC_InitStructure); //¸ù¾ÝÖ¸¶¨µÄ²ÎÊý³õʼ»¯VIC¼Ä´æÆ÷ //USART ³õʼ»¯ÉèÖà USART_InitStructure.USART_BaudRate = bound;//Ò»°ãÉèÖÃΪ9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×Ö³¤Îª8λÊý¾Ý¸ñʽ USART_InitStructure.USART_StopBits = USART_StopBits_1;//Ò»¸öֹͣλ USART_InitStructure.USART_Parity = USART_Parity_No;//ÎÞÆæżУÑéλ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//ÎÞÓ²¼þÊý¾ÝÁ÷¿ØÖÆ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //ÊÕ·¢Ä£Ê½ USART_Init(USART3, &USART_InitStructure); //³õʼ»¯´®¿Ú USART_Cmd(USART3, ENABLE); //ʹÄÜ´®¿Ú USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);//¿ªÆôÖÐ¶Ï // USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); USART_ITConfig(USART3, USART_IT_TC, ENABLE); USART_ITConfig(USART3, USART_IT_IDLE, ENABLE); } void USART3SendByte(unsigned char Byte) { USART_SendData(USART3, Byte); while (!(USART3->SR & USART_FLAG_TXE)); } void RS232_Uart3_Write(uint8_t* buff, int length) { int i = 0; for(i =0;iDR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý if(USART3_RX_LENDR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý // } } #endif #if EN_UART4_RX //Èç¹ûʹÄÜÁ˽ÓÊÕ //´®¿Ú1ÖжϷþÎñ³ÌÐò //×¢Òâ,¶ÁÈ¡USARTx->SRÄܱÜÃâĪÃûÆäÃîµÄ´íÎó u8 UART4_RX_BUF[UART4_REC_LEN]; //½ÓÊÕ»º³å,×î´óUART4_REC_LEN¸ö×Ö½Ú. //½ÓÊÕ״̬ //bit15£¬ ½ÓÊÕÍê³É±êÖ¾ //bit14£¬ ½ÓÊÕµ½0x0d //bit13~0£¬ ½ÓÊÕµ½µÄÓÐЧ×Ö½ÚÊýÄ¿ u16 UART4_RX_STA=0; //½ÓÊÕ״̬±ê¼Ç u8 UART4_RX_FLAG; u16 UART4_RX_LEN=0; //½ÓÊÕ³¤¶È void UART4SendByte(unsigned char Byte) { USART_SendData(UART4, Byte); while (!(UART4->SR & USART_FLAG_TXE)); } void RS232_Uart4_Write(uint8_t* buff, int length) { int i = 0; for(i =0;iDR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý if(UART4_RX_LENSR & USART_FLAG_TXE)); } void RS232_Uart5_Write(uint8_t* buff, int length) { int i = 0; for(i =0;iDR); //¶ÁÈ¡½ÓÊÕµ½µÄÊý¾Ý if(UART5_RX_LENÖ´ÐÐÖ¸Áî:%s...\n",incmd.cmd,incmd.cmdlen); (*cmdfunc)(); } return 1; } } // printf("An unrecognized CMD !\n"); return 0; } uint8_t SemiHexToChar(uint8_t sbyte) { sbyte &= 0x0F; if (sbyte < 0x0A) return (sbyte + '0'); else return (sbyte - 0x0A + 'A'); } uint8_t CharToSemiHex(uint8_t schar) { if (schar >= '0' && schar <= '9') return (schar - '0'); else if (schar >= 'A' && schar <= 'F') return (schar - 'A' + 0x0A); else if (schar >= 'a' && schar <= 'f') return (schar - 'a' + 0x0A); else return 0; } uint8_t IsHexChar (uint8_t schar) { if (((schar >= '0') && (schar <= '9')) || ((schar >= 'A') && (schar <= 'F')) || ((schar >= 'a') && (schar <= 'f'))){ return TRUE; } return FALSE; } // SAMPLE: '1','2','3','4' -----> 1234 uint32_t StringToInt(uint8_t *sptr, uint8_t len) { uint32_t result; result = 0; for (; len > 0; len--) { if (IsHexChar(*sptr)){ result = result * 10 + CharToSemiHex(*sptr++); } } return result; } void cmd_ADPrint(void) { } void cmd_PhoneTest(void) { } void cmd_TT(void) { } void cmd_SetAPNUser(void) { } void cmd_SetAPNPassword(void) { } /****************************************************************************************** FOR TEST SYSPARA , delet before release ******************************************************************************************/ uint16_t KeyLocation(uint8_t *sptr, char key, uint8_t keyindex,uint16_t limit) { uint16_t loc; loc = 0; for (;;) { if (*sptr++ == key) { if (keyindex == 1) break; else keyindex--; } if (limit == 0) break; else loc++; limit--; } return loc; } static uint8_t ParseCommandParam(void) { uint16_t inlen,index,tlen; uint8_t cnt; inlen = UART4_RX_LEN; //if (inlen == 0) return false; cnt = 1; incmd.cmd = UART4_RX_BUF; incmd.paranum = 0; index = KeyLocation(UART4_RX_BUF,' ',cnt,inlen); incmd.cmdlen = index; // printf("inout cmd:%s\n",incmd.cmd); if (index == inlen) { return 1; } cnt++; while (index != inlen) { if (UART4_RX_BUF[index] == ' ') { index++; } else { tlen = index; incmd.param[incmd.paranum] = &UART4_RX_BUF[index]; index = KeyLocation(UART4_RX_BUF,' ',cnt,inlen); //if (index != inlen) { incmd.paramlen[incmd.paranum] = index - tlen; printf("%d param:%s\n",incmd.paranum,incmd.param[incmd.paranum]); incmd.paranum++; if (incmd.paranum >= MAX_PARAM) break; cnt++; } } return 1; } /* Table of CRC values for high¨Corder byte */ static uint8_t const auchCRCHi[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 } ; /* Table of CRC values for low¨Corder byte */ static const char auchCRCLo[] = { 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 } ; uint16_t BlueCRC16(uint8_t *puchMsg, uint16_t usDataLen) { uint8_t uchCRCHi = 0xFF ; /* ³õʼ»¯¸ß×Ö½Ú*/ uint8_t uchCRCLo = 0xFF ; /* ³õʼ»¯µÍ×Ö½Ú*/ uint8_t uIndex ; /*°ÑCRC±í*/ while (usDataLen--) /*ͨ¹ýÊý¾Ý»º³åÆ÷*/ { uIndex = uchCRCHi ^ *puchMsg++ ; /*¼ÆËãCRC */ uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex] ; uchCRCLo = auchCRCLo[uIndex] ; } return (uchCRCHi << 8 | uchCRCLo) ; } #if 0 uint16_t Blue3CRC16(uint8_t *puchMsg, uint16_t usDataLen,u16 predata) { uint8_t uchCRCHi = 0xFF ; /* ³õʼ»¯¸ß×Ö½Ú*/ uint8_t uchCRCLo = 0xFF ; /* ³õʼ»¯µÍ×Ö½Ú*/ uint8_t uIndex ; /*°ÑCRC±í*/ #if 1 uchCRCHi = predata >>8; uchCRCLo = predata & 0xff ; #else uchCRCLo = predata >>8; uchCRCHi = predata & 0xff ; #endif while (usDataLen--) /*ͨ¹ýÊý¾Ý»º³åÆ÷*/ { uIndex = uchCRCHi ^ *puchMsg++ ; /*¼ÆËãCRC */ uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex] ; uchCRCLo = auchCRCLo[uIndex] ; } return (uchCRCHi << 8 | uchCRCLo) ; } #endif uint16_t Blue2CRC16(uint8_t *puchMsg, uint16_t usDataLen,u16 predata) { uint8_t uchCRCHi = 0xFF ; /* ³õʼ»¯¸ß×Ö½Ú*/ uint8_t uchCRCLo = 0xFF ; /* ³õʼ»¯µÍ×Ö½Ú*/ uint8_t uIndex ; /*°ÑCRC±í*/ #if 1 uchCRCHi = predata >>8; uchCRCLo = predata & 0xff ; #else uchCRCLo = predata >>8; uchCRCHi = predata & 0xff ; #endif while (usDataLen--) /*ͨ¹ýÊý¾Ý»º³åÆ÷*/ { uIndex = uchCRCHi ^ *puchMsg++ ; /*¼ÆËãCRC */ uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex] ; uchCRCLo = auchCRCLo[uIndex] ; } return (uchCRCHi << 8 | uchCRCLo) ; } #if 0 const static unsigned short crc16L[] = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, }; const static unsigned short crc16H[] = { 0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400, }; unsigned short CRC16_Modbus(unsigned short BreakPoint, unsigned char *Buffer, unsigned int Length) { unsigned short CRCValue; unsigned char Dat; CRCValue = BreakPoint; while (Length--) { Dat = *Buffer++; Dat ^= CRCValue; CRCValue >>= 8; CRCValue ^= crc16L[Dat & 0x0F]; CRCValue ^= crc16H[(Dat>>4) & 0x0F]; } return CRCValue; } #endif #if 0 unsigned short CRC16_Modbus(unsigned short BreakPoint, unsigned char *Buffer, unsigned int Length) { unsigned short CRCValue; unsigned char Dat; CRCValue = BreakPoint; while (Length--) { Dat = *Buffer++; Dat ^= CRCValue; CRCValue >>= 8; CRCValue ^= crc16L[Dat & 0x0F]; CRCValue ^= crc16H[(Dat>>4) & 0x0F]; } return CRCValue; } #endif /*-----------------------usart 2 Blue State----------------------------*/ BlueManage_t BluetoothInfo; void USART2_BLUR_Config(void) { } /*·¢ËÍÒ»¸ö×Ö½ÚÊý¾Ý*/ void RS232_Blue_Write(uint8_t* buff, int length) { int i = 0; for(i =0;iCALIBRATION_NUM)SocCalculate.index =CALIBRATION_NUM; // for(j=0;j SocCalculate.data[i+1].startVolt) // { // temp = SocCalculate.data[i]; //´ÓСµ½´óÅÅÐò // SocCalculate.data[i] = SocCalculate.data[i+1]; // SocCalculate.data[i+1] = temp; // } // } // } // //¼ÆËãȨֵ // for(i=0;iCALIBRATION_NUM)SocCalculate.index =CALIBRATION_NUM; #if 0 for(i=0;i SysParaPileD.SocCalculate.data[i+1].startVolt) { temp = SysParaPileD.SocCalculate.data[i]; //´ÓСµ½´óÅÅÐò SysParaPileD.SocCalculate.data[i] = SysParaPileD.SocCalculate.data[i+1]; SysParaPileD.SocCalculate.data[i+1] = temp; } } #endif // //¼ÆËãȨֵ // for(i=0;i= SocCalculate.data[i].startVolt)\ // &&(Sample_DataS.BAT_Voltage < SocCalculate.data[i].endVolt)) // { // // Bms_BatChargeRealInfo.uBatCurSOC = SocCalculate.data[i].startSoc+ // (Sample_DataS.BAT_Voltage-SocCalculate.data[i].startVolt)*SocCalculate.data[i].weight;; // return 1 ; // } // } // } // //дÈëÄÚ´ // if(i==SocCalculate.index) // { // //¸ßÓÚ×î´óÉèÖÃsocµÄµçѹ-- // if(Sample_DataS.BAT_Voltage > SocCalculate.data[i].startVolt) // { // return 2;//ÓÉĬÈÏËã·¨¼ÆËã // } // } return 0; } uint16_t udatatemp =0; typedef struct { uint16_t BmsMaxVolt; //µç³Ø¶î¶¨µçѹ==×î´ó³äµçµçѹ BatMaxTotalChargeVol uint16_t BmsMaxCurrent; uint16_t TotalVoltage;//µç³Ø¶î¶¨µçѹ uint16_t TotalCapacity; //µç³Ø¶î¶¨ÈÝÁ¿ uint16_t BatMaxChargeCur; uint16_t uBatMaxEnergy; //µç³Ø×î´óÈÝÁ¿ uint16_t BatMaxTotalChargeVol; //µç³Ø×î´ó³äµç×ܵçѹ uint16_t fTotalBatVol; //×¢²áÂë uint16_t BmRequireVolt; uint16_t BmsRequireCurrent; uint16_t StopVoltage; uint16_t RequirePower; //ºã¹¦ÂÊʱÒԴ˱äÁ¿ÎªÖ÷ uint16_t OverPower; uint8_t tricklepower; //ä¸Á÷¹¦ÂÊ uint8_t tricklecurrent; //ä¸Á÷µçÁ÷ uint16_t BatMaxChargeVol; //µ¥ÌåÐîµç³Ø×î¸ßÔÊÐí³äµçµçѹ(0.00~24.00V) 0.01V uint16_t BatRatedVoltage; //µ¥Ìåµç³Ø¶î¶¨µçѹ 0.1V uint8_t uBatMaxTempPlus50; //Ðîµç³ØÄ£¿é×î¸ßÔÊÐíµÄζÈ(-50~200¡æ) uint8_t uBatMinTempPlus50; //×îµÍÎÂ¶È //DCDC¹¦ÂÊ uint8_t DCMaxPower; }s_data_temp_t; s_data_temp_t sysparamdata; void updata_param(void) { sysparamdata.BmsMaxVolt = SysParaPileD.BmsMaxVolt/10; sysparamdata.BmsMaxCurrent = SysParaPileD.BmsMaxCurrent/10; sysparamdata.BmRequireVolt = SysParaPileD.BmRequireVolt/10; sysparamdata.OverPower =SysParaPileD.OverPower/10; sysparamdata.StopVoltage =SysParaPileD.StopVoltage/10; sysparamdata.BmsRequireCurrent=SysParaPileD.BmsRequireCurrent/10; sysparamdata.tricklepower =SysParaPileD.tricklepower/10; sysparamdata.tricklecurrent = SysParaPileD.tricklecurrent/10; sysparamdata.RequirePower =SysParaPileD.RequirePower/10; sysparamdata.BatMaxChargeVol =SysParaPileD.BatMaxChargeVol/10; sysparamdata.BatRatedVoltage= SysParaPileD.BatRatedVoltage/10; sysparamdata.BatMaxChargeVol=SysParaPileD.BatMaxChargeVol/10; sysparamdata.uBatMinTempPlus50=SysParaPileD.uBatMinTempPlus50-50; sysparamdata.uBatMaxTempPlus50=SysParaPileD.uBatMaxTempPlus50-50; sysparamdata.DCMaxPower=SysParaPileD.DCMaxPower; } static SysparamTable_t paramTable[] = { {0x02,1,(uint8_t *)&udatatemp}, {0x01,1,(uint8_t *)&udatatemp}, {0x03,1,(uint8_t *)&udatatemp}, {0x05,16,(uint8_t *)SysParaPileD.bluetooth_passward}, {0x04,16,(uint8_t *)SysParaPileD.bluetooth_name}, {0x06 ,2,(uint8_t *)&SysParaPileD.OverTempValue},//ζȱ£»¤Öµ {0x07 ,2,(uint8_t *)&SysParaPileD.HeartBeatTime},//ÐÄÌø°üʱ¼ä {0x08 ,1,(uint8_t *)&SysParaPileD.ProtocolType},//ÐÂÀϹú±êЭÒé {0x09 ,16,(uint8_t *)SysParaPileD.sn},//ÉèÖÃSNºÅ {0x0A ,1,(uint8_t *)&SysParaPileD.QuickChargeEnable},//ÀëÏß¿ì³äʹÄÜ {0x0F ,1,(uint8_t *)&SysParaPileD.tricklecurrent},//ä¸Á÷³äµçµçÁ÷ {0x0E ,1,(uint8_t *)&SysParaPileD.tricklepower},//ä¸Á÷³äµç¹¦ÂÊ {0x0D ,1,(uint8_t *)&SysParaPileD.trickleChargingSoc},//ä¸Á÷soc {0x0C ,1,(uint8_t *)&SysParaPileD.trickleChargingSocEnable},//ä¸Á÷ʹÄÜ {0x0B ,1,(uint8_t *)&udatatemp}, {0x13,2,(uint8_t *)&SysParaPileD.BmsMaxCurrent},//ÉèÖõçÁ÷ {0x12 ,2,(uint8_t *)&SysParaPileD.BmsMaxVolt},//ÉèÖõçѹ {0x11 ,2,(uint8_t *)&SysParaPileD.BmsRequireCurrent},//ÐèÇóµçÁ÷ {0x10 ,2,(uint8_t *)&SysParaPileD.BmRequireVolt},//ÐèÇóµçѹ {0x14,2,(uint8_t *)&udatatemp},//soc // {0x15,2,(uint8_t *)&Sample_DataS.BAT_B_Reverse_Voltage},//µ±Ç°µç³Øµçѹ {0x16,2,(uint8_t *)&SysParaPileD.uBatMaxEnergy},//µç³Ø×î´óÈÝÁ¿ // {0x17,4,(uint8_t *)&Bms_BatInfo.ucBmsVersion},//soc {0x18,1,(uint8_t *)&SysParaPileD.ucBatType},//µ±Ç°µç³Øµçѹ // {0x19,4,(uint8_t *)&Bms_BatInfo.ucProductName},//µç³Ø×î´óÈÝÁ¿ // {0x1A,3,(uint8_t *)&Bms_BatInfo.uProductYear}, // {0x1B,17,(uint8_t *)&SysParaPileD.VehichleInfo}, // {0x1C,8,(uint8_t *)&Bms_BatInfo.ucSoftwareVersion}, {0x1F,1,(uint8_t *)&sysparamdata.RequirePower},//ÐèÇó¹¦ÂÊ {0x1E,1,(uint8_t *)&sysparamdata.OverPower},//×î¸ß¹¦ÂÊ {0x1D,1,(uint8_t *)&SysParaPileD.ChargingMode},// ³äµçģʽ ºãÁ÷ ºã¹¦ÂÊ {0x20,1, (uint8_t *)&sysparamdata.BatRatedVoltage}, //µ¥Ìå¶î¶¨µçѹ {0x21 ,1,(uint8_t *)&sysparamdata.BatMaxChargeVol},//µ¥ÌåÐîµç³Ø×î¸ßÔÊÐí³äµçµçѹ {0x22 ,1,(uint8_t *)&SysParaPileD.BatCount},//µç³Øµ¥ÌåÊýÁ¿ {0x24 ,2,(uint8_t *)&SysParaPileD.BmsMaxVolt},//ϵͳÂúµçµçѹ {0x23 ,2,(uint8_t *)&SysParaPileD.TotalCapacity},//ϵͳ¶î¶¨ÈÝÁ¿ {0x27 ,1,(uint8_t *)&SysParaPileD.ucBatType},//µç³ØÀàÐÍ {0x26 ,1,(uint8_t *)&sysparamdata.uBatMinTempPlus50},//µç³Ø×îµÍÎÂ¶È {0x25 ,1,(uint8_t *)&sysparamdata.uBatMaxTempPlus50},//µç³Ø×î¸ßÎÂ¶È {0x28 ,2,(uint8_t *)&SysParaPileD.TotalVoltage},//ϵͳ¶î¶¨µçѹ {0x29 ,1,(uint8_t *)&SysParaPileD.RequireVoltageDifference},//µ±Ç°ÐèÇóÓëʵ¼Êµçѹ ѹ²î {0x2A ,2,(uint8_t *)&SysParaPileD.SimulatedCurrentBatVolt},//Ä£Äâµç³Ø²ÉÑùµçѹ {0x2B ,1,(uint8_t *)&SysParaPileD.Debug_Page_function},//µ÷ÊÔÒ³Ãæ²ÎÊý //=========================================================== {0x30 ,2,(uint8_t *)&SysParaPileD.uBatMaxEnergy},//³äµçµçÁ¿ {0x31 ,2,(uint8_t *)&sysparamdata.StopVoltage},//Í£»úµçѹ {0x32 ,1,(uint8_t *)&SysParaPileD.OverTempValue[0]},//ζÈ̽ͷ1 {0x33 ,1,(uint8_t *)&SysParaPileD.OverTempValue[1]},//ζÈ̽ͷ1 {0x34 ,1,(uint8_t *)&SysParaPileD.OverTempValue[2]},//ζÈ̽ͷ2 {0x35 ,1,(uint8_t *)&SysParaPileD.SignalLossFlag},//ÐźŶªÊ§ {0x36 ,10,(uint8_t *)SysParaPileD.VehichleInfo},//³µÁ¾VIN {0x37 ,7,(uint8_t *)&SysParaPileD.VehichleInfo[10]},//³µÁ¾VIN //---------------------------------DCBMS------------------------------ {0x50 ,1,(uint8_t *)&SysParaPileD.WorkModel}, {0x51 ,2,(uint8_t *)&SysParaPileD.DCRequireVolt}, {0x52 ,2,(uint8_t *)&SysParaPileD.DCRequireCurrent}, {0x53 ,1,(uint8_t *)&SysParaPileD.DCMaxPower}, {0x54 ,1,(uint8_t *)&SysParaPileD.DC_InductanceTemp}, {0x55 ,1,(uint8_t *)&SysParaPileD.DC_IGBTTemp}, {0x56 ,2,(uint8_t *)&SysParaPileD.DCMaxVolt}, {0x57 ,2,(uint8_t *)&SysParaPileD.DCMaxCurrent}, {0x58 ,1,(uint8_t *)&SysParaPileD.CapacitanceTemp1}, {0x59 ,1,(uint8_t *)&SysParaPileD.DCBoxTemp2}, {0x5A ,1,(uint8_t *)&SysParaPileD.DoubleBatteryMode}, {0x60 ,1,(uint8_t *)&SysParaPileD.VIN_Enable}, {0x61 ,1,(uint8_t *)&SysParaPileD.BlueSignalLoss}, {0x62 ,1,(uint8_t *)&SysParaPileD.ChargeMode}, {0x63 ,2,(uint8_t *)&SysParaPileD.ChargeParam}, //³äµç²ÎÊý {0x65 ,1,(uint8_t *)&SysParaPileD.HighVoltageModule}, //¸ßѹ¸¨ÖúÄ£¿é 1¿ª 0¹Ø {0x66 ,1,(uint8_t *)&SysParaPileD.HighVoltageOffset}, //¸ßѹ¸¨ÖúÄ£¿é У׼ {0x6D ,1,(uint8_t *)&SysParaPileD.SocSimulaType},//SOC¼ÆË㷽ʽ 1-can¶ÁÈ¡ 2-socÄ£Äâ 3-SOCУ׼ {0x6E ,2,(uint8_t *)&SysParaPileD.SocSimulaMaxVolt},//SOCÄ£Äâ×î´óµçѹȡ 2-socÄ£Äâ 3-SOCУ׼ {0x6F ,2,(uint8_t *)&SysParaPileD.SocSimulaMinVolt},//SOCÄ£Äâ×îСµçѹ-socÄ£Äâ 3-SOCУ׼ {0x70 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[0]}, {0x71 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[1]}, {0x72 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[2]}, {0x73 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[3]}, {0x74 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[4]}, {0x75 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[5]}, {0x76 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[6]}, {0x77 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[7]}, {0x78 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[8]}, {0x79 ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[9]}, {0x7A ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[10]}, {0x7B ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[11]}, {0x7C ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[12]}, {0x7D ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[13]}, {0x7E ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[14]}, {0x7F ,2,(uint8_t *)&SysParaPileD.SocCalibrationVolt[15]}, {0x80 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[0]}, {0x81 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[1]}, {0x82 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[2]}, {0x83 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[3]}, {0x84 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[4]}, {0x85 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[5]}, {0x86 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[6]}, {0x87 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[7]}, {0x88 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[8]}, {0x89 ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[9]}, {0x8A ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[10]}, {0x8B ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[11]}, {0x8C ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[12]}, {0x8D ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[13]}, {0x8E ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[14]}, {0x8F ,2,(uint8_t *)&SysParaPileD.SocCalibrationData[15]}, }; //u8 GetBnum[4]; void BMS_Updata2ACKInfo(void) { //Êý¾Ý´ò°ü static uint32_t timer,bagcnt = 0; static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data = 0; Blue_Send_Package.cmd = 0x1021; //bagcnt ++; //Blue_Send_Package.ucDataSpace[0]=0x55; //Blue_Send_Package.ucDataSpace[1]=0xaa; Blue_Send_Package.ucDataSpace[0]=UpdHead.RecePagNum & 0xff; Blue_Send_Package.ucDataSpace[1]=(UpdHead.RecePagNum >> 8) & 0xff; Blue_Send_Package.ucDataSpace[2]=(UpdHead.RecePagNum >> 16) & 0xff; Blue_Send_Package.ucDataSpace[3]=(UpdHead.RecePagNum >> 24) & 0xff; Blue_Send_Package.len =4; BluetoothInfo.connetcOvertimeFlag++; printf("\n\rshengjiyingda \n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); debugdataprocess(&Blue_Send_Package.ucDataSpace[0],4); } extern record_t ChargeRecordInfo; uint8_t paramnumcount = 0; uint8_t ServerStop_ChargeFlag = 0; uint8_t ServerSet_CmdFlag = 0; u8 upddatabuf[300]; u16 updtcnt = 0; u16 Getupdtcnt(void) { return updtcnt; } void Delupdtcnt(void) { if(updtcnt) updtcnt --; } void sHandleParsePkg(void *pkg) { uint8_t addrparam,paramdata,i,j,paramnum,cnt,err_cnt = 0; uint16_t data,Vcrc,Dcrc; uint8_t ucComBuf[64]={0}; uint16_t ucLen = 0,QQ1Crc = 0xffff,H1crc; u32 addr,readval; u32 *Upddata; //// u32 Upddata; u8 *pdata; u16 updlen,Qcmd; DP_FrameBluetooth_t *Blue_pkg =pkg; BluetoothInfo.connetcOvertimeFlag = 0; #if 1 if((Blue_pkg->cmd == 0x8020) || (Blue_pkg->cmd == 0x8021)) { pdata = (u8 *)pkg; updlen = Blue_pkg->len; Qcmd = Blue_pkg->cmd; if(Blue_pkg->len <= 300) memcpy(upddatabuf,Blue_pkg->ucDataSpace,(Blue_pkg->len)); debugdataprocess(upddatabuf,updlen); Dcrc = pdata[updlen - 1] <<8 | pdata[updlen - 2] ; Vcrc = BlueCRC16(pdata, (updlen - 2)); printf("\n\rDcrc %0x,Vcrc %0x\n\r",Dcrc,Vcrc); if(Dcrc != Vcrc) { printf("\n\r (Dcrc != Vcrc) return!!!!!\n\r"); return; } BluetoothInfo.ReciveDataOvertimeFlag = 0; UpdProcess((Qcmd - 0x8020),upddatabuf,updlen); updtcnt = 100; BluetoothInfo.ConnectServerState = BLUE_WECHATAPPLET_UPDATA; //Éý¼¶ return; } #endif switch(Blue_pkg->cmd) { case 0x8000: //×¢²á°ü case 0x0080: //×¢²á°ü if(Blue_pkg->ucDataSpace[0]==1) { BluetoothInfo.ConnectServerState = BLUE_LOGIN; //×¢²á³É¹¦ SysParaPileD.registeredFlag = 1; memset(SysParaPileD.registeredCode,0,sizeof(SysParaPileD.registeredCode)); memcpy( SysParaPileD.registeredCode,&Blue_pkg->ucDataSpace[1],8); //дÈëflash±£´æ BluetoothInfo.ConnectServerState = BLUE_LOGIN; SysStoreSysParmflag =1; printf("registered successed,Code %s\n\r",SysParaPileD.registeredCode); } else { printf("registered failed\n\r"); } break; case 0x8001: //µÇ¼°ü case 0x0180: //µÇ¼°ü if(Blue_pkg->ucDataSpace[0]==1) { //µÇ½³É¹¦ BluetoothInfo.ConnectServerState = BLUE_WECHATAPPLET_ONLINE; printf("Login Successed\n\r"); } else { printf("Login Failed\n\r"); } break; case 0x8002: //ÐÄÌø°ü case 0x0280: //ÐÄÌø°ü printf("heart count %d\n\r",Blue_pkg->ucDataSpace[0]); memcpy(&ChargeRecordInfo.date,&Blue_pkg->ucDataSpace[2],7) ; break; case 0x8003: //µ±Ç°×´Ì¬°ü case 0x0380: //µ±Ç°×´Ì¬°ü printf("receive state data \n\r"); break; case 0x8004: //ÔÊÐí³äµç case 0x0480: //ÔÊÐí³äµç printf("receive charge data \n\r"); printf("charge %s\n\r",Blue_pkg->ucDataSpace[1] == 1 ? "Enable":"Disable"); if(Blue_pkg->ucDataSpace[1] == 0 ) { ServerStop_ChargeFlag = 1; if(stopChargeReason == 0)stopChargeReason = 4;//С³ÌÐòÍ£Ö¹³äµç } break; case 0x8005: //ÉèÖðü case 0x0580: //ÉèÖðü ServerSet_CmdFlag = 1; if(Blue_pkg->ucDataSpace[0] == 0) printf("param read\n\r" ); else printf("param write\n\r"); if(Blue_pkg->ucDataSpace[0] == 1 ) { addrparam = Blue_pkg->ucDataSpace[1]; printf("param addr %x\n\r",addrparam); if( addrparam == 0x01 ) { if(Blue_pkg->ucDataSpace[2] == 0) { // g_ChargeStep = CC_CHARGE_END; ServerStop_ChargeFlag = 1; if(stopChargeReason == 0)stopChargeReason = 4;//С³ÌÐòÍ£Ö¹³äµç } printf("charging %s\n\r",Blue_pkg->ucDataSpace[2] == 1 ? "enable":"disable"); } if( addrparam == 0x02 ) { if(Blue_pkg->ucDataSpace[2] == 1) { printf("close relay\n\r"); // DC_CONTACTOR_KC4(1); } else { printf("open relay\n\r"); // DC_CONTACTOR_KC4(0); } } if( addrparam == 0x04 ) { data =strlen(&Blue_pkg->ucDataSpace[2]); if(data < sizeof(SysParaPileD.bluetooth_name)) { memcpy(SysParaPileD.bluetooth_name,&Blue_pkg->ucDataSpace[2],data); printf("bluetooth name %s\n\r",&Blue_pkg->ucDataSpace[2]); SysStoreSysParmflag =1; } else { printf("bluetooth name mistake %s\n\r",&Blue_pkg->ucDataSpace[2]); } } if( addrparam == 0x07 ) { data =Blue_pkg->ucDataSpace[2] ; printf("Heart Beat Time %d sec\n\r",data); SysParaPileD.HeartBeatTime = data; SysStoreSysParmflag =1; } if( addrparam == 0x06)//ζȱ£»¤Öµ { data =Blue_pkg->ucDataSpace[2] ; printf("OverTempValue %d \n\r",data); SysParaPileD.OverTempValue[0] = data; SysParaPileD.OverTempValue[1] = data; SysParaPileD.OverTempValue[2] = data; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x08 ) { data =Blue_pkg->ucDataSpace[2]; // if(data ==BMS_PROTOCAL_GB2015) // { // SysParaPileD.ProtocolType= BMS_PROTOCAL_GB2015; // printf("BMS PROTOCAL GB2015\n\r"); // // } // else // { //// SysParaPileD.ProtocolType= BMS_PROTOCAL_GB2011; // printf("BMS PROTOCAL GB2011\n\r"); // } SysStoreSysParmflag =1; } if( addrparam == 0x09 ) { data =strlen(&Blue_pkg->ucDataSpace[2]); if(data < sizeof(SysParaPileD.sn)) { memcpy(SysParaPileD.sn,&Blue_pkg->ucDataSpace[2],data); printf("SysParaPileD.sn:%s\n\r",&Blue_pkg->ucDataSpace[2]); // SysWriteSysParm(); SysStoreSysParmflag =1; } else { printf("SysParaPileD.sn fault %s\n\r",&Blue_pkg->ucDataSpace[2]); } // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x0A ) { data =Blue_pkg->ucDataSpace[2]; if(data ==1) { SysParaPileD.QuickChargeEnable= 1; printf("Quick Charge Enable\n\r"); } else { SysParaPileD.QuickChargeEnable= 0; printf("Quick Charge Enable\n\r"); } SysStoreSysParmflag =1; } if( addrparam == 0x0B ) //µç³Øµ±Ç°SOC Æô¶¯¼ÆËã { data =Blue_pkg->ucDataSpace[2] ; // if(data ==1) //Æô¶¯socУ׼ // { // memset((char *)&SocCalculate,0,sizeof(SocCalculate)); // SocCalculate.CalibrationEnable =0; // SysWriteSocParm(); // printf("\n\rsocÆô¶¯Ð£×¼\n\r"); // } // else if(data ==2) //socУ׼Íê³É // { // //ÅÅÐò¼ÆËã±£´æÆðÀ´ //// SocCalculateOver(); //// SysWriteSocParm(); // printf("\n\rsocÆô¶¯Ð£×¼Íê³É\n\r"); // } } if( addrparam == 0x0C) //µç³Øµ±Ç°SOC Æô¶¯¼ÆËã { data =Blue_pkg->ucDataSpace[2] ; if(data ==1) //Æô¶¯socУ׼ { SysParaPileD.trickleChargingSocEnable =1; printf("trickle Charging Soc Enable 1\n\r"); } else { //ÅÅÐò¼ÆËã±£´æÆðÀ´ SysParaPileD.trickleChargingSocEnable =0; printf("trickle Charging Soc Enable 0\n\r"); } // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x0D) //µç³Øµ±Ç°SOC Æô¶¯¼ÆËã { data =Blue_pkg->ucDataSpace[2] ; if(data < 100) //Æô¶¯socУ׼ { SysParaPileD.trickleChargingSoc =data; printf("trickleChargingSoc%d\n\r",data); } else { printf("trickleChargingSoc 90\n\r"); SysParaPileD.trickleChargingSoc =90; } // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x0E ) { data =Blue_pkg->ucDataSpace[2]; printf("trickle power %d.%dkw\n\r",data/10,data%10); SysParaPileD.tricklepower= data; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x0F ) { data =Blue_pkg->ucDataSpace[2]; printf("trickle current%dA\n\r",data); SysParaPileD.tricklecurrent= data*10; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x10 ) { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; printf("BmsMaxVolt%d \n\r",data); if(data*10 < SysParaPileD.BmsMaxVolt) { SysParaPileD.BmRequireVolt = data*10; // SysWriteSysParm(); SysStoreSysParmflag =1; } else { printf("%d BmsMaxVolt %d faild\n\r",data*10,SysParaPileD.BmsMaxVolt); SysParaPileD.BmRequireVolt = SysParaPileD.BmsMaxVolt-20; printf("BmRequireVolt %d \n\r",SysParaPileD.BmRequireVolt/10); } } if( addrparam == 0x11 ) { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; printf("BmsMaxCurrent %d \n\r",data); if(data*10 < SysParaPileD.BmsMaxCurrent) { SysParaPileD.BmsRequireCurrent = data*10; // SysWriteSysParm(); SysStoreSysParmflag =1; } else { printf("req %d over max %d \n\r",data*10,SysParaPileD.BmsMaxCurrent); } } if( addrparam == 0x12 ) { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; printf("BmsMaxVolt %d \n\r",data); SysParaPileD.BmsMaxVolt = data*10; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x13 ) { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; printf("BmsMaxCurrent%d \n\r",data); SysParaPileD.BmsMaxCurrent = data*10; // if(SysParaPileD.BmsMaxCurrent >BAT_MAX_CHARGE_CUR)SysParaPileD.BmsMaxCurrent = BAT_MAX_CHARGE_CUR; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x14 ) //µç³Øµ±Ç°SOC --×öÒ»¸öÊý×é¼ÆËãsoc { data =Blue_pkg->ucDataSpace[2]; printf("setting soc(%d)\n\r",data); // printf("BAT_Voltage %d\n\r",(uint16_t)Sample_DataS.BAT_Voltage); if(SocCalculate.index >CALIBRATION_NUM)SocCalculate.index =CALIBRATION_NUM; // SocCalculate.data[SocCalculate.index].startVolt = Sample_DataS.BAT_Voltage; SocCalculate.data[SocCalculate.index].startSoc = data; SocCalculate.index++; } if( addrparam == 0x16 ) { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.uBatMaxEnergy = data; printf("uBatMaxEnergy %d.%d\n\r",data/10,data%10); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x1D ) // ³äµçģʽ ºãÁ÷ ºã¹¦ÂÊ { data = Blue_pkg->ucDataSpace[2] ; if(data ==1 || data ==2) { SysParaPileD.ChargingMode = data; printf("ChargingMode:%s \n\r",data==1?"CC":"CV"); // SysWriteSysParm(); SysStoreSysParmflag =1; } else printf("ChargingMode Fault\n\r"); } if( addrparam == 0x1E ) //×î¸ß¹¦ÂÊ { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.OverPower = data*10; printf("OverPower :%d.%dkwh\n\r",SysParaPileD.OverPower /10,SysParaPileD.OverPower %10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x1F ) //ÐèÇó¹¦ÂÊ { data = Blue_pkg->ucDataSpace[2] ; if(SysParaPileD.RequirePower > SysParaPileD.OverPower ) { printf("RequirePower %d kw OverPower :%dkw,fault\n\r",SysParaPileD.RequirePower /10,SysParaPileD.OverPower /10 ); SysParaPileD.RequirePower = SysParaPileD.OverPower-10; printf("RequirePower %d kw \n\r",SysParaPileD.RequirePower /10); // SysWriteSysParm(); SysStoreSysParmflag =1; } else { SysParaPileD.RequirePower = data*10; printf("RequirePower :%d.%dkwh\n\r",SysParaPileD.RequirePower /10,SysParaPileD.RequirePower %10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } } //µç³ØÏà¹ØÐÅÏ¢ if( addrparam == 0x20 ) //µ¥Ìå¶î¶¨µçѹ { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.BatRatedVoltage = data*10; printf("BatRatedVoltage :%d.%dV\n\r",SysParaPileD.BatRatedVoltage /100,SysParaPileD.BatRatedVoltage %100 ); // SysWriteSysParm(); } //µ¥ÌåÐîµç³Ø×î¸ßÔÊÐí³äµçµçѹ(0.00~24.00V) 0.01V //µ¥Ìåµç³Ø¶î¶¨µçѹ 0.1V // Âúµçµçѹ // µç³ØÀàÐÍ //ä¸Á÷¹¦ÄÜ //socä¸Á÷ ʹÄÜ //ä¸Á÷socÆô¶¯Öµ //ä¸Á÷¹¦ÂÊ //ä¸Á÷µçÁ÷ if( addrparam == 0x21 ) //µ¥ÌåÐîµç³Ø×î¸ßÔÊÐí³äµçµçѹ { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.BatMaxChargeVol = data*10; printf("BatMaxChargeVol :%d.%dV\n\r",SysParaPileD.BatMaxChargeVol /100,SysParaPileD.BatMaxChargeVol %100 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x22 ) //µ¥ÌåÊýÁ¿ { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.BatCount = data; printf("BatCount :%d\n\r",SysParaPileD.BatCount ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x23 ) //ϵͳ¶î¶¨ÈÝÁ¿ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.TotalCapacity = data; printf("TotalCapacity :%d.%dAH\n\r",SysParaPileD.TotalCapacity/10,SysParaPileD.TotalCapacity%10); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x24 ) //ϵͳÂúµçµçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.BmsMaxVolt = data; printf("BmsMaxVolt:%d.%dv\n\r",SysParaPileD.BmsMaxVolt/10, SysParaPileD.BmsMaxVolt%10); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x25 ) //µç³Ø×î¸ßÎÂ¶È { data = Blue_pkg->ucDataSpace[2] ; printf("uBatMaxTempPlus50 :%d \n\r", data ); SysParaPileD.uBatMaxTempPlus50 = data+50; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x26 ) //µç³Ø×îµÍÎÂ¶È { data = Blue_pkg->ucDataSpace[2] ; printf("uBatMinTempPlus50 :%d \n\r",data ); SysParaPileD.uBatMinTempPlus50 = data+50; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x27 ) //µç³ØÀàÐÍ { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.ucBatType = data; if(data==1) printf("ucBatType:ǦËáµç³Ø \n\r" ); if(data==2) printf("ucBatType:ÄøÇâµç³Ø \n\r" ); if(data==3) printf("ucBatType:Á×ËáÌú﮵ç³Ø \n\r" ); if(data==4) printf("ucBatType:ÃÌËá﮵ç³Ø \n\r" ); if(data==5) printf("ucBatType:îÜËá﮵ç³Ø \n\r" ); if(data==6) printf("ucBatType:ÈýԪ﮵ç³Ø \n\r" ); if(data==7) printf("ucBatType:¾ÛºÏÎïï®Àë×Óµç³Ø \n\r" ); if(data==8) printf("ucBatType:îÑËá﮵ç³Ø \n\r" ); if(data==0xff) printf("ucBatType:ÆäËûµç³Ø \n\r" ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x28) //ϵͳ¶î¶¨µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.TotalVoltage = data; printf("TotalVoltage:%d \n\r",SysParaPileD.TotalVoltage /10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x29) //µ±Ç°ÐèÇóÓëʵ¼Êµçѹ ѹ²î { data = Blue_pkg->ucDataSpace[2] ; if((data>=10)&&(data <=100)) { SysParaPileD.RequireVoltageDifference = data; printf("RequireVoltageDifference(%d)V \n\r",SysParaPileD.RequireVoltageDifference); } else { printf(" (%d)V over range \n\r",data); SysParaPileD.RequireVoltageDifference = 0; } // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x2A ) { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if((data >=1000) && (data<=3500)) { SysParaPileD.SimulatedCurrentBatVolt = data; printf("SimulatedCurrentBatVolt %dV\n\r",SysParaPileD.SimulatedCurrentBatVolt/10); } else { printf("SimulatedCurrentBatVolt %dV--100-350V\n\r",data); } SysStoreSysParmflag =1; } if( addrparam == 0x2B) // µ÷ÊÔģʽ´ò¿ª { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.Debug_Page_function = data; else SysParaPileD.Debug_Page_function =0; printf("%s Debug_Page_function \n\r",SysParaPileD.Debug_Page_function==1?"OPEN":"CLOSE" ); SysStoreSysParmflag =1; } if( addrparam == 0x30 ) //³äµçµçÁ¿ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.uBatMaxEnergy = data; printf("uBatMaxEnergy %d .%d \n\r",SysParaPileD.uBatMaxEnergy/10 ,SysParaPileD.uBatMaxEnergy%10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x31 ) //Í£»úµçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.StopVoltage = data*10; printf("StopVoltage :%d.%d V \n\r",SysParaPileD.StopVoltage/10,SysParaPileD.StopVoltage%10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x32) //Í£»úζÈ--Ö÷°å { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.OverTempValue[0] = data; printf("OverTemp0Value:%d \n\r",SysParaPileD.OverTempValue[0] ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x33) // { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.OverTempValue[1] = data; printf("OverTemp1Value:%d \n\r",SysParaPileD.OverTempValue[1] ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x34) // { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.OverTempValue[2] = data; printf("OverTemp2Value:%d \n\r",SysParaPileD.OverTempValue[2] ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x35) // { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.SignalLossFlag = data; else SysParaPileD.SignalLossFlag =0; printf("SignalLossFlag %s \n\r",SysParaPileD.SignalLossFlag==1?"Enable":"Disable" ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x36) // { // data =strlen(&Blue_pkg->ucDataSpace[2]); // if(data <= sizeof(SysParaPileD.VehichleInfo)) // if(data <= 10) { memset(SysParaPileD.VehichleInfo,0,sizeof(SysParaPileD.VehichleInfo)); memcpy(SysParaPileD.VehichleInfo,&Blue_pkg->ucDataSpace[2],10); printf("VehichleInfo(0-9):%s\n\r",&Blue_pkg->ucDataSpace[2]); // SysWriteSysParm(); SysStoreSysParmflag =1; } // else // { // printf("\n\rÉèÖÃVIN³¤¶È´íÎó%s\n\r",&Blue_pkg->ucDataSpace[2]); // } // SysWriteSysParm(); } if( addrparam == 0x37) // { // data =strlen(&Blue_pkg->ucDataSpace[2]); // if(data <= sizeof(SysParaPileD.VehichleInfo)) { // memset(SysParaPileD.VehichleInfo,0,sizeof(SysParaPileD.VehichleInfo)); memcpy(&SysParaPileD.VehichleInfo[10],&Blue_pkg->ucDataSpace[2],7); printf("VehichleInfo VIN(10-17):%s\n\r",&Blue_pkg->ucDataSpace[2]); // SysWriteSysParm(); SysStoreSysParmflag =1; } // else // { // printf("\n\rÉèÖÃVIN³¤¶È´íÎó%s\n\r",&Blue_pkg->ucDataSpace[2]); // } // SysWriteSysParm(); } //---------------------------------DCBMS------------------------------ if( addrparam == 0x50) // רҵ¼òÒ×ģʽ { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.WorkModel = data; else SysParaPileD.WorkModel =0; printf("WorkModel %s \n\r",SysParaPileD.WorkModel==1?"professional":"easy" ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x51) // DCÐèÇóµçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if(data >= 48 && data <300) SysParaPileD.DCRequireVolt = data*10; else { printf("DCRequireVolt %d:Over(48-300) \n\r",data ); } printf("DCRequireVolt:%d.%d V \n\r",SysParaPileD.DCRequireVolt/10,SysParaPileD.DCRequireVolt%10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x52) // DCÐèÇóµçÁ÷ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if(data > 10 && data <100) SysParaPileD.DCRequireCurrent = data*10; else { printf("DCRequireCurrent%dA:Over(10-100A) \n\r",data ); } printf("DCRequireCurrent%dA \n\r",SysParaPileD.DCRequireCurrent/10,SysParaPileD.DCRequireCurrent%10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x53) // DC×î´ó¹¦ÂÊ { data = Blue_pkg->ucDataSpace[2] ; if(data > 10 && data <150) SysParaPileD.DCMaxPower = data; else { printf("DCMaxPower%d :Over(1-15k) \n\r",data ); } printf("DCMaxPower:%d.%d kw \n\r",SysParaPileD.DCMaxPower/10,SysParaPileD.DCMaxPower%10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } /**************DC±£»¤Ìõ¼þ******************/ if( addrparam == 0x54) // µç¸ÐÎÂ¶È -- { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.DC_InductanceTemp = data; printf("DC_InductanceTemp %d \n\r",SysParaPileD.DC_InductanceTemp); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x55) // ¹Ü×ÓÎÂ¶È -- { data = Blue_pkg->ucDataSpace[2] ; SysParaPileD.DC_IGBTTemp = data; printf("DC_IGBTTemp %d \n\r",SysParaPileD.DC_IGBTTemp); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x56) // ×î´óµçѹ-- { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if(data >= 48 && data <250) SysParaPileD.DCMaxVolt = data*10; else { printf("DCMaxVolt %dV:Over(48-200V) \n\r",data ); } printf("DC DCMaxVolt:%d.%d V \n\r",SysParaPileD.DCMaxVolt/10,SysParaPileD.DCMaxVolt%10 ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x57) // ×î´óµçÁ÷-- { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if(data >= 20 && data <110) SysParaPileD.DCMaxCurrent = data*10; else { printf("DC DCMaxCurrent%d:Over(20-110) \n\r",data ); } printf("DC DCMaxCurrent:%d.%d A \n\r",SysParaPileD.DCMaxCurrent/10,SysParaPileD.DCMaxCurrent%10 ); SysStoreSysParmflag =1; } if( addrparam == 0x58) // ¹Ü×ÓÎÂ¶È -- { data = Blue_pkg->ucDataSpace[2] ; if(data <150 ) SysParaPileD.CapacitanceTemp1 = data; printf("CapacitanceTemp1 %d \n\r",SysParaPileD.CapacitanceTemp1); SysStoreSysParmflag =1; } if( addrparam == 0x59) // ¹Ü×ÓÎÂ¶È -- { data = Blue_pkg->ucDataSpace[2] ; if(data <150 ) SysParaPileD.DCBoxTemp2 = data; printf("DCBoxTemp2 %d \n\r",SysParaPileD.DCBoxTemp2); SysStoreSysParmflag =1; } if( addrparam == 0x5A) { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.DoubleBatteryMode = data; else SysParaPileD.DoubleBatteryMode =0; printf("DoubleBatteryMode %s\n\r",SysParaPileD.DoubleBatteryMode==1?"Enable":"Disable" ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x60) // É豸VIN¹¦ÄÜÊÇ·ñ´ò¿ª { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.VIN_Enable = data; else SysParaPileD.VIN_Enable =0; printf("VIN Trans %s\n\r",SysParaPileD.VIN_Enable==1?"Enable":"Disable" ); SysStoreSysParmflag =1; } if( addrparam == 0x61) // ÐźŶªÊ§ { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.BlueSignalLoss = data; else SysParaPileD.BlueSignalLoss =0; printf("BlueSignalLoss%s\n\r",SysParaPileD.BlueSignalLoss==1?"Enable":"Disable" ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x62) // ³äµç·½Ê½ { data = Blue_pkg->ucDataSpace[2] ; if(data<=3) SysParaPileD.ChargeMode = data; else SysParaPileD.ChargeMode =0; if(SysParaPileD.ChargeMode==1) printf("ChargeMode--kwh\n\r" ); if(SysParaPileD.ChargeMode==2) printf("ChargeMode--time\n\r" ); if(SysParaPileD.ChargeMode==3) printf("ChargeMode--SOC\n\r" ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x63) // ÊýÖµ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if(SysParaPileD.ChargeMode==1) { printf("ChargeMode-kwh(%d)\n\r",data ); } if(SysParaPileD.ChargeMode==2) { printf("ChargeMode-time(%d)\n\r",data ); } if(SysParaPileD.ChargeMode==3) { printf("ChargeMode-SOC(%d)\n\r",data ); } SysParaPileD.ChargeParam = data; // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x64) // ä¸Á÷¿ª¹Ø { SysStoreSysParmflag =1; // SysWriteSysParm(); } if( addrparam == 0x65) //¸¨Öú¸ßѹģ¿é¿ª¹Ø { data = Blue_pkg->ucDataSpace[2] ; if(data==1) SysParaPileD.HighVoltageModule = data; else SysParaPileD.HighVoltageModule =0; printf("high voltage module %s\n\r",SysParaPileD.HighVoltageModule==1?"Enable":"Disable" ); SysStoreSysParmflag =1; // SysWriteSysParm(); } // if( addrparam == 0x66) // // { // data = Blue_pkg->ucDataSpace[2] ; // if(data==1) // SysParaPileD.HighVoltageOffset = data; // else // SysParaPileD.HighVoltageOffset =0; // printf("\n\rÐźŶªÊ§ %s \n\r",SysParaPileD.HighVoltageOffset==1?"ʹÄÜ":"½ûÖ¹" ); // // SysWriteSysParm(); // } if( addrparam == 0x6D) // SOC¼ÆË㷽ʽ { data = Blue_pkg->ucDataSpace[2] ; if(data==1) { SysParaPileD.SocSimulaType = 1; printf("SocSimulaType-1\n\r" ); } if(data==2) { SysParaPileD.SocSimulaType = 2; printf("SocSimulaType-2\n\r" ); } if(data==3) { SysParaPileD.SocSimulaType = 3; printf("SocSimulaType-3\n\r" ); } //SOC¼ÆË㷽ʽ 1-can¶ÁÈ¡ 2-socÄ£Äâ 3-SOCУ׼ // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x6E) // SOCÄ£Äâ×î¸ßµçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocSimulaMaxVolt = data; if(data > 200 && data < 760 ) SysParaPileD.BmsMaxVolt = data*10; printf("\n\r SocSimulaMaxVolt %d V \n\r",SysParaPileD.SocSimulaMaxVolt ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x6F) // SOCÄ£Äâ×îµÍµçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; if(data > 200 && data < 760 ) SysParaPileD.TotalVoltage = data*10; SysParaPileD.SocSimulaMinVolt = data; printf("\n\r SocSimulaMinVolt %d V \n\r",SysParaPileD.SocSimulaMinVolt ); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x70) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[0] = data; printf("\n\r SocCalibrationVolt %d (0.1)V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x71) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[1] = data; printf("\n\r SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x72) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[2] = data; printf("\n\r SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x73) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[3] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x74) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[4] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x75) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[5] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x76) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[6] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x77) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[7] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x78) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[8] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x79) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[9] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x7A) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[10] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x7B) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[11] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x7C) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[12] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x7D) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[13] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x7E) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[14] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x7F) // socУ׼µçѹ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationVolt[15] = data; printf("SocCalibrationVolt %d V \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x80) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[0] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x81) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[1] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x82) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[2] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x83) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[3] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x84) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[4] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x85) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[5] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x86) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[6] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x87) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[7] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x88) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[8] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x89) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[9] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x8A) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[10] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x8B) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[11] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x8C) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[12] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x8D) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[13] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x8E) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[14] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } if( addrparam == 0x8F) // socУ׼ { data = Blue_pkg->ucDataSpace[3] <<8 | Blue_pkg->ucDataSpace[2] ; SysParaPileD.SocCalibrationData[15] = data; printf("SocCalibration %d \n\r",data); // SysWriteSysParm(); SysStoreSysParmflag =1; } } else if(Blue_pkg->ucDataSpace[0] == 0) //¶ÁÈ¡ÃüÁî { paramnum =Blue_pkg->ucDataSpace[1]; printf("Read param num %d\n\r",paramnum); paramnumcount = paramnum; if( 13 == paramnumcount) { paramnumcount = 0; Blue_Send_Package.len =0; } Blue_Send_Package.len =0; // addrparam = Blue_pkg->ucDataSpace[1]; updata_param(); for(i =0;iucDataSpace[2+i]; for(j =0;jucDataSpace[0] ; Blue_Send_Package.ucDataSpace[1]= paramnum; for(i =0;iucDataSpace[2+i]; } DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } break; case 0x8006: //ÉèÖðü case 0x0680: //ÉèÖðü if(Blue_pkg->ucDataSpace[0] == 1 ) { SysParaPileD.Recordindex = 0; memset(SysParaPileD.chargeRecord,0,sizeof(SysParaPileD.chargeRecord)); SysWriteSysParm(); printf("Receive records ack\n\r"); } break; case 0x8007: //DCDC״̬±¨ÎÄ case 0x0780: //DCDC״̬±¨ÎÄ printf("Receive DCDC state ack\n\r"); // printf("\n\rÔÊÐí³äµç%s\n\r",Blue_pkg->ucDataSpace[1] == 1 ? "ÔÊÐí":"½ûÖ¹"); // if(Blue_pkg->ucDataSpace[1] == 0 ) // { // ServerStop_ChargeFlag = 1; // } break; case 0x8008: //Éý¼¶°ü case 0x0880: //Éý¼¶°ü printf("Receive DCDC state ack\n\r"); break; case 0x8009: //ÎļþÀàÐÍÉý¼¶ case 0x0980: printf("Receive DCDC state ack\n\r"); break; case 0x800A: //ÎļþÄÚÈÝ case 0x800D: //µ÷ÊÔÊý¾Ý printf("Receive DEBUG DCDC ack\n\r"); BluetoothInfo.connetcOvertimeFlag =0; break; case 0x0A80: printf("Receive DCDC state ack\n\r"); break; case 0x8020: //ÎļþÄÚÈÝ case 0x2080: break; case 0x8021: //ÎļþÄÚÈÝ case 0x2180: break; default: break; } } void UpdProcess(u8 type,u8 *Pdata, u16 length) // type 0 upd head get,,,, 1 ture upd data get { u32 addr,readval; u32 *Upddata; u8 *pdata; u8 i,cnt,err_cnt = 0; static u16 QQCrc = 0xffff,TCrc = 0xffff; u16 Hcrc; static u8 failfg = 0; IWDG_Feed(); if(type == 0){ UpdHead.FileType = Pdata[4]; UpdHead.FileVer = Pdata[5]; UpdHead.FileTotalByte = Pdata[6] <<24 | Pdata[7] <<16 | Pdata[8] <<8 | Pdata[9]; UpdHead.FileCrc = Pdata[11] <<8 | Pdata[10]; UpdHead.FileTotalPag = Pdata[15] <<24 | Pdata[14] <<16 | Pdata[13] <<8 | Pdata[12]; UpdHead.FilePaglen = Pdata[17] <<8 | Pdata[16]; UpdHead.ReceBakPagNum = 0xffffffff; UpdHead.CurrByteLen = 0; UpdHead.CurrBakByteLen = 0; UpdHead.FlashBakPage = 0xffff; failfg = 0; printf("\r\n666Upd--type:%d ,ver:%d,Tbyte:%d, Crc:%d,Pag:%d,Plen:%d\r\n",UpdHead.FileType,UpdHead.FileVer,UpdHead.FileTotalByte,UpdHead.FileCrc,UpdHead.FileTotalPag,UpdHead.FilePaglen); printf("\r\n777Upd--type:%0x ,ver:%0x,Tbyte:%0x, Crc:%0x,Pag:%0x,Plen:%0x\r\n",UpdHead.FileType,UpdHead.FileVer,UpdHead.FileTotalByte,UpdHead.FileCrc,UpdHead.FileTotalPag,UpdHead.FilePaglen); BMS_UpdataACKInfo(); } else if(type == 1){ if(failfg) return; UpdHead.RecePagNum = Pdata[3] <<24 | Pdata[2] <<16 | Pdata[1] <<8 | Pdata[0]; BMS_Updata2ACKInfo(); IWDG_Feed(); printf("\n\rCurr Bag:%d, len %d\n\r",UpdHead.RecePagNum,length); if(UpdHead.ReceBakPagNum != UpdHead.RecePagNum){ UpdHead.ReceBakPagNum = UpdHead.RecePagNum; UpdHead.CurrByteLen += length - 13;////Blue_pkg->len - 13; printf("Write-addr: sector %d,,offset %d ,reclen %0d\r\n",UpdHead.CurrByteLen / 2048,UpdHead.CurrByteLen % 2048,UpdHead.CurrByteLen); FLASH_Unlock(); if(UpdHead.FlashBakPage != (UpdHead.CurrByteLen / 2048)){ UpdHead.FlashBakPage = UpdHead.CurrByteLen / 2048; addr = (UpdBaseAddr + UpdHead.CurrByteLen) & 0xfffff800; printf("44Curr Erase--addr: %0x\r\n",addr); FLASH_ErasePage(addr); } Upddata = (u32 *)&Pdata[4]; cnt = (length - 13) / 4; if((length - 13) % 4){ printf("\n\rlast-----bag!!!!!!!\n\r"); memset((u8 *)&Pdata[length - 9],3,0xff); cnt ++; } addr = (UpdBaseAddr + UpdHead.CurrBakByteLen); UpdHead.CurrBakByteLen = UpdHead.CurrByteLen; for(i = 0; i < cnt ; i++){ err_cnt = 0; while (1) { if (FLASH_ProgramWord(addr, Upddata[i]) == 4)break; //// FLASH_COMPLETE 4 else err_cnt++; if (err_cnt >= 3){ printf("!22!!!!!!!!!Write-Fail-addr: %0x\r\n",addr); failfg = 1; return; } } readval = *(__IO uint32_t *)addr; if((i < 1) || (i >= (cnt - 1))){ printf("addr %0x,,Write %0x,,read %0x\r\n",addr,Upddata[i],readval); } if(readval != Upddata[i]){ printf("\n\r readval != Upddata[i])!!!!!\n\r"); printf("addr %0x,,Write %0x,,read %0x\r\n",addr,Upddata[i],readval); failfg = 1; return; } addr += 4; if(err_cnt >= 3) break; } #if 1 IWDG_Feed(); TCrc = Blue2CRC16(&Pdata[4],(length - 13),TCrc); printf("122UpdHead.FileCrc=%0x,TCrc=%0x\r\n",UpdHead.FileCrc,TCrc); #endif IWDG_Feed(); if(UpdHead.RecePagNum == UpdHead.FileTotalPag){ if(UpdHead.FileCrc != TCrc){ printf("UpdHead.FileCrc != TCrc !!! return!\r\n"); return; } err_cnt = 0; printf("!!!upd-info!! Write-totpag %d \r\n",UpdHead.FileTotalPag); FLASH_ErasePage(UpdInfoAddr); while (1) { if (FLASH_ProgramWord(UpdInfoAddr, UpdDataFlag) == 4)break; //// FLASH_COMPLETE 4 else err_cnt++; if (err_cnt >= 3){ printf("UpdDataFlag! Write-Fail-addr: %0x\r\n",UpdInfoAddr); break; } } readval = *(__IO uint32_t *)UpdInfoAddr; printf("addr %0x,,Write %0x,,read %0x\r\n",UpdInfoAddr,UpdDataFlag,readval); if(UpdDataFlag != readval){ failfg = 1; return; } err_cnt = 0; while (1) { if (FLASH_ProgramWord(UpdInfoAddr + 4, UpdHead.FileTotalByte) == 4)break; //// FLASH_COMPLETE 4 else err_cnt++; if (err_cnt >= 3){ printf("!!!upd-info!! Write-Fail-addr: %0x\r\n",UpdInfoAddr + 4); break; } } readval = *(__IO uint32_t *)(UpdInfoAddr + 4); printf("1addr %0x,,Write %0x,,read %0x\r\n",(UpdInfoAddr + 4),UpdHead.FileTotalByte,readval); if(UpdHead.FileTotalByte != readval){ failfg = 1; return; } IWDG_Feed(); BMS_Updata2ACKInfo(); printf("22upd-all write OOKK!!restart!!!!!!!!!!!\r\n"); NVIC_SystemReset(); while(1); } FLASH_Lock(); } IWDG_Feed(); } } static void Blue_Data_Parser(uint8_t *data, uint16_t length) { DP_FrameBluetooth_t *pkg = (DP_FrameBluetooth_t *)data; // uint8_t i = 0; // uint8_t ucLen; //×ܳ¤¶È(³ýȥͷ×Ö½Ú) // uint16_t crc,crc2= 0; if(pkg->address ==0x5AA5) { sHandleParsePkg(pkg); } } #define BLUE_IDLE_ACK "AT+OK\r\n" #define BLUE_PREPARE_ACK "AT+OK\r\n+256000,3,0,0" #define BLUE_PREPARE_ACK2 "AT+OK\r\n0303" #define BLUE_CONFIG_ACK "AT+OK\r\nBlue_303\r\n" #define BLUE_CONNECT_ACK "AT+OK\r\n01\r\n" #include void Blue_Receive_Parser(void) { if(USART2_RX_FLAG ==1) { // printf("%s\n\r",USART2_RX_BUF); switch(BluetoothInfo.State) { case BLUE_IDLE: if(memcmp(USART2_RX_BUF, BLUE_IDLE_ACK, 7)==0) { BluetoothInfo.State =BLUE_PREPARE; } break; case BLUE_PREPARE: if(memcmp(USART2_RX_BUF, BLUE_PREPARE_ACK2, 10)==0) { BluetoothInfo.State =BLUE_CONFIG; } break; case BLUE_CONFIG: if(strstr((char *)USART2_RX_BUF,(char *)SysParaPileD.bluetooth_name)!=0) { BluetoothInfo.State =BLUE_LINK_CONNECTING; } break; case BLUE_LINK_CONNECTING: if(memcmp(USART2_RX_BUF, BLUE_CONNECT_ACK, 11)==0) { BluetoothInfo.State =BLUE_LINK_CONNECTED; } break; case BLUE_LINK_CONNECTED: BluetoothInfo.recvBuffer = USART2_RX_BUF; BluetoothInfo.recvLength = USART2_RX_STA; Blue_Data_Parser(USART2_RX_BUF, USART2_RX_STA); break; } USART2_RX_FLAG = 0; USART2_RX_STA =0; memset(USART2_RX_BUF,0,USART_BUFFER_SIZE); } } void Blue_Set_Name(uint8_t *data, uint16_t length) { RS232_Blue_Write(data,length); } void Blue_AT_Init(void) { RS232_Blue_Write("AT",2); } void Blue_Query_Version(void) { RS232_Blue_Write("AT+VERION=?",strlen("AT+VERION=?")); } void Blue_Name_Cfg(uint8_t *data) { uint8_t buffer[30]={0}; memset(buffer,0,sizeof(buffer)); sprintf((char *)&buffer[0],"AT+NAME=%s",data); RS232_Blue_Write(buffer,strlen((char *)buffer)); } void Blue_Name_Query(void) { RS232_Blue_Write("AT+NAME=?",strlen("AT+NAME=?")); } void Blue_Connect_State(void) { RS232_Blue_Write("AT+STATE=?",strlen("AT+STATE=?")); } void Blue_Query_UART_Cfg(void) { RS232_Blue_Write("AT+UART_CFG=?",strlen("AT+UART_CFG=?")); } /********************************************************************************* * Description : ¿ÕÏеȴý£¬ÅжÏÖ§¸¶·½Ê½¡¢Ç¹ºÅ¡¢³äµçģʽ¡¢µ¯¿ªÇ¹ÃÅ **********************************************************************************/ void Bluetooth_Switch_IDLE(void) { Blue_AT_Init(); } void Bluetooth_Switch_PREPARE(void) { static uint8_t step; static uint32_t timer; if(TickOut(&timer, 1000)==TRUE) { if(step == 0) { Blue_Query_Version(); step =1; } else if(step == 1) { Blue_Query_UART_Cfg(); step =0; } TickOut(&timer, 0); } } void Bluetooth_Switch_Config(void) { static uint8_t step; static uint32_t timer; if(TickOut(&timer, 1000)==TRUE) { if(step == 0) { step =1; } else if(step == 1) { // Blue_Name_Cfg("Blue_HaiDun"); Blue_Name_Cfg(SysParaPileD.bluetooth_name); step =2; } else if(step == 2) { Blue_Name_Query(); step =0; } TickOut(&timer, 0); } } void Bluetooth_Switch_Connecting(void) { static uint32_t timer; if(TickOut(&timer, 3000)==TRUE) { Blue_Connect_State(); TickOut(&timer, 0); } } void Bluetooth_Data_Send(uint8_t *data,uint8_t len) { RS232_Blue_DataWrite(data,len); } uint8_t DP_PackageWriteDataFrame(DP_FrameBluetooth_t *pPara, uint8_t *pBuf, uint16_t *ucDatalen) { uint8_t iCount = 0; uint16_t crc,i = 0; uint16_t len = 0; if ((pPara == NULL) || (pBuf == NULL)) return FALSE; len = pPara->len+25; /* ´ò°üÕ¾ºÅ¹¦ÄÜÂë */ pBuf[iCount++] = D_DP_FrameStart1; pBuf[iCount++] = D_DP_FrameStart2; pBuf[iCount++] =len &0xff; pBuf[iCount++] = (len>>8)&0xff; pBuf[iCount++] = D_DP_Device; memcpy(pBuf+iCount, SysParaPileD.sn, 16); iCount = iCount + 16; pBuf[iCount++] = pPara->cmd &0xff; pBuf[iCount++] = ( pPara->cmd>>8)&0xff; if( pPara->len >= 2) { memcpy(pBuf + iCount, pPara->ucDataSpace, pPara->len); iCount = iCount + pPara->len; } /*¼ÆËãCRC*/ crc = BlueCRC16(pBuf, iCount); /*´ò°üCRC*/ pBuf[iCount++] = crc & 0xff ; pBuf[iCount++] = (crc >> 8) & 0xff; Bluetooth_Data_Send(pBuf, iCount); return TRUE; } void Bluetooth_Registered(void); void Bluetooth_Login(void); void Bluetooth_HeartBeat(void); void BluetoothDataProcess(void); void Bluetooth_chargeRecord(void); void BluetoothConnectProcess(void) { switch(BluetoothInfo.State) { case BLUE_IDLE: { Bluetooth_Switch_IDLE(); break; } case BLUE_PREPARE: { Bluetooth_Switch_PREPARE(); break; } case BLUE_CONFIG: { Bluetooth_Switch_Config(); break; } case BLUE_LINK_CONNECTING: { Bluetooth_Switch_Connecting(); if( SysParaPileD.registeredFlag ==0) BluetoothInfo.ConnectServerState = BLUE_REGISTERED; else if( SysParaPileD.registeredFlag ==1) BluetoothInfo.ConnectServerState = BLUE_LOGIN; break; } case BLUE_LINK_CONNECTED: { BluetoothDataProcess(); break; } case BLUE_END: { break; } default: break; }//end switch } bmsblue_datainfo_t bluebms_datainfo; void BluetoothDataProcess(void) { static uint16_t iCount = 0; static uint32_t timer = 0; static uint16_t timerout = 1000; if(SysParaPileD.Debug_Page_function ==1) { if(BluetoothInfo.connetcOvertimeFlag >=10)//¼ÆÊý±êÖ¾ { SysParaPileD.Debug_Page_function = 0; } return; } else timerout =1000; if(BluetoothInfo.connetcOvertimeFlag >20) { if( SysParaPileD.registeredFlag ==0) BluetoothInfo.ConnectServerState = BLUE_REGISTERED; else if( SysParaPileD.registeredFlag ==1) BluetoothInfo.ConnectServerState = BLUE_LOGIN; } switch(BluetoothInfo.ConnectServerState) { case BLUE_REGISTERED: { Bluetooth_Registered(); break; } case BLUE_LOGIN: { Bluetooth_Login(); SysParaPileD.Debug_Page_function =0; break; } case BLUE_WECHATAPPLET_ONLINE: { if(TickOut( &timer,timerout)==TRUE) { iCount++; if(iCount >9)iCount=0; TickOut( &timer,0); if(iCount == 0) { Bluetooth_HeartBeat(); } else if(iCount == 1) { BMS_ChargeInfo(); } else if(iCount == 2) { BMS_StatusMessage(); } else if(iCount == 3) { // BMS_UpdataACKInfo(); } else if(iCount == 4) { Bluetooth_DCDC_Data(); } else if(iCount == 5) { BMS_VersionInfo(); } else if(iCount == 6) { BMS_ChargingDataInfo(); } else if(iCount == 7) { bat_temp_Info(); } else if(iCount == 8) { bat_Cell_Vol_Info(); } else if(iCount == 9) { bat_state_code(); } } break; } case BLUE_WECHATAPPLET_OFFLINE: { break; } case BLUE_WECHATAPPLET_UPDATA: { if(BluetoothInfo.ReciveDataOvertimeFlag++ >20) { BluetoothInfo.State=BLUE_IDLE; if( SysParaPileD.registeredFlag ==0) BluetoothInfo.ConnectServerState = BLUE_REGISTERED; else if( SysParaPileD.registeredFlag ==1) BluetoothInfo.ConnectServerState = BLUE_LOGIN; } break; } case BLUE_LINK_CONNECTED: { // Bluetooth_Data_Send("87654321", 8); break; } case BLUE_END: { break; } default: break; }//end switch } extern uint16_t WuLingBatMaxchargcur; /********************************************************************** * @ º¯ÊýÃû £º Bluetooth_Registered * @ ¹¦ÄÜ˵Ã÷£º É豸Ê״εǼÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚ»ñÈ¡ºÍ°ó¶¨×¢²áÂë¡£ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void Bluetooth_Registered(void) { //Êý¾Ý´ò°ü static uint32_t timer; uint8_t ucComBuf[64]; uint16_t ucLen = 0; if(TickOut(&timer, 5000)==TRUE) { Blue_Send_Package.cmd = 0x1000; Blue_Send_Package.len = 0; printf("Send Registered data\n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); TickOut(&timer, 0); } } /********************************************************************** * @ º¯ÊýÃû £º Bluetooth_Login * @ ¹¦ÄÜ˵Ã÷£º É豸µÇ¼ʱÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚУÑé×¢²áÂëºÍͬ²½¹Ì¼þ°æ±¾ºÅ¡£ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void Bluetooth_Login(void) { //Êý¾Ý´ò°ü static uint32_t timer; uint8_t ucComBuf[64]; uint16_t ucLen = 0; if(TickOut(&timer, 3000)==TRUE) { Blue_Send_Package.cmd = 0x1001; //×¢²áÂë printf("send Login data\r\n"); memcpy(&Blue_Send_Package.ucDataSpace[0], SysParaPileD.registeredCode, 8); memcpy(&Blue_Send_Package.ucDataSpace[8], ApplicationVersion, 8); Blue_Send_Package.len =16; DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); TickOut(&timer, 0); } } /********************************************************************** * @ º¯ÊýÃû £º Bluetooth_HeartBeat * @ ¹¦ÄÜ˵Ã÷£º É豸¶¨ÆÚÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚ±£³ÖÐÄÌøÁ¬½Ó¡£±ÈÑǵÏÔ¶¹Å°æ±¾´ÓÕâÀï»ñÈ¡ÉèÖòÎÊý£¬ а汾¿ÉÒÔʹÓÃ0x8005»ñÈ¡ÉèÖòÎÊýºó»ù±¾Óò»ÉÏÕâ¸ö±¨ÎÄ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void Bluetooth_HeartBeat(void) { //Êý¾Ý´ò°ü static uint32_t timer; static uint32_t heartbeat = 0; uint8_t ucComBuf[128]; uint16_t ucLen = 0; // if( ServerSet_CmdFlag == 1) { // Blue_Send_Package.cmd = 0x1002; // heartbeat++; // Blue_Send_Package.ucDataSpace[0]=heartbeat&0xff; // Blue_Send_Package.ucDataSpace[1]=(heartbeat>>8)&0xff;; // //memcpy(&Blue_Send_Package.ucDataSpace[1],&SysTime,sizeof(SysTime)); //// Blue_Send_Package.ucDataSpace[2]=bmsProtocalType; // bmsЭÒé // Blue_Send_Package.ucDataSpace[2]=SysParaPileD.ProtocolType; // bmsЭÒé // Blue_Send_Package.ucDataSpace[3]=(CDZ_ChargeInfo.ChargeOutMaxVoltage/10)&0xff; // Blue_Send_Package.ucDataSpace[4]=((CDZ_ChargeInfo.ChargeOutMaxVoltage/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[5]=(CDZ_ChargeInfo.ChargeOutMinVoltage/10)&0xff; // Blue_Send_Package.ucDataSpace[6]=((CDZ_ChargeInfo.ChargeOutMinVoltage/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[7]=(CDZ_ChargeInfo.ChargeOutMaxCurrent/10)&0xff; // Blue_Send_Package.ucDataSpace[8]=((CDZ_ChargeInfo.ChargeOutMaxCurrent/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[9]=(CDZ_ChargeInfo.ChargeOutMinCurrent/10)&0xff; // Blue_Send_Package.ucDataSpace[10]=((CDZ_ChargeInfo.ChargeOutMinCurrent/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[11]=SysParaPileD.ChargingMode; // 1--ºã¹¦ÂÊ 2-ºãÁ÷ // Blue_Send_Package.ucDataSpace[12]=(SysParaPileD.OverPower/10 ); //×î´ó¹¦ÂÊ // Blue_Send_Package.ucDataSpace[13]=(SysParaPileD.uBatMaxEnergy)&0xff; // Blue_Send_Package.ucDataSpace[14]=(SysParaPileD.uBatMaxEnergy>>8)&0xff;//×î´óµçÁ¿ // Blue_Send_Package.ucDataSpace[15]=(SysParaPileD.StopVoltage/10)&0xff; // Blue_Send_Package.ucDataSpace[16]=((SysParaPileD.StopVoltage/10)>>8)&0xff;//Í£»úµçѹ // // //µ¥ÌåÐîµç³Ø×î¸ßÔÊÐí³äµçµçѹ(0.00~24.00V) 0.01V // //µ¥Ìåµç³Ø¶î¶¨µçѹ 0.1V // Blue_Send_Package.ucDataSpace[17]=((SysParaPileD.BatRatedVoltage/10))&0xff; // //Blue_Send_Package.ucDataSpace[18]=((SysParaPileD.BatRatedVoltage/10)>>8)&0xff;//×î´óµçÁ¿ // Blue_Send_Package.ucDataSpace[18]=(SysParaPileD.BatMaxChargeVol/10)&0xff; // //Blue_Send_Package.ucDataSpace[20]=((SysParaPileD.BatMaxChargeVol/10)>>8)&0xff;//Í£»úµçѹ // // ¶î¶¨µçµçѹ // // ¶î¶¨ÈÝÁ¿ // Blue_Send_Package.ucDataSpace[19]=(SysParaPileD.TotalVoltage)&0xff; // Blue_Send_Package.ucDataSpace[20]=((SysParaPileD.TotalVoltage)>>8)&0xff; // Blue_Send_Package.ucDataSpace[21]=(SysParaPileD.TotalCapacity)&0xff; // Blue_Send_Package.ucDataSpace[22]=((SysParaPileD.TotalCapacity)>>8)&0xff; // // Âúµçµçѹ // // µç³ØÀàÐÍ // Blue_Send_Package.ucDataSpace[23]=(SysParaPileD.BmsMaxVolt)&0xff; // Blue_Send_Package.ucDataSpace[24]=((SysParaPileD.BmsMaxVolt)>>8)&0xff; // Blue_Send_Package.ucDataSpace[25]=SysParaPileD.ucBatType; // //ä¸Á÷¹¦ÄÜ // //socä¸Á÷ ʹÄÜ // //ä¸Á÷socÆô¶¯Öµ // //ä¸Á÷¹¦ÂÊ // //ä¸Á÷µçÁ÷ // Blue_Send_Package.ucDataSpace[26]=(SysParaPileD.trickleChargingSocEnable)&0xff; // Blue_Send_Package.ucDataSpace[27]=(SysParaPileD.trickleChargingSoc)&0xff; // Blue_Send_Package.ucDataSpace[28]=(SysParaPileD.tricklepower/10)&0xff; // Blue_Send_Package.ucDataSpace[29]=(SysParaPileD.tricklecurrent/10)&0xff; // Blue_Send_Package.ucDataSpace[30]=(SysParaPileD.uBatMaxTempPlus50-50)&0xff; // Blue_Send_Package.ucDataSpace[31]=(SysParaPileD.uBatMinTempPlus50-50)&0xff; // Blue_Send_Package.ucDataSpace[32]=(SysParaPileD.BatCount)&0xff; // Blue_Send_Package.ucDataSpace[33]=(SysParaPileD.OverTempValue[0])&0xff; // Blue_Send_Package.ucDataSpace[34]=(SysParaPileD.OverTempValue[1])&0xff; // Blue_Send_Package.ucDataSpace[35]=(SysParaPileD.OverTempValue[2])&0xff; // Blue_Send_Package.ucDataSpace[36]=(SysParaPileD.QuickChargeEnable)&0xff; // Blue_Send_Package.ucDataSpace[37]=bmsProtocalType; // bmsЭÒé // Blue_Send_Package.ucDataSpace[38]=(SysParaPileD.RequirePower/10 ); //ÐèÇó¹¦ÂÊ // Blue_Send_Package.ucDataSpace[39]=(SysParaPileD.SignalLossFlag ); // ÐźŶªÊ§ // Blue_Send_Package.ucDataSpace[40]=(SysParaPileD.RequireVoltageDifference); //ÐèÇóµçѹ±Èʵ¼Ê²ÉÑù // //µçѹµÄ²î±ð // memcpy(&Blue_Send_Package.ucDataSpace[41],SysParaPileD.VehichleInfo,17); //³µÁ¾VINÉÏ´« //Blue_Send_Package.ucDataSpace[34]=((SysParaPileD.tricklepower/10)>>8)&0xff; //Blue_Send_Package.ucDataSpace[35]=((SysParaPileD.tricklecurrent/10)>>8)&0xff; printf("send heartbeat data \n\r"); Blue_Send_Package.len = 58;//41+17; DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); BluetoothInfo.connetcOvertimeFlag++; TickOut(&timer, 0); } } /********************************************************************** * @ º¯ÊýÃû £º BMS_StatusMessage * @ ¹¦ÄÜ˵Ã÷£º É豸¶¨ÆÚÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚͬ²½É豸״̬ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void BMS_StatusMessage(void) { //Êý¾Ý´ò°ü static uint32_t timer; static uint32_t heartbeat = 0; uint8_t ucComBuf[128]; uint16_t ucLen = 0; // if(TickOut(&timer, 1000)==TRUE) { Blue_Send_Package.cmd = 0x1003; // Blue_Send_Package.ucDataSpace[0]= 0; // if(g_ChargeStep == CC_CHARGE_IDLE) // Blue_Send_Package.ucDataSpace[1]=2; // else if(g_ChargeStep == CC_CHARGE_READY) // Blue_Send_Package.ucDataSpace[1]=2; // else if(g_ChargeStep == CC_CHARGE_START) // Blue_Send_Package.ucDataSpace[1]=2; // else if(g_ChargeStep == CC_CHARGE_ING) // Blue_Send_Package.ucDataSpace[1]=3; // else if(g_ChargeStep == CC_CHARGE_END) // Blue_Send_Package.ucDataSpace[1]=4; // // // if(g_ChargeStep == CC_CHARGE_IDLE) // Blue_Send_Package.ucDataSpace[2]=1; // else if(g_ChargeStep == CC_CHARGE_READY) // Blue_Send_Package.ucDataSpace[2]=1; // else if(g_ChargeStep == CC_CHARGE_START) // Blue_Send_Package.ucDataSpace[2]=3; // else if(g_ChargeStep == CC_CHARGE_ING) // Blue_Send_Package.ucDataSpace[2]=4; // else if(g_ChargeStep == CC_CHARGE_END) // Blue_Send_Package.ucDataSpace[2]=5; // Blue_Send_Package.ucDataSpace[3]=stopChargeReason; Blue_Send_Package.len =4; BluetoothInfo.connetcOvertimeFlag++; printf("send state data \n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); TickOut(&timer, 0); } } /********************************************************************** * @ º¯ÊýÃû £º BMS_StatusMessage * @ ¹¦ÄÜ˵Ã÷£º É豸¶¨ÆÚÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚͬ²½³äµç×®µÄµçѹµçÁ÷Êý¾Ý¡£ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void BMS_ChargeInfo(void)//³äµç׮״̬±¨ÎÄ { //Êý¾Ý´ò°ü static uint32_t timer; static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data = 0; // if(ServerSet_CmdFlag == 1) { Blue_Send_Package.cmd = 0x1004; // if(ServerSet_CmdFlag == 1)ServerSet_CmdFlag =0; // if(flag == 0) // { // start_soc = Bms_BatChargeRealInfo.uBatCurSOC; // flag =1; // } // Blue_Send_Package.ucDataSpace[0]=(CDZ_ChargeInfo.ChargeOutMaxVoltage/10)&0xff; // Blue_Send_Package.ucDataSpace[1]=((CDZ_ChargeInfo.ChargeOutMaxVoltage/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[2]=(CDZ_ChargeInfo.ChargeOutMinVoltage/10)&0xff; // Blue_Send_Package.ucDataSpace[3]=((CDZ_ChargeInfo.ChargeOutMinVoltage/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[4]=(CDZ_ChargeInfo.ChargeOutMaxCurrent/10)&0xff; // Blue_Send_Package.ucDataSpace[5]=((CDZ_ChargeInfo.ChargeOutMaxCurrent/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[6]=(CDZ_ChargeInfo.ChargeOutMinCurrent/10)&0xff; // Blue_Send_Package.ucDataSpace[7]=((CDZ_ChargeInfo.ChargeOutMinCurrent/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[8]=( CDZ_ChargeInfo.ChargeOutVoltage/10)&0xff; // Blue_Send_Package.ucDataSpace[9]=(( CDZ_ChargeInfo.ChargeOutVoltage/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[10]=(Bms_BatChargeRealInfo.BatRealCur/10)&0xff; // Blue_Send_Package.ucDataSpace[11]=((Bms_BatChargeRealInfo.BatRealCur/10)>>8)&0xff; // //µ±Ç°³äµçµçÁ¿ // // Blue_Send_Package.ucDataSpace[12]=((uint16_t)(CDZ_ChargeInfo.ChargeEnergyTotal))&0xff; // Blue_Send_Package.ucDataSpace[13]=(((uint16_t)(CDZ_ChargeInfo.ChargeEnergyTotal))>>8)&0xff; // //Æô¶¯Ê±soc , µ±Ç°soc // if(Bms_BatChargeRealObdBatCurSOC <= 100 && Bms_BatChargeRealObdBatCurSOC >0) // Blue_Send_Package.ucDataSpace[14]=Bms_BatChargeRealObdBatCurSOC; // else // Blue_Send_Package.ucDataSpace[14]=Bms_BatChargeRealInfo.uBatCurSOC; // Blue_Send_Package.ucDataSpace[15]=start_soc; // if((Sample_DataS.Tempreture[0]> 1)&&(Sample_DataS.Tempreture[0]<100)) // Blue_Send_Package.ucDataSpace[16]= Sample_DataS.Tempreture[0]; // else // Blue_Send_Package.ucDataSpace[16]= 0; // if((Sample_DataS.Tempreture[1] > 1)&&(Sample_DataS.Tempreture[1]<100)) // Blue_Send_Package.ucDataSpace[17]= Sample_DataS.Tempreture[1]; // else // Blue_Send_Package.ucDataSpace[17]= 0; // if((Sample_DataS.Tempreture[2] > 1)&&(Sample_DataS.Tempreture[2]<100)) // Blue_Send_Package.ucDataSpace[18]= Sample_DataS.Tempreture[2]; // else // Blue_Send_Package.ucDataSpace[18]= 0; // //Blue_Send_Package.ucDataSpace[16]=Sample_DataS.Tempreture[0]; // //Blue_Send_Package.ucDataSpace[17]=Sample_DataS.Tempreture[1]; // //Blue_Send_Package.ucDataSpace[18]=Sample_DataS.Tempreture[2]; // Blue_Send_Package.ucDataSpace[19]= (SysParaPileD.BmsMaxVolt/10)&0xff; // Blue_Send_Package.ucDataSpace[20]= ((SysParaPileD.BmsMaxVolt/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[21]=(SysParaPileD.BmsMaxCurrent/10)&0xff; // Blue_Send_Package.ucDataSpace[22]= ((SysParaPileD.BmsMaxCurrent/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[23]=(SysParaPileD.BmRequireVolt/10) &0xff; // Blue_Send_Package.ucDataSpace[24]= ((SysParaPileD.BmRequireVolt/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[25]=(SysParaPileD.BmsRequireCurrent/10) &0xff; // Blue_Send_Package.ucDataSpace[26]= ((SysParaPileD.BmsRequireCurrent/10)>>8)&0xff; // Blue_Send_Package.ucDataSpace[27]= Bms_BatChargeRealInfo.contactorState; // // Blue_Send_Package.ucDataSpace[28]= CDZ_ChargeInfo.ChargeTimeTotal &0xff; //³äµçʱ¼ä // Blue_Send_Package.ucDataSpace[29]= ((CDZ_ChargeInfo.ChargeTimeTotal)>>8)&0xff; //³äµçʱ¼ä // //// if( CDZ_ChargeInfo.ChargeTime >60) //// { //// Blue_Send_Package.ucDataSpace[28]= CDZ_ChargeInfo.ChargeTime &0xff; //³äµçʱ¼ä //// Blue_Send_Package.ucDataSpace[29]= ((CDZ_ChargeInfo.ChargeTime)>>8)&0xff; //³äµçʱ¼ä //// } //// else //// { //// Blue_Send_Package.ucDataSpace[28]= ChargeRecordInfo.chargingtime &0xff; //³äµçʱ¼ä //// Blue_Send_Package.ucDataSpace[29]= ((ChargeRecordInfo.chargingtime)>>8)&0xff; //³äµçʱ¼ä //// } // if(WuLingBatteryInfo.bms29A.bits.BatTalVolSm > 400) // data = WuLingBatteryInfo.bms29A.bits.BatTalVolSm; // ͨÐŵĵçѹ»òÕßDCDCÊä³öµçѹ // else // { // // if(ModuleInfo.state == POWER_ON) // { // data = ModuleInfo.current_volt; // ͨÐŵĵçѹ»òÕßDCDCÊä³öµçѹ // } // else // data = ModuleInfo.sample_bat_volt; // } // Blue_Send_Package.ucDataSpace[30]=(data/10)&0xff; // Blue_Send_Package.ucDataSpace[31]=((data/10)>>8)&0xff; Blue_Send_Package.len =32; BluetoothInfo.connetcOvertimeFlag++; printf("send Charge data\n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); TickOut(&timer, 0); } } /********************************************************************** * @ º¯ÊýÃû £º BMS_SetDataAck * @ ¹¦ÄÜ˵Ã÷£º É豸µÇÓ¦´ðÄÚÈÝ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void BMS_SetDataAck(void) { //Êý¾Ý´ò°ü static uint32_t timer; static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[64]; uint16_t ucLen = 0; Blue_Send_Package.cmd = 0x1005; // Blue_Send_Package.ucDataSpace[17]=Sample_DataS.Tempreture[1]; // Blue_Send_Package.ucDataSpace[18]=Sample_DataS.Tempreture[2]; Blue_Send_Package.len =19; BluetoothInfo.connetcOvertimeFlag++; DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } /********************************************************************** * @ º¯ÊýÃû £º Bluetooth_chargeRecord * @ ¹¦ÄÜ˵Ã÷£º É豸µÇ¼ʱÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚУÑé×¢²áÂëºÍͬ²½¹Ì¼þ°æ±¾ºÅ¡£ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void Bluetooth_chargeRecord(void) { uint8_t i = 0; uint8_t ucComBuf[128]; uint16_t ucLen = 0; if(SysParaPileD.Recordindex < RECORD_NUM) { Blue_Send_Package.cmd = 0x1006; Blue_Send_Package.ucDataSpace[0]=SysParaPileD.Recordindex; for(i=0;i>8); Blue_Send_Package.ucDataSpace[2]=ModuleInfo.current_curr; Blue_Send_Package.ucDataSpace[3]=(ModuleInfo.current_curr)>>8; Blue_Send_Package.ucDataSpace[4]=power&0xff; Blue_Send_Package.ucDataSpace[5]=(ModuleInfo.Inductance_Temp) ; Blue_Send_Package.ucDataSpace[6]=(ModuleInfo.Modul_Temp); Blue_Send_Package.ucDataSpace[7]=32; Blue_Send_Package.ucDataSpace[8]=95; Blue_Send_Package.ucDataSpace[9]=ModuleInfo.state; Blue_Send_Package.ucDataSpace[10]=ModuleInfo.faultcode&0xff; Blue_Send_Package.ucDataSpace[11]=(ModuleInfo.faultcode)>>8; Blue_Send_Package.ucDataSpace[12]=ModuleInfo.state; Blue_Send_Package.ucDataSpace[13]=(u8)(ModuleInfo.target_volt); Blue_Send_Package.ucDataSpace[14]=(u8)((ModuleInfo.target_volt)>>8); Blue_Send_Package.ucDataSpace[15]=ModuleInfo.target_curr; Blue_Send_Package.ucDataSpace[16]=(ModuleInfo.target_curr)>>8; Blue_Send_Package.ucDataSpace[17]=(u8)(ModuleInfo.over_volt); Blue_Send_Package.ucDataSpace[18]=(u8)((ModuleInfo.over_volt)>>8); Blue_Send_Package.ucDataSpace[19]=ModuleInfo.over_curr; Blue_Send_Package.ucDataSpace[20]=(ModuleInfo.over_curr)>>8; Blue_Send_Package.ucDataSpace[21]=(ModuleInfo.max_power); Blue_Send_Package.ucDataSpace[22]=(ModuleInfo.currentadjust); Blue_Send_Package.ucDataSpace[23]=(ModuleInfo.currentadjust>>8)&0xff; Blue_Send_Package.ucDataSpace[24]=(ModuleInfo.temp3); Blue_Send_Package.ucDataSpace[25]=(ModuleInfo.temp4); printf("send DCDC data\n\r"); Blue_Send_Package.len = 26;//41+17; DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); BluetoothInfo.connetcOvertimeFlag++; TickOut(&timer, 0); } } /********************************************************************** * @ º¯ÊýÃû £º BMS_VersionInfo * @ ¹¦ÄÜ˵Ã÷£º É豸¶¨ÆÚÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚͬ²½µç³Ø°æ±¾Êý¾Ý * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void BMS_VersionInfo(void)//µç³Ø°æ±¾ÐÅÏ¢ { static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data = 0; Blue_Send_Package.cmd = 0x1008; memcpy(bluebms_datainfo.BatManuSpecCode,"S201",sizeof(bluebms_datainfo.BatManuSpecCode)); memcpy(bluebms_datainfo.BatManuversionNo,"WLING",sizeof(bluebms_datainfo.BatManuversionNo)); memcpy(&Blue_Send_Package.ucDataSpace[0],bluebms_datainfo.BatManuSpecCode,sizeof(bluebms_datainfo.BatManuSpecCode)); memcpy(&Blue_Send_Package.ucDataSpace[4],bluebms_datainfo.BatManuversionNo,sizeof(bluebms_datainfo.BatManuversionNo)); //0x0: 2kwOBC 0x1:3.3kwOBC 0x2:6.6kwOBC 0x3:2kwOBC+1.5kwDC/DC //0x4: 6.6kwOBC+1.5kwDC/DC 0x5: 6.6kwOBC+1.5kwDC/DC+2kwDC/AC 0x6: 6.6kwOBC+1.5kwDC/DC+PDU //0x7: 6.6kwOBC+2kwDC/DC+PDU 0x8: 6.6kwOBC+1.5kwDC/DC+2kwDC/AC+PDU //0x9: 1.5kwOBC+0.8kwDC/DC++PDU 0xA: 2kwOBC+1kwDC/DC++PDU" // bluebms_datainfo.CDUType = WuLingBatteryInfo.bms5C1.bits.CDUType; // // bluebms_datainfo.VehOdo = WuLingBatteryInfo.bms120.bits.VehOdo; Blue_Send_Package.ucDataSpace[8]=(bluebms_datainfo.VehOdo)&0xff; Blue_Send_Package.ucDataSpace[9]=(bluebms_datainfo.VehOdo>>8)&0xff; Blue_Send_Package.ucDataSpace[10]=(bluebms_datainfo.VehOdo>>16)&0xff; Blue_Send_Package.ucDataSpace[11]=(bluebms_datainfo.VehOdo>>24)&0xff; //µ±Ç°³äµçµçÁ¿ Blue_Send_Package.ucDataSpace[12]= bluebms_datainfo.CDUType; Blue_Send_Package.len =13; BluetoothInfo.connetcOvertimeFlag++; printf("send bms version\n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } /********************************************************************** * @ º¯ÊýÃû £º BMS_VersionInfo * @ ¹¦ÄÜ˵Ã÷£º É豸¶¨ÆÚÏòС³ÌÐòÉϱ¨Êý¾Ý£¬ÓÃÓÚͬ²½µç³Ø³äµçÊý¾Ý¡£ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void BMS_ChargingDataInfo(void)//µç³Ø³äµç״̬ÐÅÏ¢ { static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data = 0; Blue_Send_Package.cmd = 0x1009; // bluebms_datainfo.BatEnrgRated = WuLingBatteryInfo.bms5D6.bits.RatedEgy/10; // bluebms_datainfo.BatVolRated = WuLingBatteryInfo.bms5D6.bits.RatedVol; // bluebms_datainfo.ChrgVolRqst = WuLingBatteryInfo.bms284.bits.bmsChrgVolRqst; // bluebms_datainfo.ChrgCurRqst = WuLingBatteryInfo.maxchargcur; // bluebms_datainfo.BatIslatRes = WuLingBatteryInfo.bms287.bits.BatIslatRes; // bluebms_datainfo.BatSOC = WuLingBatteryInfo.bms297.bits.BatSOC; // bluebms_datainfo.BatSOH = WuLingBatteryInfo.bms297.bits.BatSOH; // bluebms_datainfo.BatEnrgAvail = WuLingBatteryInfo.bms297.bits.BatEnrgAvail;; // bluebms_datainfo.BatChrgTims= WuLingBatteryInfo.bms297.bits.BatChrgTims;; // bluebms_datainfo.BatPlsChrgPowAvail = WuLingBatteryInfo.bms28B.bits.Bat10sPlsChrgPowAvail/10; // bluebms_datainfo.BatPlsDischrgPowAvail = WuLingBatteryInfo.bms28B.bits.Bat10sPlsDischrgPowAvail/10; // Blue_Send_Package.ucDataSpace[0]= (bluebms_datainfo.ChrgVolRqst); // Blue_Send_Package.ucDataSpace[1]= ((bluebms_datainfo.ChrgVolRqst)>>8); // Blue_Send_Package.ucDataSpace[2]= bluebms_datainfo.ChrgCurRqst; // Blue_Send_Package.ucDataSpace[3]= (bluebms_datainfo.ChrgCurRqst)>>8; // Blue_Send_Package.ucDataSpace[4]= bluebms_datainfo.BatIslatRes; // Blue_Send_Package.ucDataSpace[5]= bluebms_datainfo.BatIslatRes>>8; // Blue_Send_Package.ucDataSpace[6]= (bluebms_datainfo.BatSOC); // Blue_Send_Package.ucDataSpace[7]= bluebms_datainfo.BatSOH; // Blue_Send_Package.ucDataSpace[8]= bluebms_datainfo.BatEnrgAvail&0xff; // Blue_Send_Package.ucDataSpace[9]= (bluebms_datainfo.BatEnrgAvail>>8)&0xff; // Blue_Send_Package.ucDataSpace[10]= bluebms_datainfo.BatEnrgRated&0xff; // Blue_Send_Package.ucDataSpace[11]= (bluebms_datainfo.BatEnrgRated>>8)&0xff; // Blue_Send_Package.ucDataSpace[12]= bluebms_datainfo.BatChrgTims&0xff; // Blue_Send_Package.ucDataSpace[13]= (bluebms_datainfo.BatChrgTims>>8)&0xff; // Blue_Send_Package.ucDataSpace[14]= bluebms_datainfo.BatPlsChrgPowAvail&0xff; // Blue_Send_Package.ucDataSpace[15]= (bluebms_datainfo.BatPlsDischrgPowAvail)&0xff; // Blue_Send_Package.ucDataSpace[16]= bluebms_datainfo.BatVolRated&0xff; // Blue_Send_Package.ucDataSpace[17]= (bluebms_datainfo.BatVolRated>>8)&0xff; Blue_Send_Package.len =18; BluetoothInfo.connetcOvertimeFlag++; printf("Send ChargingData \n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } /********************************************************************** * @ º¯ÊýÃû £º BMS_VersionInfo * @ ¹¦ÄÜ˵Ã÷£º µ¥½Úµç³ØζÈÐÅÏ¢ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void bat_temp_Info(void)//µ¥½Úµç³ØζÈÐÅÏ¢ { static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data,i = 0; Blue_Send_Package.cmd = 0x100A; // for(i=0;i<40;i++) // { // bluebms_datainfo.cellbat_data[i].Celltemp = 0xff; // } // for(i=0;i<8;i++) // { // bluebms_datainfo.cellbat_data[i].Celltemp = WuLingBatteryInfo.bms5C6.BatCelTemp1[i]+40; // } // for(i=0;i<8;i++) // { // bluebms_datainfo.cellbat_data[i+8].Celltemp = WuLingBatteryInfo.bms5C7.BatCelTemp9[i]+40; // } // for(i=0;i<8;i++) // { // bluebms_datainfo.cellbat_data[i+16].Celltemp = WuLingBatteryInfo.bms5C8.BatCelTemp17[i]+40; // } for(i=0;i<40;i++) { // bluebms_datainfo.cellbat_data[i].Celltemp = 65; Blue_Send_Package.ucDataSpace[i]= (bluebms_datainfo.cellbat_data[i].Celltemp); } Blue_Send_Package.len =40; BluetoothInfo.connetcOvertimeFlag++; printf("Send cell temp \n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } /********************************************************************** * @ º¯ÊýÃû £º BMS_VersionInfo * @ ¹¦ÄÜ˵Ã÷£º µ¥½Úµç³ØµçѹÐÅÏ¢ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void bat_Cell_Vol_Info(void)// { static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data,i = 0; Blue_Send_Package.cmd = 0x100B; for(i=0;i<40;i++) { // bluebms_datainfo.cellbat_data[i].BattCellVoltage = 3329; // bluebms_datainfo.cellbat_data[i].BattCellVoltage = WuLingBatteryInfo.cell_batt_info[i].bits.BattCellVoltage; // Blue_Send_Package.ucDataSpace[i*2]= (bluebms_datainfo.cellbat_data[i].BattCellVoltage&0xff); // Blue_Send_Package.ucDataSpace[i*2+1]= (bluebms_datainfo.cellbat_data[i].BattCellVoltage>>8)&0xff; } Blue_Send_Package.len =80; BluetoothInfo.connetcOvertimeFlag++; printf("Send cell temp \n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } /********************************************************************** * @ º¯ÊýÃû £º BMS_VersionInfo * @ ¹¦ÄÜ˵Ã÷£º µç³Ø¹ÊÕÏ״̬ * @ ²ÎÊý £º * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void bat_state_code(void)//µç³ØÐøµçÆ÷״̬ { static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data,i = 0; Blue_Send_Package.cmd = 0x100C; // bluebms_datainfo.bms_state_info.bits.BatMaNegRlySts = WuLingBatteryInfo.bms295.bits.BatMaNegRlySts; // bluebms_datainfo.bms_state_info.bits.BatMaPosRlySts = WuLingBatteryInfo.bms295.bits.BatMaPosRlySts; // bluebms_datainfo.bms_state_info.bits.BatPrechrgRlySts = WuLingBatteryInfo.bms295.bits.BatPrechrgRlySts; // bluebms_datainfo.bms_state_info.bits.BatHvIntlkSts = WuLingBatteryInfo.bms295.bits.BatHvIntlkSts; // bluebms_datainfo.bms_state_info.bits.BatFuSts = WuLingBatteryInfo.bms295.bits.BatFuSts; // bluebms_datainfo.bms_state_info.bits.BatHeRlySts = WuLingBatteryInfo.bms295.bits.BatHeRlySts; // bluebms_datainfo.bms_state_info.bits.BatHeSts = WuLingBatteryInfo.bms295.bits.BatHeSts; // bluebms_datainfo.bms_state_info.bits.Prechrgsts = WuLingBatteryInfo.bms295.bits.Prechrgsts; // bluebms_datainfo.bms_state_info.bits.Batfaultnum = WuLingBatteryInfo.bms289.BatOthFltNum; // bluebms_datainfo.bms_state_info.bits.BatTalVolSts = WuLingBatteryInfo.bms289.BatOthFltList; // bluebms_datainfo.bms_state_info.bits.BatAvgCelVolSts = WuLingBatteryInfo.bms29E.bits.BatAvgCelVolSts; // bluebms_datainfo.bms_state_info.bits.BatAvgTolVolSts = WuLingBatteryInfo.bms29E.bits.BatTalVolSts; // bluebms_datainfo.bms_state_info.bits.BatChrgCurSts = WuLingBatteryInfo.bms29E.bits.BatChrgCurSts; //// bluebms_datainfo.bms_state_info.bits.BatDischrgCurSts = WuLingBatteryInfo.bms29E.bits.BatDischrgCurSts; // bluebms_datainfo.bms_state_info.bits.BatIslateSts = WuLingBatteryInfo.bms29E.bits.BatIslateSts; // bluebms_datainfo.bms_state_info.bits.BatInCANBsErrFlt = WuLingBatteryInfo.bms29E.bits.BatInCANBsErrFlt; // bluebms_datainfo.bms_state_info.bits.BatTempSensFlt = WuLingBatteryInfo.bms29E.bits.BatTempSensFlt; // bluebms_datainfo.bms_state_info.bits.BatCurSensFlt = WuLingBatteryInfo.bms29E.bits.BatCurSensFlt; // bluebms_datainfo.bms_state_info.bits.BatCelVolSensFlt = WuLingBatteryInfo.bms29E.bits.BatCelVolSensFlt; // bluebms_datainfo.bms_state_info.bits.BalanceSts = WuLingBatteryInfo.bms29E.bits.BalanceSts; for(i=0;i<8;i++) { Blue_Send_Package.ucDataSpace[i]= bluebms_datainfo.bms_state_info.stats[i]; } Blue_Send_Package.len =8; BluetoothInfo.connetcOvertimeFlag++; printf("send bms_state_info\n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } void BMS_UpdataACKInfo(void) { //Êý¾Ý´ò°ü static uint32_t timer; static uint32_t flag = 0; static uint8_t start_soc = 0; uint8_t ucComBuf[128]; uint16_t ucLen,data = 0; Blue_Send_Package.cmd = 0x1020; Blue_Send_Package.ucDataSpace[0]=0x55; Blue_Send_Package.ucDataSpace[1]=0xaa; Blue_Send_Package.len =2; BluetoothInfo.connetcOvertimeFlag++; printf("OTA ACK \n\r"); DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); debugdataprocess(&Blue_Send_Package.ucDataSpace[0],2); } /********************************************************************** * @ º¯ÊýÃû £º UpdataDebugInfoToServer * @ ¹¦ÄÜ˵Ã÷£º µ÷ÊÔÐÅÏ¢±¨ÎÄ * @ ²ÎÊý £º dataÊý¾Ý len×Ö½Ú * @ ·µ»ØÖµ £º ÎÞ ********************************************************************/ void UpdataDebugInfoToServer(uint8_t *data,uint8_t len) { uint8_t ucComBuf[255]; uint16_t ucLen,i = 0; Blue_Send_Package.cmd = 0x100D; memcpy(Blue_Send_Package.ucDataSpace,data,len); Blue_Send_Package.len = len; DP_PackageWriteDataFrame(&Blue_Send_Package, ucComBuf, &ucLen); } #endif