From 62906c66857fb903a45b72eb286f7146550fe975 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 27 Jun 2025 16:40:42 +0300 Subject: [PATCH] comment1 --- .gitmodules | 3 + external_flash_eeprom | 1 + john103C6T6/Core/Inc/dallas_tools.h | 2 +- john103C6T6/Core/Inc/main.h | 4 +- john103C6T6/Core/Inc/stm32f1xx_it.h | 1 + john103C6T6/Core/Src/gpio.c | 6 +- john103C6T6/Core/Src/main.c | 21 ++--- john103C6T6/Core/Src/rtc.c | 50 ++++++------ john103C6T6/Core/Src/stm32f1xx_it.c | 15 ++++ john103C6T6/MDK-ARM/john103C6T6.uvoptx | 32 +++++--- john103C6T6/MDK-ARM/john103C6T6.uvprojx | 4 +- john103C6T6/Modbus/modbus_data.h | 15 ++-- john103C6T6/john103C6T6.ioc | 102 ++++++++++++++---------- 13 files changed, 150 insertions(+), 106 deletions(-) create mode 100644 .gitmodules create mode 160000 external_flash_eeprom diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..52a54f2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external_flash_eeprom"] + path = external_flash_eeprom + url = https://git.arktika.cyou/set506/external_flash_eeprom.git diff --git a/external_flash_eeprom b/external_flash_eeprom new file mode 160000 index 0000000..6ec779c --- /dev/null +++ b/external_flash_eeprom @@ -0,0 +1 @@ +Subproject commit 6ec779c11dab4a2cdee38930058e51ae1bb8939a diff --git a/john103C6T6/Core/Inc/dallas_tools.h b/john103C6T6/Core/Inc/dallas_tools.h index 5ddea86..ab6126d 100644 --- a/john103C6T6/Core/Inc/dallas_tools.h +++ b/john103C6T6/Core/Inc/dallas_tools.h @@ -112,7 +112,7 @@ struct _SensorHandleStruct float set_temp; - int hyst; + uint16_t hyst; DALLAS_HandleTypeDef *hdallas; uint64_t sensROM; ///< ROM-код датчика diff --git a/john103C6T6/Core/Inc/main.h b/john103C6T6/Core/Inc/main.h index 3841e5c..adbf31e 100644 --- a/john103C6T6/Core/Inc/main.h +++ b/john103C6T6/Core/Inc/main.h @@ -63,7 +63,7 @@ typedef struct /* USER CODE BEGIN ET */ #define reset_blink_delay 50 #define rest_iter 10 -#define GPIOB11_valve MB_DATA.Coils.coils.state_val_bit.state_val_01 +#define GPIOB11_valve MB_DATA.Coils.coils[0].state_val_bit.state_val_01 @@ -96,6 +96,8 @@ void Error_Handler(void); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ +#define One_wire_Pin GPIO_PIN_15 +#define One_wire_GPIO_Port GPIOA /* USER CODE BEGIN Private defines */ diff --git a/john103C6T6/Core/Inc/stm32f1xx_it.h b/john103C6T6/Core/Inc/stm32f1xx_it.h index 342b392..03aa6dc 100644 --- a/john103C6T6/Core/Inc/stm32f1xx_it.h +++ b/john103C6T6/Core/Inc/stm32f1xx_it.h @@ -55,6 +55,7 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); +void RTC_IRQHandler(void); void TIM1_BRK_IRQHandler(void); void TIM1_UP_IRQHandler(void); void TIM1_TRG_COM_IRQHandler(void); diff --git a/john103C6T6/Core/Src/gpio.c b/john103C6T6/Core/Src/gpio.c index be0f0dd..ec27cf5 100644 --- a/john103C6T6/Core/Src/gpio.c +++ b/john103C6T6/Core/Src/gpio.c @@ -53,7 +53,7 @@ void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8 - |GPIO_PIN_9|GPIO_PIN_10, GPIO_PIN_RESET); + |GPIO_PIN_9|GPIO_PIN_10|One_wire_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10 @@ -68,10 +68,10 @@ void MX_GPIO_Init(void) /*Configure GPIO pins : PA1 PA2 PA3 PA4 PA5 PA6 PA7 PA8 - PA9 PA10 */ + PA9 PA10 PAPin */ GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8 - |GPIO_PIN_9|GPIO_PIN_10; + |GPIO_PIN_9|GPIO_PIN_10|One_wire_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; diff --git a/john103C6T6/Core/Src/main.c b/john103C6T6/Core/Src/main.c index 689a786..7cff452 100644 --- a/john103C6T6/Core/Src/main.c +++ b/john103C6T6/Core/Src/main.c @@ -58,7 +58,7 @@ uint16_t iter,cnt=5; float temperature; extern uint8_t roms[MAX_DEVICES][8]; //extern uint8_t devices_found ; - uint8_t init=1; + uint8_t _debug_init=1; //TEMP temp_sense[30]; float set_temp_old[30]; char rx_buffer[64]; @@ -144,8 +144,8 @@ int main(void) sens[i].Init.InitParam.Ind = i; sens[i].Init.init_func = &Dallas_SensorInitByInd; sens[i].Init.Resolution = DALLAS_CONFIG_9_BITS; - MB_DATA.HoldRegs.set_Temp[i] =sens[i].set_temp =20.; - sens[i].hyst =3; + MB_DATA.HoldRegs.set_Temp[i] =sens[i].set_temp =20.; + MB_DATA.HoldRegs.set_hyst[i]=sens[i].hyst =1; Dallas_AddNewSensors(&hdallas, &sens[i]); } @@ -155,22 +155,23 @@ int main(void) /* USER CODE BEGIN WHILE */ while (1) { - if (init) + if (_debug_init||MB_DATA.Coils.init_param) { - init=0; + _debug_init=0; MB_DATA.Coils.init_param=0; for(int i=0;iRomCnt;i++) { - MB_DATA.HoldRegs.set_Temp[i]=21; - + sens[i].set_temp=MB_DATA.HoldRegs.set_Temp[i]; + sens[i].hyst=MB_DATA.HoldRegs.set_hyst[i]; } + // init_all_T_sense(); //DS18B20_Search(&DS, &OW); } - init=MB_DATA.Coils.init_param; + Dallas_StartConvertTAll(&hdallas,DALLAS_WAIT_BUS,0); for(int i=0;iRomCnt;i++) @@ -187,7 +188,7 @@ int main(void) { - MB_DATA.Coils.coils.all|=1<sens[i].set_temp+sens[i].hyst) { - MB_DATA.Coils.coils.all&=~(1< 0 ST-LINKIII-KEIL_SWO - -U37FF71064E57343625581443 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL08000 -FP0($$Device:STM32F103C6$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 + -U37FF71064E57343625581443 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL08000 -FP0($$Device:STM32F103C6$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 @@ -168,52 +168,52 @@ 3 1 - MB_DATA,0x0A + hmodbus1 4 1 - hmodbus1 + hiwdg 5 1 - hiwdg + OW 6 1 - OW + _debug_init 7 1 - init + htim1,0x0A 8 1 - htim1,0x0A + DS18B20_DEVICE_AMOUNT 9 1 - DS18B20_DEVICE_AMOUNT + set_temp_old 10 1 - set_temp_old + hrtc.Instance,0x0A 11 1 - MB_DATA.Coils.coils + \\john103C6T6\../Modbus/modbus.c\MB_DATA,0x0A 12 1 - hrtc.Instance,0x0A + sTime @@ -266,6 +266,10 @@ + + System Viewer\BKP + 35895 + System Viewer\GPIOA 35904 @@ -274,6 +278,10 @@ System Viewer\GPIOB 35900 + + System Viewer\GPIOC + 35896 + System Viewer\IWDG 35905 @@ -391,7 +399,7 @@ 2 6 1 - 1 + 0 0 0 ..\Core\Src\ow_port.c diff --git a/john103C6T6/MDK-ARM/john103C6T6.uvprojx b/john103C6T6/MDK-ARM/john103C6T6.uvprojx index f7fd993..bb15279 100644 --- a/john103C6T6/MDK-ARM/john103C6T6.uvprojx +++ b/john103C6T6/MDK-ARM/john103C6T6.uvprojx @@ -133,12 +133,12 @@ 1 0 0 - 0 + 1 1 4101 1 - BIN\UL2V8M.DLL + STLink\ST-LINKIII-KEIL_SWO.dll "" () diff --git a/john103C6T6/Modbus/modbus_data.h b/john103C6T6/Modbus/modbus_data.h index d3ef42b..54f91bb 100644 --- a/john103C6T6/Modbus/modbus_data.h +++ b/john103C6T6/Modbus/modbus_data.h @@ -64,16 +64,17 @@ typedef struct //MB_DataInRegsTypeDef typedef struct //MB_DataInRegsTypeDef { uint16_t set_Temp[MAX_SENSE]; + uint16_t set_hyst[MAX_SENSE]; }MB_DataHoldRegsTypeDef; // DEFINES FOR INPUT REGISTERS ARRAYS #define R_INPUT_ADDR 0 -#define R_INPUT_QNT 10 +#define R_INPUT_QNT 40 // DEFINES FOR HOLDING REGISTERS ARRAYS #define R_HOLDING_ADDR 0 -#define R_HOLDING_QNT 10 +#define R_HOLDING_QNT 40 /** MODBUS_DATA_RERISTERS_DEFINES @@ -108,9 +109,9 @@ typedef struct //MB_DataInRegsTypeDef * @brief Коилы * @details Желательно с помощью reserved делать стркутуру кратной 16-битам */ -typedef union +typedef union { - struct { + struct __packed { unsigned state_val_01:1; unsigned state_val_02:1; unsigned state_val_03:1; @@ -132,11 +133,11 @@ typedef union }word; -typedef struct //MB_DataCoilsTypeDef +typedef struct //MB_DataCoilsTypeDef { - word coils; + word coils[2]; unsigned init_param:1; unsigned reserved:15; @@ -144,7 +145,7 @@ typedef struct //MB_DataCoilsTypeDef // DEFINES FOR COIL ARRAYS #define C_CONTROL_ADDR 0 -#define C_CONTROL_QNT 16 +#define C_CONTROL_QNT 100 /** MODBUS_DATA_COILS_DEFINES * @} diff --git a/john103C6T6/john103C6T6.ioc b/john103C6T6/john103C6T6.ioc index d730eb0..dd7def5 100644 --- a/john103C6T6/john103C6T6.ioc +++ b/john103C6T6/john103C6T6.ioc @@ -33,47 +33,50 @@ Mcu.IPNb=11 Mcu.Name=STM32F103C(4-6)Tx Mcu.Package=LQFP48 Mcu.Pin0=PC13-TAMPER-RTC -Mcu.Pin1=PD0-OSC_IN -Mcu.Pin10=PA7 -Mcu.Pin11=PB0 -Mcu.Pin12=PB1 -Mcu.Pin13=PB2 -Mcu.Pin14=PB10 -Mcu.Pin15=PB11 -Mcu.Pin16=PB12 -Mcu.Pin17=PB13 -Mcu.Pin18=PB14 -Mcu.Pin19=PB15 -Mcu.Pin2=PD1-OSC_OUT -Mcu.Pin20=PA8 -Mcu.Pin21=PA9 -Mcu.Pin22=PA10 -Mcu.Pin23=PA11 -Mcu.Pin24=PA12 -Mcu.Pin25=PA13 -Mcu.Pin26=PA14 -Mcu.Pin27=PB3 -Mcu.Pin28=PB4 -Mcu.Pin29=PB5 -Mcu.Pin3=PA0-WKUP -Mcu.Pin30=PB6 -Mcu.Pin31=PB7 -Mcu.Pin32=PB8 -Mcu.Pin33=PB9 -Mcu.Pin34=VP_ADC1_TempSens_Input -Mcu.Pin35=VP_ADC1_Vref_Input -Mcu.Pin36=VP_RTC_VS_RTC_Activate -Mcu.Pin37=VP_RTC_VS_RTC_Calendar -Mcu.Pin38=VP_SYS_VS_tim3 -Mcu.Pin39=VP_TIM1_VS_ClockSourceINT -Mcu.Pin4=PA1 -Mcu.Pin40=VP_TIM2_VS_ClockSourceINT -Mcu.Pin5=PA2 -Mcu.Pin6=PA3 -Mcu.Pin7=PA4 -Mcu.Pin8=PA5 -Mcu.Pin9=PA6 -Mcu.PinsNb=41 +Mcu.Pin1=PC14-OSC32_IN +Mcu.Pin10=PA5 +Mcu.Pin11=PA6 +Mcu.Pin12=PA7 +Mcu.Pin13=PB0 +Mcu.Pin14=PB1 +Mcu.Pin15=PB2 +Mcu.Pin16=PB10 +Mcu.Pin17=PB11 +Mcu.Pin18=PB12 +Mcu.Pin19=PB13 +Mcu.Pin2=PC15-OSC32_OUT +Mcu.Pin20=PB14 +Mcu.Pin21=PB15 +Mcu.Pin22=PA8 +Mcu.Pin23=PA9 +Mcu.Pin24=PA10 +Mcu.Pin25=PA11 +Mcu.Pin26=PA12 +Mcu.Pin27=PA13 +Mcu.Pin28=PA14 +Mcu.Pin29=PA15 +Mcu.Pin3=PD0-OSC_IN +Mcu.Pin30=PB3 +Mcu.Pin31=PB4 +Mcu.Pin32=PB5 +Mcu.Pin33=PB6 +Mcu.Pin34=PB7 +Mcu.Pin35=PB8 +Mcu.Pin36=PB9 +Mcu.Pin37=VP_ADC1_TempSens_Input +Mcu.Pin38=VP_ADC1_Vref_Input +Mcu.Pin39=VP_RTC_VS_RTC_Activate +Mcu.Pin4=PD1-OSC_OUT +Mcu.Pin40=VP_RTC_VS_RTC_Calendar +Mcu.Pin41=VP_SYS_VS_tim3 +Mcu.Pin42=VP_TIM1_VS_ClockSourceINT +Mcu.Pin43=VP_TIM2_VS_ClockSourceINT +Mcu.Pin5=PA0-WKUP +Mcu.Pin6=PA1 +Mcu.Pin7=PA2 +Mcu.Pin8=PA3 +Mcu.Pin9=PA4 +Mcu.PinsNb=44 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F103C6Tx @@ -87,6 +90,7 @@ NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.RTC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false NVIC.TIM1_BRK_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true @@ -113,6 +117,10 @@ PA13.Mode=Serial_Wire PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Serial_Wire PA14.Signal=SYS_JTCK-SWCLK +PA15.GPIOParameters=GPIO_Label +PA15.GPIO_Label=One_wire +PA15.Locked=true +PA15.Signal=GPIO_Output PA2.Locked=true PA2.Signal=GPIO_Output PA3.Locked=true @@ -161,8 +169,12 @@ PB8.Mode=I2C PB8.Signal=I2C1_SCL PB9.Mode=I2C PB9.Signal=I2C1_SDA -PC13-TAMPER-RTC.Mode=Tamper -PC13-TAMPER-RTC.Signal=RTC_TAMPER +PC13-TAMPER-RTC.Mode=RTC OUT +PC13-TAMPER-RTC.Signal=RTC_OUT +PC14-OSC32_IN.Mode=LSE-External-Oscillator +PC14-OSC32_IN.Signal=RCC_OSC32_IN +PC15-OSC32_OUT.Mode=LSE-External-Oscillator +PC15-OSC32_OUT.Signal=RCC_OSC32_OUT PD0-OSC_IN.Mode=HSE-External-Oscillator PD0-OSC_IN.Signal=RCC_OSC_IN PD1-OSC_OUT.Mode=HSE-External-Oscillator @@ -198,7 +210,7 @@ ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_TIM1_Init-TIM1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_ADC1_Init-ADC1-false-HAL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_TIM1_Init-TIM1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_ADC1_Init-ADC1-false-HAL-true,7-MX_CAN_Init-CAN-false-HAL-true,8-MX_I2C1_Init-I2C1-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true RCC.ADCFreqValue=12000000 RCC.ADCPresc=RCC_ADCPCLK2_DIV6 RCC.AHBFreq_Value=72000000 @@ -222,6 +234,8 @@ RCC.TimSysFreq_Value=72000000 RCC.USBFreq_Value=48000000 RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV1_5 RCC.VCOOutput2Freq_Value=8000000 +RTC.IPParameters=OutPut +RTC.OutPut=RTC_OUTPUTSOURCE_SECOND SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2 SPI1.CalculateBaudRate=36.0 MBits/s SPI1.Direction=SPI_DIRECTION_2LINES