From: QQY <979527038@qq.com> Date: Thu, 31 Aug 2023 02:19:44 +0000 (+0800) Subject: 1.新增modbusrtc,读写寄存器数据需求功能. X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=92ac5329113a0a004e841a0c6c597d6fb7846818;p=zd%2Fzd-mcu.git 1.新增modbusrtc,读写寄存器数据需求功能. 2.max31865-gpio引脚替换 --- diff --git a/STM32/code/MAX31865/max31865.c b/STM32/code/MAX31865/max31865.c index f099fd18..a9a421e4 100644 --- a/STM32/code/MAX31865/max31865.c +++ b/STM32/code/MAX31865/max31865.c @@ -1,21 +1,38 @@ #include "tim.h" +#include "App_para.h" #include "max31865.h" #include "usart.h" #include #include +#include #include #include float pt100_temp[Pt100_MAX]; +#if 1 +static const Pt100_Cs_t Pt100_Cs[] = +{ + // Êä³öÒý½Å + {GPIOB, GPIO_PIN_14}, + {GPIOB, GPIO_PIN_15}, + {GPIOE, GPIO_PIN_14}, + {GPIOE, GPIO_PIN_15}, +}; + +#else + static const Pt100_Cs_t Pt100_Cs[] = { // Êä³öÒý½Å {GPIOD, GPIO_PIN_11}, {GPIOD, GPIO_PIN_13}, - {GPIOD, GPIO_PIN_15}, - {GPIOA, GPIO_PIN_8 }, + {GPIOA, GPIO_PIN_8 }, + {GPIOD, GPIO_PIN_15}, + }; +#endif + void Max_Pt100_Cs(uint8_t io, uint8_t value) { @@ -33,26 +50,26 @@ void MAX31865_SPI_Init(void) __HAL_RCC_GPIOA_CLK_ENABLE(); //CSÒý½Å³õʼ»¯ - GPIO_InitStructure.Pin = GPIO_PIN_11|GPIO_PIN_13|GPIO_PIN_15; + GPIO_InitStructure.Pin = GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP ; //ÍÆÍìÊä³ö GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); + HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); - GPIO_InitStructure.Pin = GPIO_PIN_8; + GPIO_InitStructure.Pin = GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP ; //ÍÆÍìÊä³ö GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); + HAL_GPIO_Init(GPIOE, &GPIO_InitStructure); //SCKºÍMOSIÒý½Å³õʼ»¯ - GPIO_InitStructure.Pin = GPIO_PIN_10|GPIO_PIN_14; + GPIO_InitStructure.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP ; //ÍÆÍìÊä³ö GPIO_InitStructure.Pull = GPIO_PULLUP; GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); + HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); //MISOÒý½Å³õʼ»¯ - GPIO_InitStructure.Pin = GPIO_PIN_12; + GPIO_InitStructure.Pin = GPIO_PIN_13; GPIO_InitStructure.Mode = GPIO_MODE_INPUT ; //¸¡¿ÕÊäÈë - HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); + HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); for(int i = 0; i < Pt100_MAX; i++) { @@ -61,6 +78,7 @@ void MAX31865_SPI_Init(void) SCK_H; } + //SPI¿ÉÒÔͬʱ¶ÁÈ¡ºÍдÈëÊý¾Ý£¬Òò´ËÒ»¸öº¯Êý¼´¿ÉÂú×ãÒªÇó uint8_t SPI_ReadWriteByte(uint8_t txData) { @@ -70,7 +88,7 @@ uint8_t SPI_ReadWriteByte(uint8_t txData) for(i = 0; i < 8; i++) { SCK_L; - delayus(5); + delayus(TIMING_INV); //Êý¾Ý·¢ËÍ if(txData & 0x80){ MOSI_H; @@ -78,16 +96,16 @@ uint8_t SPI_ReadWriteByte(uint8_t txData) MOSI_L; } txData <<= 1; - delayus(5); + delayus(TIMING_INV); SCK_H; - delayus(5); + delayus(TIMING_INV); //Êý¾Ý½ÓÊÕ rxData <<= 1; if(SPI_READ_MISO){ rxData |= 0x01; } - delayus(5); + delayus(TIMING_INV); } return rxData; @@ -122,35 +140,37 @@ void MAX31865_Config(uint8_t addr, uint8_t data) } } + uint16_t Max31865_ReadTemp(uint8_t ch) { - uint16_t data; - delayus(65); + + HAL_Delay(66); Max_Pt100_Cs(ch,0); - delayus(5); + delayus(2); SPI_ReadWriteByte(TEMP_ADDR_H); data = SPI_ReadWriteByte(TEMP_ADDR_H); data <<=8; - delayus(5); + delayus(2); Max_Pt100_Cs(ch,1); - delayus(20); + + delayus(2); Max_Pt100_Cs(ch,0); - delayus(5); + delayus(2); SPI_ReadWriteByte(TEMP_ADDR_L); data |= SPI_ReadWriteByte(TEMP_ADDR_L); - delayus(5); + delayus(2); Max_Pt100_Cs(ch,1); - data >>= 1; + + data >>= 1; return data; } -float Get_MAX31865Data(uint8_t ch) +int Get_MAX31865Temp(uint8_t ch,float *p) { - float Z1, Z2, Z3, Z4,Rt, temp; - + float error; Rt = Max31865_ReadTemp(ch); Rt /= 32768; Rt *= RREF; @@ -162,39 +182,301 @@ float Get_MAX31865Data(uint8_t ch) temp = Z2 + ( Z3 * Rt ); temp = ( (float)sqrt ( (double)temp ) +Z1 ) / Z4; + if(chipflashpara.PT100_Coefficient_para.flag[ch] == true) + { + temp -= chipflashpara.PT100_Coefficient_para.PT100[ch]; + } + else + { + temp += chipflashpara.PT100_Coefficient_para.PT100[ch]; + } + error = abs(temp - *p); + if(temp >= 241 || temp <= -31) + { + return 0; + } + else if(error >= 30) + { + return 0; + } + *p = temp; + return 1; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* +2023_0620 +re-write max31865 driver for: +1.none-block access. +2.doing all max31865 init and convert(one shot trig) simultaneously. +3.new way reg read&write. +4.add test function in init to check Hw health. +5.manual init max31865 in beginning. +*/ + +static uint8_t readReg(uint8_t ch, uint8_t reg) +{ + uint8_t data = 0; + Max_Pt100_Cs(ch,0); + delayus(TIMING_CS_INV); + + SPI_ReadWriteByte(reg&0x7F); + data = SPI_ReadWriteByte(0xFF); + delayus(TIMING_CS_INV); + Max_Pt100_Cs(ch,1); + //delayus(TIMING_CS_INV); + return data; +} + +static void writeReg(uint8_t ch, uint8_t reg, uint8_t data) +{ + uint8_t val = 0; + Max_Pt100_Cs(ch,0); + delayus(TIMING_CS_INV); + + SPI_ReadWriteByte(reg|0x80); + val = SPI_ReadWriteByte(data); + + delayus(TIMING_CS_INV); + Max_Pt100_Cs(ch,1); + //delayus(TIMING_CS_INV); + (void)val;//for warnning. +} + + +void MAX31865_Init(void) +{ + uint8_t val = 0; + uint8_t ch = 0; + + for (ch = 0; ch < Pt100_MAX; ch++) + { + Max_Pt100_Cs(ch,1); + } + + //test config reg read and wirte function for testing Hw and wire +#if 0 + + Max_Pt100_Cs(0,0); + Max_Pt100_Cs(0,1); + + Max_Pt100_Cs(1,0); + Max_Pt100_Cs(1,1); + + Max_Pt100_Cs(2,0); + Max_Pt100_Cs(2,1); + + Max_Pt100_Cs(3,0); + Max_Pt100_Cs(3,1); + + +static uint8_t p_config_val0[255] = {0}; +static uint8_t p_config_val1[255] = {0}; +static uint8_t p_config_val2[255] = {0}; +static uint8_t p_config_val3[255] = {0}; +extern void Task_Iwdg_feed(void); + + uint8_t idx = 0; + ch = 0; + //for(idx = 0; idx<0xFE; idx++) + for(idx = 0; idx<0x10; idx++) + { + Task_Iwdg_feed(); + writeReg(ch, CONFIG_REG_W, idx); + p_config_val0[idx] = readReg(ch, CONFIG_REG_R); + } + + ch = 1; + //for(idx = 0; idx<0xFE; idx++) + for(idx = 0; idx<0x10; idx++) + { + Task_Iwdg_feed(); + writeReg(ch, CONFIG_REG_W, idx); + p_config_val1[idx] = readReg(ch, CONFIG_REG_R); + } + + ch = 2; + //for(idx = 0; idx<0xFE; idx++) + for(idx = 0; idx<0x10; idx++) + { + Task_Iwdg_feed(); + writeReg(ch, CONFIG_REG_W, idx); + p_config_val2[idx] = readReg(ch, CONFIG_REG_R); + } + + ch = 3; + //for(idx = 0; idx<0xFE; idx++) + for(idx = 0; idx<0x10; idx++) + { + Task_Iwdg_feed(); + writeReg(ch, CONFIG_REG_W, idx); + p_config_val3[idx] = readReg(ch, CONFIG_REG_R); + } + + + for (ch = 0; ch < Pt100_MAX; ch++) + { + writeReg(ch, CONFIG_REG_W, 0); + } +#endif + + for (ch = 0; ch < Pt100_MAX; ch++) + { + val = readReg(ch, CONFIG_REG_R); + val |= CONFIG_3WIRE; //set 3 wire + val |= CONFIG_BIAS;//enable bias + val &= 0xBF;//disable auto convert + val |= 0x03;//clear fault,and set 50Hz filter + writeReg(ch, CONFIG_REG_W, val); + //read back check(optional) + val = readReg(ch, CONFIG_REG_R);//bit1 read back always 0(cleared) + } + + HAL_Delay(11);//10ms for bias stable + +} + + + +void MAX31865_S1_Trig_1Shot(void) +{ + uint8_t ch = 0; + uint8_t val = 0; + for(ch = 0; ch < Pt100_MAX; ch++) + { + //clear fault by read + readReg(ch, FAULTSTAT_REG_R); - return temp; + //step 2: set 1 shot trig + val = readReg(ch, CONFIG_REG_R); + val |= CONFIG_1SHOT; + writeReg(ch, CONFIG_REG_W, val); + } + + // after trig, host mcu need 65ms at least, to aquire ADC data + // HAL_Delay(64); //in super while(1) system + // osDelay(64); //in os. } -float Get_MAX31865Temp(uint8_t ch) -{ - int filter_buf[FILTER_N]; - int i, j; - int filter_temp; - for(i = 0; i < FILTER_N; i++) - { - filter_buf[i] = Get_MAX31865Data(ch); - } - // ²ÉÑùÖµ´ÓСµ½´óÅÅÁУ¨Ã°ÅÝ·¨£© - for(j = 0; j < FILTER_N - 1; j++) - { - for(i = 0; i < FILTER_N - 1 - j; i++) - { - if(filter_buf[i] > filter_buf[i + 1]) - { - filter_temp = filter_buf[i]; - filter_buf[i] = filter_buf[i + 1]; - filter_buf[i + 1] = filter_temp; - } - } - } - return filter_buf[(FILTER_N - 1) / 2]; +static uint16_t p_val_rt[Pt100_MAX] = {0}; +void MAX31865_S2_ReadRT(void) +{ + uint8_t ch = 0; + + for(ch = 0; ch < Pt100_MAX; ch++) + { + p_val_rt[ch] = readReg(ch, TEMP_ADDR_H); + p_val_rt[ch] <<= 8; + p_val_rt[ch] |= readReg(ch, TEMP_ADDR_L); + p_val_rt[ch] >>= 1; + } } +int MAX31865_S3_ReadTemp(uint8_t ch, float *p) +{ + float Z1, Z2, Z3, Z4,Rt, temp; +// float error; + Rt = p_val_rt[ch]; + Rt /= 32768; + Rt *= RREF; + Z1 = -RTD_A; + Z2 = RTD_A * RTD_A - ( 4 * RTD_B ); + Z3 = ( 4 * RTD_B ) / RTD_NOMINAL; + Z4 = 2 * RTD_B; + + temp = Z2 + ( Z3 * Rt ); + temp = ( (float)sqrt ( (double)temp ) +Z1 ) / Z4; +// if(chipflashpara.PT100_Coefficient_para.flag[ch] == true) +// { +// temp -= chipflashpara.PT100_Coefficient_para.PT100[ch]; +// } +// else +// { +// temp += chipflashpara.PT100_Coefficient_para.PT100[ch]; +// } +// error = abs(temp - *p); +// if(temp >= 241 || temp <= -31) +// { +// return 0; +// } +// else if(error >= 30) +// { +// return 0; +// } + *p = temp; + return 1; +} +void MAX31865_S4_Fsm(void) +{ + static uint32_t tExtAdcTrigCnt = 0; + static uint32_t tExtAdcAquireCnt = 0; + static uint8_t tExtAdcTrigFlag = 0; + uint32_t now = HAL_GetTick(); + + if( (now - tExtAdcTrigCnt) < 100 ) + { + //trig max31865 100ms per time + if(tExtAdcTrigFlag == 0) + { + //one shot trig + MAX31865_S1_Trig_1Shot(); + tExtAdcTrigFlag = 1; + } + } + else + { + tExtAdcTrigCnt = now; + } + + if( (now - tExtAdcAquireCnt) > 200 ) + { + tExtAdcAquireCnt = now; + if(tExtAdcTrigFlag == 1) + { + // read temperature + MAX31865_S2_ReadRT(); + tExtAdcTrigCnt = now; + //reset trig flag , perpare next trig + tExtAdcTrigFlag = 0; + } + } +} diff --git a/STM32/code/MAX31865/max31865.h b/STM32/code/MAX31865/max31865.h index b14c0a15..669e552c 100644 --- a/STM32/code/MAX31865/max31865.h +++ b/STM32/code/MAX31865/max31865.h @@ -16,14 +16,23 @@ typedef struct #define RREF 430.0 #define RTD_NOMINAL 100 -#define SCK_H HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14,GPIO_PIN_SET) /* SCK = 1 */ -#define SCK_L HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14,GPIO_PIN_RESET) /* SCK = 0 */ +#define SCK_H HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11,GPIO_PIN_SET) /* SCK = 1 */ +#define SCK_L HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11,GPIO_PIN_RESET) /* SCK = 0 */ -#define MOSI_H HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10,GPIO_PIN_SET) /* MOSI = 1 */ -#define MOSI_L HAL_GPIO_WritePin(GPIOD, GPIO_PIN_10,GPIO_PIN_RESET) /* MOSI = 0 */ +#define MOSI_H HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_SET) /* MOSI = 1 */ +#define MOSI_L HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_RESET) /* MOSI = 0 */ -#define SPI_READ_MISO HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_12) /* ¶ÁMISO¿ÚÏß״̬ */ +#define SPI_READ_MISO HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13) /* ¶ÁMISO¿ÚÏß״̬ */ +#define MIOS_H HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13,GPIO_PIN_SET) /* MOSI = 1 */ +#define MIOS_L HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13,GPIO_PIN_RESET) /* MOSI = 0 */ + +#define FAULTSTAT_REG_R 0x07 //FAULT +#define CONFIG_REG_W 0x80 //WRITE CONFIG +#define CONFIG_REG_R 0x00 //READ CONFIG +#define CONFIG_3WIRE 0x10 //3 WIRE +#define CONFIG_BIAS 0x80 //BIAS +#define CONFIG_1SHOT 0x20 //ONE SHOT #define CONFIG_ADDR 0X80 //ÅäÖüĴæÆ÷µØÖ· #define THREE_WIRE 0xD0 //ÅäÖÃÈýÏßÖÆ @@ -32,7 +41,11 @@ typedef struct #define Dummy_Byte 0xFF //¶ÁȡʱMISO·¢Ë͵ÄÊý¾Ý£¬¿ÉÒÔΪÈÎÒâÊý¾Ý -#define FILTER_N 11 +#define FILTER_N 10 + +#define TIMING_INV 1//0//4// +#define TIMING_CS_INV 1//2//4//2 + enum { Pt100_A = 0, @@ -43,12 +56,20 @@ enum }; void MAX31865_SPI_Init(void); -float Get_MAX31865Temp(uint8_t ch); +int Get_MAX31865Temp(uint8_t ch,float *p); uint8_t SPI_ReadByte(void); uint16_t Max31865_ReadTemp(uint8_t ch); void SPI_WriteByte(uint8_t txData); uint8_t SPI_ReadWriteByte(uint8_t txData); void MAX31865_Config(uint8_t addr, uint8_t data); + + + +void MAX31865_Init(void); +void MAX31865_S1_Trig_1Shot(void); +void MAX31865_S2_ReadRT(void); +int MAX31865_S3_ReadTemp(uint8_t ch, float *p); +void MAX31865_S4_Fsm(void); #endif diff --git a/STM32/code/app/App_ADC.c b/STM32/code/app/App_ADC.c index 012eae98..07ec2b6c 100644 --- a/STM32/code/app/App_ADC.c +++ b/STM32/code/app/App_ADC.c @@ -16,7 +16,7 @@ ADCת #include "runflag.h" #include "alarm.h" #include "mcu_com.h" - +#include "Get_EquipmentData.h" /* PT100Ó²¼þ״̬ */ BOOL PT100_Hard_state[PT100_CH_MAx]; /* °´bit±êÖ¾µÄPT100̽ͷӲ¼þ״̬ */ @@ -124,17 +124,20 @@ static void _Check_PT100_Hard() Mcu_to_Arm_state.sensor_self_test |=(1<<6); continue; } - temp = Get_MAX31865Temp(i); + //Get_MAX31865Temp(i,&temp); + MAX31865_S3_ReadTemp(i,&temp); if((temp > ADC_PT100x16_LIMIT_MAX)||(temp < ADC_PT100x16_LIMIT_MIN)) { PT100_Hard_state[i] = PT100_Hard_BAD; byVal |= (1 << i); Mcu_to_Arm_state.sensor_self_test&=~(1<<(3+i)); + Md_RegisterData.State_Register1 &=~(1<<7+i); } else { PT100_Hard_state[i] = PT100_HARD_GOOD; Mcu_to_Arm_state.sensor_self_test |=(1<<(3+i)); + Md_RegisterData.State_Register1 |=(1<<7+i); } } if(byVal != TCCheckStatus) @@ -169,23 +172,19 @@ static void _Conv_ADC_PT100_To_Temperture() // SHORT temp; for(i=0;i AC_SUPPLY_THRESHOLD) { power_on_state = POWER_STATE_AC; External_V = true; Mcu_to_Arm_state.alarm_state &=~(1<<4); + Md_RegisterData.State_Register1 &=~(1<<0); } if(last_power_on_state != power_on_state) @@ -383,10 +383,12 @@ void FanFault_Detect() if((Data_I < FAN_Fault) && (Mcu_to_Arm_state.led_state & (1<<4))) { Mcu_to_Arm_state.alarm_state |=(1<<3); - } + Md_RegisterData.State_Register1 |=(1<<1); + } else { Mcu_to_Arm_state.alarm_state &=~(1<<3); + Md_RegisterData.State_Register1 &=~(1<<1); } } @@ -412,9 +414,11 @@ void Task_ADC() { static DWORD last_adc_tim = 0; DWORD now; - - now = HAL_GetTick(); - if((DWORD)(now - last_adc_tim) >= 1000) + + MAX31865_S4_Fsm(); + + now = HAL_GetTick(); + if((DWORD)(now - last_adc_tim) >= 500)//1000) { last_adc_tim = now; diff --git a/STM32/code/app/App_Lora.c b/STM32/code/app/App_Lora.c index defbaddb..8141b4b9 100644 --- a/STM32/code/app/App_Lora.c +++ b/STM32/code/app/App_Lora.c @@ -50,14 +50,14 @@ static void _Step_Lora_Init_Run() MyLoraInit_Step++; return; } - if (strstr((char*)frame, "OK") != NULL) - { - //´Ë´Î¾Ö·ÅÊý¾ÝÒÑÉÏ´«Íê±Ï ±ê־λÇå³ý - AppLora_Tx_Flag = 0; - AppLora_JuFang_Flag = 0; - //MyLoraInit_Step = MY_LORA_INIT_STEP_NULL; - return; - } + if (strstr((char*)frame, "OK") != NULL) + { + //´Ë´Î¾Ö·ÅÊý¾ÝÒÑÉÏ´«Íê±Ï ±ê־λÇå³ý + AppLora_Tx_Flag = 0; + AppLora_JuFang_Flag = 0; + //MyLoraInit_Step = MY_LORA_INIT_STEP_NULL; + return; + } } } @@ -112,7 +112,7 @@ static void _Step_Lora_Init_Run() else if (MyLoraInit_Step == MY_LORA_INIT_STEP_MAX) { MyLoraInit_Step = MY_LORA_INIT_STEP_NULL; - AppLora_Tx_Flag = TRUE; + AppLora_Tx_Flag = TRUE; } } diff --git a/STM32/code/app/App_RS485_1.c b/STM32/code/app/App_RS485_1.c index c4d94e5e..4de442ac 100644 --- a/STM32/code/app/App_RS485_1.c +++ b/STM32/code/app/App_RS485_1.c @@ -5,8 +5,8 @@ #include "def.h" #include "Port.h" #include "protocol_698.h" +#include "Get_EquipmentData.h" #include "protocol_modbus_rtu.h" - #include "Rn8302_cal.h" static BYTE rs4851_probuf[1024]; @@ -49,9 +49,16 @@ void Task_RS485_1_sProtocol() Port_tran_One_Frame(PORT_UART_IFACE_RS4851, pD645AckBuff, len-4); } } + else if(Modbus_Protocol_Analysis(frame,len))//µÚÈý·½ºǫ́modbusЭÒé + { + + } else { printf("Protocl Not Recognized\n"); } + } + + } diff --git a/STM32/code/app/App_Wifi.c b/STM32/code/app/App_Wifi.c index ae4d1f17..251f253b 100644 --- a/STM32/code/app/App_Wifi.c +++ b/STM32/code/app/App_Wifi.c @@ -794,7 +794,7 @@ void Task_App_WIFI() if (GetMyWIFIRunFlag(MyWIFI_RUN_FLAG_INIT_MOUDLE) == FALSE) { s_wifi_Signal = -100; - _Step_WIFI_Init_Run(); + _Step_WIFI_Init_Run(); return; } diff --git a/STM32/code/app/App_para.c b/STM32/code/app/App_para.c index 89c5d2cc..01c44526 100644 --- a/STM32/code/app/App_para.c +++ b/STM32/code/app/App_para.c @@ -274,6 +274,7 @@ void Load_Default_PT100_Para() { chipflashpara.PT100_para.PT100_adj_DC[i] = 0.01091f; chipflashpara.PT100_para.PT100_adj_Gain[i] = 46.809f; + chipflashpara.PT100_Coefficient_para.PT100[i] = 0x00; } } @@ -306,6 +307,10 @@ void Load_Default_LoopShow_Para() } } +void _Load_Default_Modbus_Para() +{ + chipflashpara.tMdbus_DeviceParam.DeviceAddr = 0x01; +} /* ¼ÓÔØÄ¬ÈϵIJÎÊý½á¹¹Ìå */ @@ -340,6 +345,9 @@ void _Load_Default_ChipFlash_Para() /* ÂÖÏÔ²ÎÊýģʽ */ Load_Default_LoopShow_Para(); + + /* modbus_rtuÉ豸µØÖ· */ + _Load_Default_Modbus_Para(); } static void _Load_Default_SpiFlash_Para() @@ -622,17 +630,12 @@ static BOOL _Check_Para_extend() /* ²ÎÊý½á¹¹Ìå ·¢ÉúÀ©Õ¹ºó,¼ìË÷³öÓÐЧµÄ²¿·ÖÌî³äµ½RAMÖÐ */ -static void _Copy_vaild_para_to_RAM(uint32_t para_flashaddr) +static void _Copy_vaild_para_to_RAM() { - - DWORD len = sizeof(tChipFlashPara); - //len = sizeof(RN8302Para_Stru); - //len = sizeof(RN8302Rate_Stru); - + BYTE buffer[MyCHIPFLASHPARA_SIZE]; + DWORD len; /* ¶ÁÈ¡×îºóÒ»´ÎÕýÈ·µÄ²ÎÊý½á¹¹Ì峤¶È*/ -#if 0 - BYTE buffer[MyCHIPFLASHPARA_SIZE]; - if (ChipFlashRead(para_flashaddr, (BYTE *)&len, sizeof(len)) == FALSE) + if (ChipFlashRead(USER_PARA_0_ADDRESS, (BYTE *)&len, sizeof(len)) == FALSE) { return; } @@ -641,23 +644,14 @@ static void _Copy_vaild_para_to_RAM(uint32_t para_flashaddr) { return; } - /* ¶Á³öÓÐЧ²ÎÊý²¿·Ö[¾É] */ - if (ChipFlashRead(para_flashaddr, buffer, len) == FALSE) + if (ChipFlashRead(USER_PARA_0_ADDRESS, buffer, len) == FALSE) { return; } /* ¸²¸ÇĬÈϲÎÊýµÄÇ°ÃæÒ»²¿·Ö */ memcpy(&chipflashpara, buffer, len); -#else - /* ¶Á³öÓÐЧ²ÎÊý²¿·Ö[¾É] */ - if (ChipFlashRead(para_flashaddr, (uint8_t *)&chipflashpara, len) == FALSE) - { - return; - } -#endif - } /* @@ -799,10 +793,10 @@ void ChipFlash_Para_Init() _Load_Default_ChipFlash_Para(); /*¼ì²éÊÇ·ñÓÉÓÚ³ÌÐòÉý¼¶¶øÀ©Õ¹³öÏÖÐÂÔö²ÎÊý½á¹¹Ìå? */ - //if (_Check_Para_extend()) + if (_Check_Para_extend()) { /* ¼ìË÷³öÓÐЧµÄ²ÎÊý²¿·Ö */ - _Copy_vaild_para_to_RAM(USER_PARA_0_ADDRESS); + _Copy_vaild_para_to_RAM(); } } else @@ -828,6 +822,7 @@ void ChipFlash_Para_Init() */ void SpiFlash_Para_Init() { + BYTE buffer[MySPIFLASHPARA_SIZE]; DWORD crc; BOOL result = FALSE; diff --git a/STM32/code/app/App_para.h b/STM32/code/app/App_para.h index 4f6e9ece..2c5698f5 100644 --- a/STM32/code/app/App_para.h +++ b/STM32/code/app/App_para.h @@ -118,8 +118,8 @@ typedef struct BYTE resv[3]; WORD PulseConst; /* Âö³å³£Êý */ WORD Freq0; /* ¶î¶¨ÆµÂÊ */ - WORD Un; /* ¶î¶¨µçѹ */ - INT Ib; /* ¶î¶¨µçÁ÷ */ + WORD Un; /* ¶î¶¨µçѹ */ + INT Ib; /* ¶î¶¨µçÁ÷ */ INT Imax; /* ×î´óµçÁ÷ */ INT Iadj; /* У׼µçÁ÷Öµ */ float f_scalexu; /* µçѹÀàת»»ÏµÊý */ @@ -275,6 +275,11 @@ typedef struct } tFan_PT100_CoefficientPARA; +typedef struct +{ + uint8_t DeviceAddr; +} +tMdbus_DeviceParam_t; //typedef Pt100Corrct_t tPt100_Checkout_ControlPARA; /********************************** ´øCRCµÄFLASH½á¹¹Ìå **********************************************/ @@ -312,6 +317,8 @@ typedef struct /*µçÄÜУ±íÊý¾Ý*/ RN8302Para_Stru g_RN8302CaliParaBkp; RN8302Rate_Stru g_RN8302RateBkp; + + tMdbus_DeviceParam_t tMdbus_DeviceParam; /* À©Õ¹ÆäËû : */ }tChipFlashPara; diff --git a/STM32/code/app/main_task.c b/STM32/code/app/main_task.c index d3c7a753..92de5364 100644 --- a/STM32/code/app/main_task.c +++ b/STM32/code/app/main_task.c @@ -32,6 +32,7 @@ #include "wireless_temp.h" #include "partial_discharge.h" #include "App_Lora.h" +#include "Get_EquipmentData.h" extern tEngRamDbase s_Ram_eng; /* @@ -96,20 +97,23 @@ void Task_RunFlagDaemon() Save_PowerOff_Data(); /* ÑÓʱ1ÃëµÈ´ýUARTÊý¾Ý´«ÊäÍê±Ï */ HAL_Delay(1000); - MyGpioWrite(PIN_OUT_POWER_SW, LOW); + //MyGpioWrite(PIN_OUT_POWER_SW, LOW); HAL_Delay(3000); /* ¸´Î»º¯Êý */ NVIC_SystemReset(); - while (1) - ; + while (1); } } +uint32_t pTimeCostMs = 0; +uint32_t pTimeMaxCostMs = 0; + void Task_main() { // Task_Eth(); + uint32_t tTimeStamp = HAL_GetTick(); - Task_ADC(); + Task_ADC(); Task_Save(); @@ -162,7 +166,16 @@ void Task_main() Task_LedBuzzer_State(); Task_Buzzer(); -// - Task_Iwdg_feed(); // ι¹· + + Task_ModbusRtu(); + + //Task_Iwdg_feed(); // ι¹· + + //all tasks running time measurment in ms. + pTimeCostMs = abs(HAL_GetTick() - tTimeStamp); + if(pTimeCostMs>pTimeMaxCostMs) + { + pTimeMaxCostMs = pTimeCostMs; + } } diff --git a/STM32/code/app/root.c b/STM32/code/app/root.c index 6d8ab526..626fe7d5 100644 --- a/STM32/code/app/root.c +++ b/STM32/code/app/root.c @@ -26,6 +26,8 @@ #include "concentrator.h" #include "wireless_temp.h" #include "partial_discharge.h" +#include "Get_EquipmentData.h" + extern void MX_LWIP_Init(void); /* @@ -81,24 +83,30 @@ void App_Init() /* ³õʼ»¯²É¼¯ÈÎÎñ */ Init_CJ_task(); - /*iwdg³õʼ»¯*/ - MX_IWDG_Init(); + /*iwdg³õʼ»¯*/ + //MX_IWDG_Init(); + + /*¼¯ÖÐÆ÷³õʼ»¯*/ + Concentrator_Init(); + + /*ÎÞÏß²âγõʼ»¯*/ + Wireless_Temp_Init(); + + /*¾Ö·½³õʼ»¯*/ + Partial_Discharge_Init(); + + /*·ç»ú³õʼ»¯*/ + Fun_Init(); - /*¼¯ÖÐÆ÷³õʼ»¯*/ - Concentrator_Init(); + //Sensor_State_Init(); + + /*PT100УÑé³õʼ»¯*/ + PT100_Checkout_Init(); - /*ÎÞÏß²âγõʼ»¯*/ - Wireless_Temp_Init(); - /*¾Ö·½³õʼ»¯*/ - Partial_Discharge_Init(); + MAX31865_Init(); - /*·ç»ú³õʼ»¯*/ - Fun_Init(); - - /*PT100УÑé³õʼ»¯*/ - PT100_Checkout_Init(); - - MAX31865_Config(CONFIG_ADDR,THREE_WIRE); + Modbus_Init(); + //MAX31865_Config(CONFIG_ADDR,THREE_WIRE); } diff --git a/STM32/code/app/temperture_ctrl.c b/STM32/code/app/temperture_ctrl.c index 7e1ff86b..bdd831b9 100644 --- a/STM32/code/app/temperture_ctrl.c +++ b/STM32/code/app/temperture_ctrl.c @@ -13,7 +13,7 @@ #include "alarm.h" #include "flats_CH455.h" #include "mcu_com.h" - +#include "Get_EquipmentData.h" /* modbusÓõ½µÄÔËÐÐ״̬°´bit BIT0 : ·ç»úÔËÐÐ״̬ @@ -149,7 +149,7 @@ static void Refresh_work_condition() } } - lVal = (INT)(t_max * DOT1); + lVal = (INT)(t_max); /* ·ç»úÆôÍ£¹¤¿ö */ if (s_work_state[WORK_CONDITION_FAN_NEED_RUN] == TRUE) { /* ÅжϽáÊø */ @@ -241,6 +241,7 @@ static void _Generate_One_Work_Event(BYTE work_type, BYTE startEndFlag) _FAN_Run(TRUE); Mcu_to_Arm_state.alarm_state |= (1 << 2); Mcu_to_Arm_state.beeper_state |= (1 << 3); + Md_RegisterData.State_Register1 |=(1<<4); Led_Temp_Motor_State.led_fan = true; MyMBWorkStatus |= BIT2; _Alarm_Switch_Run(SW_ALARM_2, TRUE); @@ -259,6 +260,7 @@ static void _Generate_One_Work_Event(BYTE work_type, BYTE startEndFlag) MyMBWorkStatus &= ~BIT2; Mcu_to_Arm_state.alarm_state &= ~(1 << 2); Mcu_to_Arm_state.beeper_state &= ~(1 << 3); + Md_RegisterData.State_Register1 &=~(1<<4); _Alarm_Switch_Run(SW_ALARM_2, FALSE); Set_Alarm_Status(TEM_WARNING_ALARM, FALSE); warnng = false; @@ -272,6 +274,7 @@ static void _Generate_One_Work_Event(BYTE work_type, BYTE startEndFlag) Mcu_to_Arm_state.led_state |= (1 << 2); Mcu_to_Arm_state.alarm_state |= (1 << 1); Mcu_to_Arm_state.beeper_state |= (1 << 2); + Md_RegisterData.State_Register1 |=(1<<5); Led_Temp_Motor_State.led_fan = true; _Alarm_Switch_Run(SW_ALARM_1, TRUE); @@ -284,6 +287,7 @@ static void _Generate_One_Work_Event(BYTE work_type, BYTE startEndFlag) Mcu_to_Arm_state.led_state &= ~(1 << 2); Mcu_to_Arm_state.alarm_state &= ~(1 << 1); Mcu_to_Arm_state.beeper_state &= ~(1 << 2); + Md_RegisterData.State_Register1 &=~(1<<5); if (fan == false || warnng == false || PT100_warnng == false) { if (fan == false && warnng == false) diff --git a/STM32/code/flat/gpio.c b/STM32/code/flat/gpio.c index 7ba5b757..8088b6bf 100644 --- a/STM32/code/flat/gpio.c +++ b/STM32/code/flat/gpio.c @@ -97,6 +97,8 @@ void MX_GPIO_Init(void) HAL_GPIO_WritePin(gpio_init_list[i].port_reg, GPIO_InitStruct.Pin, pinstate); } } + + MyGpioWrite(PIN_OUT_POWER_SW, HIGH);//20230619£ºÉϵçĬÈÏ¿ªÆôÐîµç³Ø¹©µç } /* @@ -113,6 +115,33 @@ void MyGpioWrite(BYTE enum_gpio, BYTE value) HAL_GPIO_WritePin(gpio_init_list[enum_gpio].port_reg, pin, value ? GPIO_PIN_SET : GPIO_PIN_RESET); } + + +////20230619£ºÔö¼ÓÒ»¸öÑÓ³Ù¹Ø±Õµç³ØµÄÈÎÎñ +//void taskDelayTurnOffBattery(void) +//{ +// //static uint32_t pBatTskCnt = 0; +// static uint8_t pBatSta = 1; +// +// //È¡ÏûADC ¼à²âÖÐµÄµç³Ø¿ª¹Ø²Ù×÷! +// uint32_t tCurTicks = HAL_GetTick(); +// //(abs(tCurTicks - pBatTskCnt) < 300000) +// if(tCurTicks > 1200000) +// { +// //³¬¹ý300Ãëºó¹Ø±Õµç³ØÊä³ö +// if(pBatSta)// only running ONCE! +// { +// MyGpioWrite(PIN_OUT_POWER_SW, LOW);//¹Ø±ÕÐîµç³Ø¹©µç +// pBatSta = 0;//reset bat sta; +// } +// } +// else +// { +// +// } +//} + + /* GPIO in¶ÁÈ¡½Ó¿Ú */ diff --git a/STM32/code/flat/gpio.h b/STM32/code/flat/gpio.h index 840607bb..8bc76b57 100644 --- a/STM32/code/flat/gpio.h +++ b/STM32/code/flat/gpio.h @@ -98,7 +98,7 @@ typedef struct void MX_GPIO_Init(void); /* USER CODE BEGIN Prototypes */ - +void taskDelayTurnOffBattery(void); /* USER CODE END Prototypes */ #ifdef __cplusplus diff --git a/STM32/code/flat/iwdg.c b/STM32/code/flat/iwdg.c index 44588511..14eb6bef 100644 --- a/STM32/code/flat/iwdg.c +++ b/STM32/code/flat/iwdg.c @@ -41,7 +41,7 @@ void MX_IWDG_Init(void) /* USER CODE END IWDG_Init 1 */ hiwdg.Instance = IWDG; hiwdg.Init.Prescaler = IWDG_PRESCALER_256; - hiwdg.Init.Reload = 2500; + hiwdg.Init.Reload = 5000;//2500 if (HAL_IWDG_Init(&hiwdg) != HAL_OK) { Error_Handler(); diff --git a/STM32/code/flat/tim.c b/STM32/code/flat/tim.c index 073e0c0c..2a1647fa 100644 --- a/STM32/code/flat/tim.c +++ b/STM32/code/flat/tim.c @@ -64,7 +64,6 @@ void MX_TIM8_Init(void) /* TIM2 init function */ void MX_TIM2_Init(void) { - /* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */ @@ -97,7 +96,6 @@ void MX_TIM2_Init(void) Error_Handler(); } /* USER CODE BEGIN TIM2_Init 2 */ - /* USER CODE END TIM2_Init 2 */ } diff --git a/STM32/code/flat/usart.c b/STM32/code/flat/usart.c index 11631c9a..db87c873 100644 --- a/STM32/code/flat/usart.c +++ b/STM32/code/flat/usart.c @@ -19,7 +19,8 @@ /* Includes ------------------------------------------------------------------*/ #include "def.h" -#include "config.h" +#include "usart.h" +#include "config.h" #include "device_tree.h" #include "usart.h" #include "system.h" diff --git a/STM32/code/flat/usart.h b/STM32/code/flat/usart.h index 9ad4e12b..5ecc283f 100644 --- a/STM32/code/flat/usart.h +++ b/STM32/code/flat/usart.h @@ -55,7 +55,7 @@ extern "C" /* ³õʼ»¯È«²¿UART¶Ë¿Ú */ - void Init_UART_ALL(void); +void Init_UART_ALL(void); BOOL UART_Tx_One_Frame(BYTE enum_uart, BYTE *data, WORD txlen); diff --git a/STM32/code/flat/yx.c b/STM32/code/flat/yx.c index 5f81570d..63df94ad 100644 --- a/STM32/code/flat/yx.c +++ b/STM32/code/flat/yx.c @@ -11,6 +11,7 @@ #include "gpio.h" #include "mcu_com.h" #include "temperture_ctrl.h" +#include "Get_EquipmentData.h" // ±¾ÎļþÓõ½µÄÈ«¾Ö±äÁ¿ static BYTE Sameple_Yx[YX_History_Max]; /* µ±Ç°Ò£ÐÅ״̬,¾­¹ý·À¶¶¶¯´¦Àí */ @@ -105,12 +106,14 @@ void Task_Yx() { Mcu_to_Arm_state.alarm_state &= ~(1 << 0); Mcu_to_Arm_state.beeper_state &= ~(1 << 0); + Md_RegisterData.State_Register1 &=~(1<<6); // Len_Yx_State.yx_menchudian_buzzer=FALSE; } else { Mcu_to_Arm_state.alarm_state |= (1 << 0); Mcu_to_Arm_state.beeper_state |= (1 << 0); + Md_RegisterData.State_Register1 |= (1<<6); // Len_Yx_State.yx_menchudian_buzzer=TRUE; } } diff --git a/STM32/code/main.c b/STM32/code/main.c index eac03166..fc2a02c0 100644 --- a/STM32/code/main.c +++ b/STM32/code/main.c @@ -78,7 +78,7 @@ int main(void) SystemClock_Config(); // _Load_Default_ChipFlash_Para(); - //// + // // Save_ChipFlash_Para(); /* ²ÎÊý³õʼ»¯ */ diff --git a/STM32/code/mcu_com/mcu_com.c b/STM32/code/mcu_com/mcu_com.c index 4071de01..9b352574 100644 --- a/STM32/code/mcu_com/mcu_com.c +++ b/STM32/code/mcu_com/mcu_com.c @@ -15,6 +15,7 @@ #include "Concentrator.h" #include "wireless_temp.h" #include "temperture_ctrl.h" +#include "Get_EquipmentData.h" #include "partial_discharge.h" #include "mcu_com_second_machine_sensor.h" @@ -31,6 +32,8 @@ Partial_Discharge_Alarm_Data_t Partial_Discharge_Alarm_Data; Partial_Discharge_Sensor_Data_t Partial_Discharge_Sensor_Data; Second_Machine_Sensor_t second_machine_LCD_data; +Arm_to_Mcu_state_t Arm_to_Mcu_state; + static Concentrator_Data_t Concentrator_Data; static Wireless_Temp_Data_t Wireless_Temp_Data; @@ -44,7 +47,7 @@ uint16_t McuCom_Sensor_Packet(uint8_t type, uint8_t sun_type, uint8_t *data, uin uint8_t *p; uint16_t pack_len = 0, crc16; McuCom_Head_t McuCom_Head; - McuCom_Head.head = MCU_ARM_COM_HEAD; // 55AA + McuCom_Head.head = MCU_ARM_COM_HEAD; // AA55 McuCom_Head.type = type; McuCom_Head.sub_type = sun_type; McuCom_Head.len = len; @@ -296,18 +299,7 @@ void McuCom_Send_Partial_Discharge(uint8_t port) { return; } - if (port == PORT_UART_IFACE_4G) - { - UART_Tx_One_Frame(PORT_UART_IFACE_4G, com_temp, packet_len); - Discharge_TX_count += 1; - } - else - { UART_Tx_One_Frame(PORT_UART_IFACE_WIFI, com_temp, packet_len); - Discharge_TX_count += 1; - } - if (Discharge_TX_count >= 2) - { if (updata.sensor == true) { Partial_Discharge_Clear_Updata(PARTICAL_DISCHARGE_SENSOR_FUN, NULL_TYPE); @@ -320,8 +312,6 @@ void McuCom_Send_Partial_Discharge(uint8_t port) { Partial_Discharge_Clear_Updata(PARTICAL_DISCHARGE_ATLAS_FUN, ULT_TYPE); } - Discharge_TX_count = 0; - } HAL_Delay(3); } @@ -452,9 +442,9 @@ void ArmMcu_Set(ARM_SET_E fun, uint8_t *data) // case case FAN_TEMP_CONTR: // 温度控制 fan_open_temp = *p++; - fan_open_temp = ((fan_open_temp << 8) | *p++) * DOT1; + fan_open_temp = ((fan_open_temp << 8) | *p++); fan_stop_temp = *p++; - fan_stop_temp = ((fan_stop_temp << 8) | *p) * DOT1; + fan_stop_temp = ((fan_stop_temp << 8) | *p); huicha_temp = fan_open_temp - fan_stop_temp; ArmMcu_FanTemp_Set(fan_open_temp, huicha_temp); SetRunFlag(TCM_FLAG_CHIPFLASHPARA_Save, FLAG_SET); @@ -469,10 +459,12 @@ void ArmMcu_Set(ARM_SET_E fun, uint8_t *data) if (*p == true) { Mcu_Fan_Contr.time_config.time_enable = true; + Md_RegisterData.State_Register1 |=(1<<3); } else { Mcu_Fan_Contr.time_config.time_enable = false; + Md_RegisterData.State_Register1 &=~(1<<3); } SetRunFlag(TCM_FLAG_CHIPFLASHPARA_Save, FLAG_SET); break; @@ -489,9 +481,9 @@ void ArmMcu_Set(ARM_SET_E fun, uint8_t *data) } case OVERHEAT_TRIP_TEMP: // 超温报报警,跳闸温度 Overheat = *p++; - Overheat = ((Overheat << 8) | *p++) * DOT1; + Overheat = ((Overheat << 8) | *p++); Trip = *p++; - Trip = ((Trip << 8) | *p) * DOT1; + Trip = ((Trip << 8) | *p); ArmMcu_Overheat_Trip_Temp(Overheat, Trip); SetRunFlag(TCM_FLAG_CHIPFLASHPARA_Save, FLAG_SET); break; @@ -793,6 +785,7 @@ void Mcu_Arm_Request(uint8_t port) UART_Tx_One_Frame(PORT_UART_IFACE_WIFI, com_temp, len); } } + /*传感器连接状态*/ void McuCom_Sensor_Send_State(uint8_t cmd_type) { @@ -811,69 +804,13 @@ void McuCom_Sensor_Send_State(uint8_t cmd_type) UART_Tx_One_Frame(PORT_UART_IFACE_WIFI, com_temp, len); HAL_Delay(30); } -///********************************************************************************** -// UART1-->ARM通信传感器任�? -//**********************************************************************************/ -// void Task_McuCom1(void) -//{ -// ComHard_ComTest_t ComTest; -// -// static DWORD last_split_eng_tim = 0; -// // tSimpleTim stim; -// DWORD now; -// now = HAL_GetTick(); -// if ((DWORD)(now - last_split_eng_tim) > 1000) -// { -// last_split_eng_tim = now; -// } -// else -// { -// return; -// } -// -// ComHard_Get_ComTest(&ComTest); -// switch (McuCom.com1_status) -// { -// //首先通�??测试:arm--request,mcu应答,然后�?�取arm_request读取通�??状�? -// case MCU_ARM_COM_INIT: //初�?�化状�? -// -// ComHard_Uart1_Analy(); //arm串口1接收数据解析 -// if (ComTest.arm_uart1_request == true) -// { -// McuCom.com1_status = MCU_ARM_COM_TEST; //检测状�? -// McuCom.concentra_config = ARMMCU_CONFIG_INIT; //配置初�?�化 -// McuCom.wireless_temp_config = ARMMCU_CONFIG_INIT; -// McuCom.com1_handshake = MCU_HANDSHAKE_RESPONSE; -// } -// break; -// -// case MCU_ARM_COM_TEST: -// switch (McuCom.com1_handshake) //握手状�? -// { -// case MCU_HANDSHAKE_RESPONSE: //握手应答状�? -// Mcu_Handhake_Response(ARMMCU_COM1); //MCU握手应答 -// McuCom.com1_handshake = MCU_HANDSHAKE_CONFIM; //握手�?认状�? -// break; -// -// case MCU_HANDSHAKE_CONFIM: //握手�?�? -// ComHard_Uart1_Analy(); -// if (ComTest.arm_uart1_confim == true) -// { -// McuCom.com1_status = MCU_ARM_COM_SUCCESS; //正常状�? -// } -// break; -// -// default: -// break; -// } -// break; -// case MCU_ARM_COM_SUCCESS://正常状�? -// -// break; -// case MCU_ARM_COM_FAILE: -// break; -// } -//} + +void McuCom_Send_DsTemp_Request(void) +{ + uint8_t len = 0; + len = McuCom_Sensor_Packet(DS_TEMP,0x01,&Arm_to_Mcu_state.DS_TempRequest,0x01); + UART_Tx_One_Frame(PORT_UART_IFACE_WIFI, com_temp, len); +} /********************************************************************************** UART2-->ARM通信传感器任务 @@ -956,10 +893,10 @@ void Task_McuCom2(void) { ComHard_Uart2_Analy(); Mcu_Handhake_Response(ARMMCU_COM2); // 使能请求 - if(McuCom.arm_set_sensor_enable == true) - { - Arm_Sensor_Enable_Process(McuCom.sensor_enable); - } + } + if(McuCom.arm_set_sensor_enable == true) + { + Arm_Sensor_Enable_Process(McuCom.sensor_enable); } McuCom_Send_Wireless_Temp(PORT_UART_IFACE_WIFI); // 无线温度 McuCom_Send_Concentrator(PORT_UART_IFACE_WIFI); // 集中采集 @@ -967,6 +904,7 @@ void Task_McuCom2(void) McuCom_Sensor_Send_State(SENSOR_SELF_TEST); // 发送传感器自检状态 McuCom_Sencond_Machine_Sensor_LCD(); // 二代LCD数据 McuCom_Send_Partial_Discharge(PORT_UART_IFACE_WIFI); // 局放数据 + if (now - state_time > (60000 * 60)) { if ((uint8_t) false == (Mcu_to_Arm_state.sensor_state & 0x01)) @@ -1034,10 +972,12 @@ void Mcu_Set_Config_Enable(ARM_CONFIG_E fan, uint8_t *data) if (*p == false) { chipflashpara.temp_ctrl_para.PT100_4_Vaild = false; + Md_RegisterData.State_Register1 &=~(1<<11); } else { chipflashpara.temp_ctrl_para.PT100_4_Vaild = true; + Md_RegisterData.State_Register1 |=(1<<11); } SetRunFlag(TCM_FLAG_CHIPFLASHPARA_Save, FLAG_SET); @@ -1058,15 +998,6 @@ void Fun_Init(void) Mcu_Fan_Contr.time_config.enable = false; } -// void Get_TempFan(int *buf) -// { -// Mcu_Second_Machine_Sensor_Get_Data(&second_machine_LCD_data); -// for (int i = 0; i < 4; i++) -// { -// buf[i] = big_to_littles_int(second_machine_LCD_data.pt100_temp[i]); -// } -// } - void Temp_Fan(void) { //int PT100_Temp[4]; @@ -1119,6 +1050,7 @@ void Task_Fun_Contr(void) { ArmMcu_FAN_Run(false); // 关闭风机 Mcu_to_Arm_state.led_state &= ~(1 << 4); + Md_RegisterData.State_Register1 &=~(1<<2); Mcu_Fan_Contr.time_config.enable = false; } } @@ -1149,6 +1081,7 @@ void Task_Fun_Contr(void) ArmMcu_FAN_Run(true); // 打开风机 Set_ACK(FAN_MANUAL, &data); Mcu_to_Arm_state.led_state |= (1 << 4); + Md_RegisterData.State_Register1 |=(1<<2); Led_Temp_Motor_State.led_fan = true; } @@ -1160,6 +1093,7 @@ void Task_Fun_Contr(void) { ArmMcu_FAN_Run(false); // 关闭风机 Mcu_to_Arm_state.led_state &= ~(1 << 4); + Md_RegisterData.State_Register1 &=~(1<<2); Led_Temp_Motor_State.led_fan = false; Mcu_Fan_Contr.time_config.enable = false; } @@ -1198,10 +1132,12 @@ void LedBuzzer_Data_state(void) if (Led_Temp_Motor_State.led_fan == true || Mcu_Fan_Contr.time_config.enable == true || Mcu_Fan_Contr.manual.enable == true) { Mcu_to_Arm_state.led_state |= (1 << 4); + Md_RegisterData.State_Register1 |=(1<<2); } else { Mcu_to_Arm_state.led_state &= ~(1 << 4); + Md_RegisterData.State_Register1 &=~(1<<2); } if (Led_Com_State.Led_Com_Tx == true) @@ -1239,6 +1175,12 @@ void Task_LedBuzzer_State(void) LedBuzzer_Data_state(); McuArm_LedBuzzer_Send(LED_STATE, &Mcu_to_Arm_state.led_state); McuArm_LedBuzzer_Send(ALARM_STATE, &Mcu_to_Arm_state.alarm_state); + if(Arm_to_Mcu_state.DS_TempRequest !=false) + { + McuCom_Send_DsTemp_Request(); + Arm_to_Mcu_state.DS_TempRequest = false; + Md_RegisterData.State_Register1 &=~(3<<12); + } } /*蜂鸣器任务*/ @@ -1264,6 +1206,7 @@ void Task_Buzzer(void) Mcu_to_Arm_state.beepRunFlag[i] = 1; Mcu_to_Arm_state.quietFlag[i] = 0; Mcu_to_Arm_state.led_state |= (1 << 5); + Md_RegisterData.State_Register1 |=(1<<14); break; } } @@ -1272,12 +1215,14 @@ void Task_Buzzer(void) // beep off ArmMcu_Beep_Run(false); Mcu_to_Arm_state.led_state &= ~(1 << 5); + Md_RegisterData.State_Register1 &=~(1<<14); } } // 如果ARM有消音命令 if (Mcu_Config_Enable.muffler_buzzer_disable == true) { Mcu_to_Arm_state.led_state &= ~(1 << 5); + Md_RegisterData.State_Register1 &=~(1<<14); for (int i = 0; i < ALARM_BEEP_MAX; i++) { if (Mcu_to_Arm_state.beepRunFlag[i] == 1) diff --git a/STM32/code/mcu_com/mcu_com.h b/STM32/code/mcu_com/mcu_com.h index 29a671fc..497f3c92 100644 --- a/STM32/code/mcu_com/mcu_com.h +++ b/STM32/code/mcu_com/mcu_com.h @@ -10,6 +10,8 @@ #define ALARM_BEEP_MAX 5 #define SECOND_MACHINE_SENSOR_UPLOAD 0X01 // ¶þ´ú´«¸ÐÆ÷ÉÏ´« + + // ³õʼ»¯×´Ì¬ typedef enum { @@ -35,7 +37,8 @@ typedef enum CT_SET, ARM_RTC_STATE_ACK = 0X17, // ARMÇëÇóÉèÖÃrtcʱ¼ä SENSOR_CONNECT_STATE = 0X19, // ´«¸ÐÆ÷Á¬½Ó״̬ - SENSOR_SELF_TEST = 0x05 // ´«¸ÐÆ÷×Ô¼ì״̬ + SENSOR_SELF_TEST = 0x05, // ´«¸ÐÆ÷×Ô¼ì״̬ + DS_TEMP = 0X31,//ÈÈÏñÒÇζÈÇëÇó } ARM_SET_E; typedef enum @@ -133,6 +136,13 @@ typedef struct } McuCom_t; +typedef struct +{ + uint8_t DS_2TD3017T; //ÈȳÉÏñ״̬Êý¾Ý + uint8_t SengdData_Flag; //Êý¾Ý·¢ËÍÍê³É±êÖ¾ + uint8_t DS_TempRequest; //ÈÈÏñÒÇζÈÇëÇó +} Arm_to_Mcu_state_t; + typedef enum { CONFIG_INIT, @@ -194,12 +204,15 @@ typedef enum extern Mcu_to_Arm_state_t Mcu_to_Arm_state; extern Mcu_Config_Enable_t Mcu_Config_Enable; +extern Arm_to_Mcu_state_t Arm_to_Mcu_state; +extern Mcu_Fan_Contr_t Mcu_Fan_Contr; void Fun_Init(void); void Task_Buzzer(void); void Task_McuCom1(void); void Task_McuCom2(void); void Task_Fun_Contr(void); +//void Sensor_State_Init(void); void Task_LedBuzzer_State(void); void Fan_Cmd_Send(uint8_t type); void Buzzer_GPIO_Config(uint8_t state); diff --git a/STM32/code/mcu_com/mcu_com_hard.c b/STM32/code/mcu_com/mcu_com_hard.c index a6d7cc9f..b3790f8d 100644 --- a/STM32/code/mcu_com/mcu_com_hard.c +++ b/STM32/code/mcu_com/mcu_com_hard.c @@ -1,10 +1,11 @@ -#include "mcu_com_hard.h" -#include "concentrator.h" #include "def.h" +#include "fun.h" #include "port.h" #include "mcu_com.h" +#include "mcu_com_hard.h" +#include "concentrator.h" +#include "Get_EquipmentData.h" #include "protocol_modbus_rtu.h" -#include "fun.h" // #include "wireless_temp.h" // mcuÏòarm·¢Ë͵Ĵ®¿Ú½ÓÊÕ½âÎö @@ -157,7 +158,7 @@ void ComHard_Uart2_Analy(void) uint8_t *frame, *p, pos; uint16_t len = 0, crc16, cal_crc; McuCom_Head_t *McuCom_Head; - + uint8_t data; uint8_t dbg_len,head_len; // ½«Öжϻº³å¶ÓÁÐÊý¾Ý¿½±´µ½Ó¦Óûº³åÇø Port_Get_One_Rx_Frame(PORT_UART_IFACE_WIFI, &frame, &len); @@ -246,6 +247,61 @@ void ComHard_Uart2_Analy(void) Mcu_Set_Config_Enable(ARM_RTC_STATE, p); } break; + case DS_TEMP1: //ÈÈÏñÒÇ1ζÈÊý¾Ý + p += 2; + for(int i = 0; i < 4; i++) + { + Md_RegisterData.Ds_Temp[0].Temp_Max<<=8; + Md_RegisterData.Ds_Temp[0].Temp_Max += *p; + + p+=1; + } + for(int i = 0; i < 4; i++) + { + Md_RegisterData.Ds_Temp[0].Temp_Min<<=8; + Md_RegisterData.Ds_Temp[0].Temp_Min += *p; + p+=1; + } + for(int i = 0; i < 4; i++) + { + Md_RegisterData.Ds_Temp[0].Temp_Average <<= 8; + Md_RegisterData.Ds_Temp[0].Temp_Average += *p; + p+=1; + } + break; + case DS_TEMP2: //ÈÈÏñÒÇ2ζÈÊý¾Ý + p += 2; + for(int i = 0; i < 4; i++) + { + Md_RegisterData.Ds_Temp[1].Temp_Max<<=8; + Md_RegisterData.Ds_Temp[1].Temp_Max += *p; + p+=1; + } + for(int i = 0; i < 4; i++) + { + Md_RegisterData.Ds_Temp[1].Temp_Min<<=8; + Md_RegisterData.Ds_Temp[1].Temp_Min += *p; + p+=1; + } + for(int i = 0; i < 4; i++) + { + Md_RegisterData.Ds_Temp[1].Temp_Average <<= 8; + Md_RegisterData.Ds_Temp[1].Temp_Average += *p; + p+=1; + } + break; + case DS_STATE: //ÈÈÏñÒÇ״̬Êý¾Ý + p += 2; + Arm_to_Mcu_state.DS_2TD3017T = *p; + break; + case DATA_SEND_FLAG: + p += 2; + if(*p) + { + Battery_SwitchEnable(0); + }else{Battery_SwitchEnable(1);} + Arm_to_Mcu_state.SengdData_Flag = *p; + break; default: break; } diff --git a/STM32/code/mcu_com/mcu_com_hard.h b/STM32/code/mcu_com/mcu_com_hard.h index 4c2d3b2b..06dce400 100644 --- a/STM32/code/mcu_com/mcu_com_hard.h +++ b/STM32/code/mcu_com/mcu_com_hard.h @@ -113,9 +113,12 @@ typedef enum MCUCOM_FUN_CONTROL_SET, // 0X23 MCUCOM_FUN_TIME_SET, // 0X24 //·çÉÈ¿ªÆôʱ¼ä MCUCOM_BUZZER_SET = 0x25, // ·äÃùÆ÷ + DS_TEMP1, //ÈÈÏñÒÇ1ÎÂ¶È MCUCOM_OVERHEAT_TRIP_TEMP = 0x27, // ³¬Î±¨¾¯¡¢ÌøÕ¢ÎÂ¶È MCUCOM_CT_SET = 0x28, // CT²ÎÊýÉèÖà - + DS_TEMP2, //ÈÈÏñÒÇ1ÎÂ¶È + DS_STATE = 0x30, //ÈÈÏñÒÇ״̬ + DATA_SEND_FLAG = 0x32, //Êý¾Ý·¢ËÍÍê³É±êÖ¾ } ComHard_CmdType_E; typedef struct diff --git a/STM32/code/mcu_com/mcu_com_second_machine_sensor.c b/STM32/code/mcu_com/mcu_com_second_machine_sensor.c index a651a219..ff7f2ae4 100644 --- a/STM32/code/mcu_com/mcu_com_second_machine_sensor.c +++ b/STM32/code/mcu_com/mcu_com_second_machine_sensor.c @@ -9,6 +9,7 @@ #include "App_Harm.h" #include "tcm_dbase.h" #include "Rn8302_cal.h" +#include "Get_EquipmentData.h" #include "mcu_com_second_machine_sensor.h" extern tHarm_Data MyHarmDbase; @@ -80,15 +81,18 @@ void Mcu_Second_Machine_Sensor_Get_Vol(void) if (dwVal >= 10) { Mcu_to_Arm_state.sensor_state |= (1 << 6); + Md_RegisterData.State_Register2 |= (1<<4); } } if (dwVal <= 10 && chipflashpara.PriLinePara.CT_U > 1) { Mcu_to_Arm_state.sensor_state |= (1 << 3 + i); + Md_RegisterData.State_Register2 |= (1<<5 + i); } else { Mcu_to_Arm_state.sensor_state &= ~(1 << 3 + i); + Md_RegisterData.State_Register2 &=~ (1<<5 + i); } second_machine_sensor.voltage[i] = big_to_littles_int(dwVal); // printf("µçѹ[%d] = %fV\r\n",i+1,(float)dwVal); @@ -372,7 +376,7 @@ void Mcu_Second_Machine_Sensor_Get_PF(void) int32_t val = 0; uint8_t i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { Get_rt_dbase_data(DBASE_DATA_RTDATA_FLOAT_PFA_D0 + i, &fVal); val = (int32_t)(fVal * DOT4); @@ -693,8 +697,6 @@ void Mcu_Second_Machine_Sensor_Get_Demand(void) { float fVal; INT data; - - //static int debug_data = -300000; for (int i = 0; i < 2; i++) diff --git a/STM32/code/new_sensor/partial_discharge.c b/STM32/code/new_sensor/partial_discharge.c index fa90c690..a5888bd4 100644 --- a/STM32/code/new_sensor/partial_discharge.c +++ b/STM32/code/new_sensor/partial_discharge.c @@ -26,7 +26,7 @@ #include "def.h" #include "App_Lora.h" #include "stm32f4xx_hal.h" - +#include "Get_EquipmentData.h" /*************************************************************************** | Compile Option or configuration Section (for test/debug) |**************************************************************************/ @@ -486,46 +486,50 @@ void Partical_Discharge_Alarm_Analyse(Partial_Discharge_Alarm_Recive_Data* alarm crc16=ModBusCRC16((uint8_t*)alarm_data,sizeof(Partial_Discharge_Alarm_Recive_Data)-sizeof(crc16)); if(crc16==alarm_data->crc16) { - memset(&Partial_Discharge_Alarm.data,0,sizeof(Partial_Discharge_Alarm_Data_t)); + memset(&Partial_Discharge_Alarm.data,0,sizeof(Partial_Discharge_Alarm_Data_t)); - Partial_Discharge_Contr.updata.alarm=true; - Partial_Discharge_Sensor.data.updata=true; - if(alarm_data->data == 0) - { - Partial_Discharge_Sensor.data.alarm=false; - } - else - { - switch(alarm_data->data) - { - case TEV_ALARM://µØµç²¨±¨¾¯ - Partial_Discharge_Alarm.data.tev_ararm=true; - Partial_Discharge_Atlas.tev_enable=true; - Partial_Discharge_Alarm.data.updata=true; - Partial_Discharge_Sensor.data.alarm=0x01; - // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ - break; + Partial_Discharge_Contr.updata.alarm=true; + Partial_Discharge_Sensor.data.updata=true; + if(alarm_data->data == 0) + { + Partial_Discharge_Sensor.data.alarm=false; + Md_RegisterData.State_Register2 &=~(1<<10); + Md_RegisterData.State_Register2 &=~(1<<11); + } + else + { + switch(alarm_data->data) + { + case TEV_ALARM://µØµç²¨±¨¾¯ + Partial_Discharge_Alarm.data.tev_ararm=true; + Partial_Discharge_Atlas.tev_enable=true; + Partial_Discharge_Alarm.data.updata=true; + Md_RegisterData.State_Register2 |=(1<<11); + Partial_Discharge_Sensor.data.alarm=0x01; + // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ + break; - case ULT_ALARM://³¬Éù²¨±¨¾¯ - Partial_Discharge_Alarm.data.ult_ararm=true; - Partial_Discharge_Atlas.ult_enable=true; - Partial_Discharge_Alarm.data.updata=true; - Partial_Discharge_Sensor.data.alarm=0x02; - // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ - break; - - case UNION_ARAM://ÁªºÏ±¨¾¯ - Partial_Discharge_Alarm.data.union_ararm=true; - Partial_Discharge_Atlas.tev_enable=true; - Partial_Discharge_Atlas.ult_enable=true; - Partial_Discharge_Alarm.data.updata=true; - Partial_Discharge_Sensor.data.alarm=0x03; - // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ - break; - default: - break; - } - } + case ULT_ALARM://³¬Éù²¨±¨¾¯ + Partial_Discharge_Alarm.data.ult_ararm=true; + Partial_Discharge_Atlas.ult_enable=true; + Partial_Discharge_Alarm.data.updata=true; + Md_RegisterData.State_Register2 |=(1<<10); + Partial_Discharge_Sensor.data.alarm=0x02; + // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ + break; + + case UNION_ARAM://ÁªºÏ±¨¾¯ + Partial_Discharge_Alarm.data.union_ararm=true; + Partial_Discharge_Atlas.tev_enable=true; + Partial_Discharge_Atlas.ult_enable=true; + Partial_Discharge_Alarm.data.updata=true; + Partial_Discharge_Sensor.data.alarm=0x03; + // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ + break; + default: + break; + } + } } } @@ -539,16 +543,17 @@ void Partical_Discharge_Alarm_Analyse(Partial_Discharge_Alarm_Recive_Data* alarm void Partical_Discharge_Sensor_Analyse(Partial_Discharge_Sensor_Recive_Data *data) { uint16_t crc16=0; - crc16=ModBusCRC16((uint8_t*)data,sizeof(Partial_Discharge_Sensor_Recive_Data)-sizeof(crc16)); + crc16=ModBusCRC16((uint8_t*)data,sizeof(Partial_Discharge_Sensor_Recive_Data)-sizeof(crc16)); if(crc16==data->crc16) { //Partial_Discharge_Atlas.atlas_process=ATLAS_INIT; - Partial_Discharge_Sensor.data.tev_data=data->tev;//µØµç²¨Êý¾Ý - Partial_Discharge_Sensor.data.ult_data=data->ult;//³¬Éù²¨Êý¾Ý + Partial_Discharge_Sensor.data.tev_data = data->tev;//µØµç²¨Êý¾Ý + + Partial_Discharge_Sensor.data.ult_data = data->ult;//³¬Éù²¨Êý¾Ý Partial_Discharge_Contr.updata.sensor=true; Partial_Discharge_Contr.cmd_state = PARTICAL_DISCHARGE_ALARM;//±¨¾¯×´Ì¬ } - jufangdata = data->tev.tev_peak; + jufangdata = big_to_littles_uint16(data->tev.tev_peak); AppLora_JuFang_Flag = 1; } @@ -659,8 +664,8 @@ void Partial_Discharge_Self_Test_Receive(uint8_t *data) ***************************************************************************/ void Partial_Discharge_Receive_Analyse(void) { - uint8_t *p; - uint16_t i; + uint8_t *p; + uint16_t i; Partial_Discharge_Alarm_Recive_Data *alarm_data;//±¨¾¯Êý¾Ý Partial_Discharge_Sensor_Recive_Data *sensor_data;//¾Ö·½Êý¾Ý p=rec_buf; @@ -762,6 +767,7 @@ void PARTICAL_DISCHARGE_Self_test_Process(void) { Partial_Discharge_Sensor.arm_config.self_test_finish=true; Mcu_to_Arm_state.sensor_state &=~(1<<1); + Md_RegisterData.State_Register2 &=~(1<<0); } else { @@ -780,6 +786,7 @@ void PARTICAL_DISCHARGE_Self_test_Process(void) case PARTICAL_DISCHARGE_CHECK_SELF_END://×Ô¼ì½áÊø Mcu_to_Arm_state.sensor_state |=(1<<1); + Md_RegisterData.State_Register2 |=(1<<0); break; } } @@ -819,8 +826,8 @@ void Task_Partial_Discharge(void) PARTICAL_DISCHARGE_Self_test_Process(); break; case PARTICAL_DISCHARGE_NORMAL://Õý³£×´Ì¬ - Partial_Discharge_Receive(); //¾Ö·½Êý¾Ý½ÓÊÜ - Partial_Discharge_Cmd(); //¾Ö·½ÃüÁî·¢ËÍ + Partial_Discharge_Receive(); //¾Ö·½Êý¾Ý½ÓÊÜ + Partial_Discharge_Cmd(); //¾Ö·½ÃüÁî·¢ËÍ break; default: break; diff --git a/STM32/code/new_sensor/partial_discharge.h b/STM32/code/new_sensor/partial_discharge.h index 30ae277d..54c4cf06 100644 --- a/STM32/code/new_sensor/partial_discharge.h +++ b/STM32/code/new_sensor/partial_discharge.h @@ -213,28 +213,28 @@ typedef struct ͼÆ×¿ØÖƽṹÌå ******************************/ - typedef struct - { - uint8_t data[256]; - uint8_t len; - }Partial_Discharge_ultTevData_t; - - /*ͼÆ×modbus_cmd¸ñʽ - Addr fun len ÒýÓà ÎļþºÅ ÆðʼºÅ Êý¾Ý³¤¶È crc16 - ÎļþºÅ:0x01---tev - 0x03---ult*/ +typedef struct +{ + uint8_t data[256]; + uint8_t len; +}Partial_Discharge_ultTevData_t; + +/*ͼÆ×modbus_cmd¸ñʽ +Addr fun len ÒýÓà ÎļþºÅ ÆðʼºÅ Êý¾Ý³¤¶È crc16 +ÎļþºÅ:0x01---tev +0x03---ult*/ //ͼÆ×ÃüÁî¸ñʽ - typedef struct - { - uint8_t addr; - uint8_t fun; - uint8_t cmd_len; - uint8_t quote; //ÒýÓà - uint16_t file_num; - uint16_t statr_num ; //ÆðʼºÅ - uint16_t record_len; - uint16_t crc16; - }Partial_Discharge_Atlas_Cmd_t; +typedef struct +{ + uint8_t addr; + uint8_t fun; + uint8_t cmd_len; + uint8_t quote; //ÒýÓà + uint16_t file_num; + uint16_t statr_num ; //ÆðʼºÅ + uint16_t record_len; + uint16_t crc16; +}Partial_Discharge_Atlas_Cmd_t; //ͼÆ×·¢ËÍ¿ØÖƽṹÌå typedef struct @@ -290,12 +290,11 @@ typedef struct Partial_Discharge_Fun_E fun; //¹¦ÄÜ£»±¨¾¯/Êý¾Ý/ͼÆ× //uint8_t alarm_time; uint8_t enable; //´«¸ÐÆ÷ʹÄÜ - Partial_Discharge_Self_Test_State_E test_state; + Partial_Discharge_Self_Test_State_E test_state; Partial_Discharge_Updata_t updata; Partical_Dischage_Cmd_Statu cmd_state; }Partial_Discharge_Contr_t; - /******************************* ½ÓÊÕÊý¾Ý½á¹¹ *******************************/ @@ -318,13 +317,12 @@ typedef struct{ uint8_t refern;/// ²Î¿¼ÀàÐÍ }Partial_Discharge_Atlas_Receive_PackHead; - typedef struct { Partial_Discharge_Sensor_Receive_PackHead PackHead; Tev_Data_t tev; uint16_t data[26]; - Ult_Data_t ult; + Ult_Data_t ult; uint16_t crc16; }Partial_Discharge_Sensor_Recive_Data; @@ -334,6 +332,8 @@ typedef struct uint8_t data; uint16_t crc16; }Partial_Discharge_Alarm_Recive_Data; + +extern Partial_Discharge_Sensor_t Partial_Discharge_Sensor; /*************************************************************************** | Table Definition |**************************************************************************/ diff --git a/STM32/code/new_sensor/wireless_temp.c b/STM32/code/new_sensor/wireless_temp.c index ed458b54..ea058922 100644 --- a/STM32/code/new_sensor/wireless_temp.c +++ b/STM32/code/new_sensor/wireless_temp.c @@ -26,6 +26,7 @@ #include "fun.h" #include "def.h" #include "stm32f4xx_hal.h" +#include "Get_EquipmentData.h" /*************************************************************************** | Static local variables Declaration |**************************************************************************/ @@ -156,10 +157,18 @@ static void Wireless_Temp_Read_Receive(uint8_t *p) if (Wireless_Temp_Info.data.temp[i] == 0XFF7F) { Wireless_Temp_Info.data.state[i] = false; + if(i < 16){Md_RegisterData.WirelessTemp_State[0]&=~(1<