diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index d1bce9b..df0cd96 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -11,7 +11,7 @@
"defines": [
"USE_STDPERIPH_DRIVER",
"RT_THREAD",
- "STM32F10X_MD"
+ "STM32F10X_HD"
],
"cStandard": "c99",
"cppStandard": "gnu++17",
@@ -27,7 +27,8 @@
],
"defines": [
"USE_STDPERIPH_DRIVER",
- "STM32F10X_MD"
+ "RT_THREAD",
+ "STM32F10X_HD"
],
"cStandard": "c99",
"cppStandard": "gnu++17",
diff --git a/checher_slave.uvoptx b/checher_slave.uvoptx
index d65ac4a..365583f 100644
--- a/checher_slave.uvoptx
+++ b/checher_slave.uvoptx
@@ -459,6 +459,16 @@
+
+
+ System Viewer\TIM4
+ 35905
+
+
+ System Viewer\TIM5
+ 35904
+
+
1
1
@@ -779,8 +789,8 @@
0
0
0
- .\source\core\startup_stm32f10x_md.s
- startup_stm32f10x_md.s
+ .\source\core\startup_stm32f10x_hd.s
+ startup_stm32f10x_hd.s
0
0
@@ -1136,6 +1146,18 @@
0
0
+
+ 4
+ 34
+ 1
+ 0
+ 0
+ 0
+ .\source\interface\if_timer.c
+ if_timer.c
+ 0
+ 0
+
@@ -1146,7 +1168,7 @@
0
5
- 34
+ 35
1
0
0
@@ -1158,7 +1180,7 @@
5
- 35
+ 36
1
0
0
@@ -1170,7 +1192,7 @@
5
- 36
+ 37
1
0
0
@@ -1190,7 +1212,7 @@
0
6
- 37
+ 38
1
0
0
@@ -1202,7 +1224,7 @@
6
- 38
+ 39
1
0
0
@@ -1214,7 +1236,7 @@
6
- 39
+ 40
1
0
0
@@ -1226,7 +1248,7 @@
6
- 40
+ 41
1
0
0
@@ -1238,7 +1260,7 @@
6
- 41
+ 42
1
0
0
@@ -1250,7 +1272,7 @@
6
- 42
+ 43
1
0
0
@@ -1262,7 +1284,7 @@
6
- 43
+ 44
1
0
0
@@ -1274,7 +1296,7 @@
6
- 44
+ 45
1
0
0
@@ -1286,7 +1308,7 @@
6
- 45
+ 46
1
0
0
@@ -1298,7 +1320,7 @@
6
- 46
+ 47
1
0
0
@@ -1310,7 +1332,7 @@
6
- 47
+ 48
1
0
0
@@ -1322,7 +1344,7 @@
6
- 48
+ 49
1
0
0
@@ -1334,7 +1356,7 @@
6
- 49
+ 50
1
0
0
@@ -1346,7 +1368,7 @@
6
- 50
+ 51
1
0
0
@@ -1358,7 +1380,7 @@
6
- 51
+ 52
1
0
0
@@ -1370,7 +1392,7 @@
6
- 52
+ 53
1
0
0
@@ -1382,7 +1404,7 @@
6
- 53
+ 54
1
0
0
@@ -1394,7 +1416,7 @@
6
- 54
+ 55
1
0
0
@@ -1406,7 +1428,7 @@
6
- 55
+ 56
1
0
0
@@ -1418,7 +1440,7 @@
6
- 56
+ 57
1
0
0
@@ -1430,7 +1452,7 @@
6
- 57
+ 58
1
0
0
@@ -1442,7 +1464,7 @@
6
- 58
+ 59
1
0
0
@@ -1454,7 +1476,7 @@
6
- 59
+ 60
1
0
0
@@ -1466,7 +1488,7 @@
6
- 60
+ 61
1
0
0
@@ -1478,7 +1500,7 @@
6
- 61
+ 62
1
0
0
@@ -1490,7 +1512,7 @@
6
- 62
+ 63
1
0
0
@@ -1502,7 +1524,7 @@
6
- 63
+ 64
1
0
0
@@ -1522,7 +1544,7 @@
0
7
- 64
+ 65
1
0
0
@@ -1534,7 +1556,7 @@
7
- 65
+ 66
1
0
0
@@ -1554,7 +1576,7 @@
0
8
- 66
+ 67
1
0
0
@@ -1566,7 +1588,7 @@
8
- 67
+ 68
1
0
0
@@ -1578,7 +1600,7 @@
8
- 68
+ 69
1
0
0
@@ -1590,7 +1612,7 @@
8
- 69
+ 70
1
0
0
@@ -1602,7 +1624,7 @@
8
- 70
+ 71
1
0
0
@@ -1614,7 +1636,7 @@
8
- 71
+ 72
1
0
0
@@ -1626,7 +1648,7 @@
8
- 72
+ 73
1
0
0
@@ -1638,7 +1660,7 @@
8
- 73
+ 74
1
0
0
@@ -1650,7 +1672,7 @@
8
- 74
+ 75
1
0
0
@@ -1662,7 +1684,7 @@
8
- 75
+ 76
1
0
0
@@ -1674,7 +1696,7 @@
8
- 76
+ 77
1
0
0
@@ -1686,7 +1708,7 @@
8
- 77
+ 78
1
0
0
@@ -1698,7 +1720,7 @@
8
- 78
+ 79
1
0
0
@@ -1710,7 +1732,7 @@
8
- 79
+ 80
1
0
0
@@ -1722,7 +1744,7 @@
8
- 80
+ 81
1
0
0
@@ -1734,7 +1756,7 @@
8
- 81
+ 82
1
0
0
@@ -1746,7 +1768,7 @@
8
- 82
+ 83
1
0
0
@@ -1758,7 +1780,7 @@
8
- 83
+ 84
1
0
0
@@ -1770,7 +1792,7 @@
8
- 84
+ 85
2
0
0
@@ -1790,7 +1812,7 @@
0
9
- 85
+ 86
1
0
0
@@ -1802,7 +1824,7 @@
9
- 86
+ 87
1
0
0
@@ -1814,7 +1836,7 @@
9
- 87
+ 88
1
0
0
@@ -1826,7 +1848,7 @@
9
- 88
+ 89
1
0
0
@@ -1838,7 +1860,7 @@
9
- 89
+ 90
1
0
0
@@ -1850,7 +1872,7 @@
9
- 90
+ 91
1
0
0
@@ -1862,7 +1884,7 @@
9
- 91
+ 92
1
0
0
@@ -1874,7 +1896,7 @@
9
- 92
+ 93
1
0
0
@@ -1886,7 +1908,7 @@
9
- 93
+ 94
1
0
0
@@ -1898,7 +1920,7 @@
9
- 94
+ 95
1
0
0
@@ -1910,7 +1932,7 @@
9
- 95
+ 96
1
0
0
@@ -1922,7 +1944,7 @@
9
- 96
+ 97
1
0
0
@@ -1942,7 +1964,7 @@
0
10
- 97
+ 98
1
0
0
@@ -1954,7 +1976,7 @@
10
- 98
+ 99
1
0
0
@@ -1966,7 +1988,7 @@
10
- 99
+ 100
1
0
0
@@ -1978,7 +2000,7 @@
10
- 100
+ 101
1
0
0
@@ -1990,7 +2012,7 @@
10
- 101
+ 102
1
0
0
@@ -2010,7 +2032,7 @@
0
11
- 102
+ 103
1
0
0
@@ -2030,7 +2052,7 @@
0
12
- 103
+ 104
1
0
0
@@ -2042,7 +2064,7 @@
12
- 104
+ 105
1
0
0
@@ -2054,7 +2076,7 @@
12
- 105
+ 106
1
0
0
@@ -2066,7 +2088,7 @@
12
- 106
+ 107
1
0
0
@@ -2078,7 +2100,7 @@
12
- 107
+ 108
1
0
0
@@ -2090,7 +2112,7 @@
12
- 108
+ 109
1
0
0
@@ -2110,7 +2132,7 @@
0
13
- 109
+ 110
5
0
0
@@ -2130,7 +2152,7 @@
0
14
- 110
+ 111
5
0
0
@@ -2142,7 +2164,7 @@
14
- 111
+ 112
5
0
0
diff --git a/checher_slave.uvprojx b/checher_slave.uvprojx
index 7cefcba..7ca0159 100644
--- a/checher_slave.uvprojx
+++ b/checher_slave.uvprojx
@@ -408,9 +408,9 @@
.\source\core\system_stm32f10x.c
- startup_stm32f10x_md.s
+ startup_stm32f10x_hd.s
2
- .\source\core\startup_stm32f10x_md.s
+ .\source\core\startup_stm32f10x_hd.s
@@ -715,6 +715,11 @@
+
+ if_timer.c
+ 1
+ .\source\interface\if_timer.c
+
@@ -3048,9 +3053,9 @@
.\source\core\system_stm32f10x.c
- startup_stm32f10x_md.s
+ startup_stm32f10x_hd.s
2
- .\source\core\startup_stm32f10x_md.s
+ .\source\core\startup_stm32f10x_hd.s
@@ -3304,6 +3309,11 @@
1
.\source\interface\if_can.c
+
+ if_timer.c
+ 1
+ .\source\interface\if_timer.c
+
@@ -4507,9 +4517,9 @@
.\source\core\system_stm32f10x.c
- startup_stm32f10x_md.s
+ startup_stm32f10x_hd.s
2
- .\source\core\startup_stm32f10x_md.s
+ .\source\core\startup_stm32f10x_hd.s
@@ -4763,6 +4773,11 @@
1
.\source\interface\if_can.c
+
+ if_timer.c
+ 1
+ .\source\interface\if_timer.c
+
diff --git a/source/ReadMe.txt b/source/ReadMe.txt
index ad812da..fbb7d7d 100644
--- a/source/ReadMe.txt
+++ b/source/ReadMe.txt
@@ -278,4 +278,5 @@
2023.12.4
只在初次进入检测命令时清除检测结果,检测结束时获取检测结果加入有效性判断
添加广播命令的解析和回复指令
-
+2023.12.5
+ 使用定时器来精确控制数据发送的时间间隙,保证和其他小板不冲突
diff --git a/source/codec/codec.c b/source/codec/codec.c
index 1b72130..58dd569 100644
--- a/source/codec/codec.c
+++ b/source/codec/codec.c
@@ -255,6 +255,7 @@ array_def *protm_decode(protu_def *p,array_def *data)
int dst_addrs=arr_get(r,0)|(arr_get(r,1)<<8)|(arr_get(r,2)<<16);
if((dst_addrs&(1<<(self_addr-1)))!=0){
p->silent=1;
+ p->timer->write(p->timer,0);
arr_remove(r,0,3);
}else{
arr_delete(r);
diff --git a/source/core/startup_stm32f10x_hd.s b/source/core/startup_stm32f10x_hd.s
new file mode 100644
index 0000000..b8b9a17
--- /dev/null
+++ b/source/core/startup_stm32f10x_hd.s
@@ -0,0 +1,358 @@
+;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
+;* File Name : startup_stm32f10x_hd.s
+;* Author : MCD Application Team
+;* Version : V3.5.0
+;* Date : 11-March-2011
+;* Description : STM32F10x High Density Devices vector table for MDK-ARM
+;* toolchain.
+;* This module performs:
+;* - Set the initial SP
+;* - Set the initial PC == Reset_Handler
+;* - Set the vector table entries with the exceptions ISR address
+;* - Configure the clock system and also configure the external
+;* SRAM mounted on STM3210E-EVAL board to be used as data
+;* memory (optional, to be enabled by user)
+;* - Branches to __main in the C library (which eventually
+;* calls main()).
+;* After Reset the CortexM3 processor is in Thread mode,
+;* priority is Privileged, and the Stack is set to Main.
+;* <<< Use Configuration Wizard in Context Menu >>>
+;*******************************************************************************
+; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+;*******************************************************************************
+
+; Amount of memory (in bytes) allocated for Stack
+; Tailor this value to your application needs
+; Stack Configuration
+; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
+;
+
+Stack_Size EQU 0x00000400
+
+ AREA STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem SPACE Stack_Size
+__initial_sp
+
+; Heap Configuration
+; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
+;
+
+Heap_Size EQU 0x00000000
+
+ AREA HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem SPACE Heap_Size
+__heap_limit
+
+ PRESERVE8
+ THUMB
+
+
+; Vector Table Mapped to Address 0 at Reset
+ AREA RESET, DATA, READONLY
+ EXPORT __Vectors
+ EXPORT __Vectors_End
+ EXPORT __Vectors_Size
+
+__Vectors DCD __initial_sp ; Top of Stack
+ DCD Reset_Handler ; Reset Handler
+ DCD NMI_Handler ; NMI Handler
+ DCD HardFault_Handler ; Hard Fault Handler
+ DCD MemManage_Handler ; MPU Fault Handler
+ DCD BusFault_Handler ; Bus Fault Handler
+ DCD UsageFault_Handler ; Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; SVCall Handler
+ DCD DebugMon_Handler ; Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; PendSV Handler
+ DCD SysTick_Handler ; SysTick Handler
+
+ ; External Interrupts
+ DCD WWDG_IRQHandler ; Window Watchdog
+ DCD PVD_IRQHandler ; PVD through EXTI Line detect
+ DCD TAMPER_IRQHandler ; Tamper
+ DCD RTC_IRQHandler ; RTC
+ DCD FLASH_IRQHandler ; Flash
+ DCD RCC_IRQHandler ; RCC
+ DCD EXTI0_IRQHandler ; EXTI Line 0
+ DCD EXTI1_IRQHandler ; EXTI Line 1
+ DCD EXTI2_IRQHandler ; EXTI Line 2
+ DCD EXTI3_IRQHandler ; EXTI Line 3
+ DCD EXTI4_IRQHandler ; EXTI Line 4
+ DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
+ DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
+ DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
+ DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
+ DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
+ DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
+ DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
+ DCD ADC1_2_IRQHandler ; ADC1 & ADC2
+ DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
+ DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; CAN1 RX1
+ DCD CAN1_SCE_IRQHandler ; CAN1 SCE
+ DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
+ DCD TIM1_BRK_IRQHandler ; TIM1 Break
+ DCD TIM1_UP_IRQHandler ; TIM1 Update
+ DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
+ DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
+ DCD TIM2_IRQHandler ; TIM2
+ DCD TIM3_IRQHandler ; TIM3
+ DCD TIM4_IRQHandler ; TIM4
+ DCD I2C1_EV_IRQHandler ; I2C1 Event
+ DCD I2C1_ER_IRQHandler ; I2C1 Error
+ DCD I2C2_EV_IRQHandler ; I2C2 Event
+ DCD I2C2_ER_IRQHandler ; I2C2 Error
+ DCD SPI1_IRQHandler ; SPI1
+ DCD SPI2_IRQHandler ; SPI2
+ DCD USART1_IRQHandler ; USART1
+ DCD USART2_IRQHandler ; USART2
+ DCD USART3_IRQHandler ; USART3
+ DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
+ DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
+ DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
+ DCD TIM8_BRK_IRQHandler ; TIM8 Break
+ DCD TIM8_UP_IRQHandler ; TIM8 Update
+ DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation
+ DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
+ DCD ADC3_IRQHandler ; ADC3
+ DCD FSMC_IRQHandler ; FSMC
+ DCD SDIO_IRQHandler ; SDIO
+ DCD TIM5_IRQHandler ; TIM5
+ DCD SPI3_IRQHandler ; SPI3
+ DCD UART4_IRQHandler ; UART4
+ DCD UART5_IRQHandler ; UART5
+ DCD TIM6_IRQHandler ; TIM6
+ DCD TIM7_IRQHandler ; TIM7
+ DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
+ DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
+ DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
+ DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
+__Vectors_End
+
+__Vectors_Size EQU __Vectors_End - __Vectors
+
+ AREA |.text|, CODE, READONLY
+
+; Reset handler
+Reset_Handler PROC
+ EXPORT Reset_Handler [WEAK]
+ IMPORT __main
+ IMPORT SystemInit
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__main
+ BX R0
+ ENDP
+
+; Dummy Exception Handlers (infinite loops which can be modified)
+
+NMI_Handler PROC
+ EXPORT NMI_Handler [WEAK]
+ B .
+ ENDP
+HardFault_Handler\
+ PROC
+ EXPORT HardFault_Handler [WEAK]
+ B .
+ ENDP
+MemManage_Handler\
+ PROC
+ EXPORT MemManage_Handler [WEAK]
+ B .
+ ENDP
+BusFault_Handler\
+ PROC
+ EXPORT BusFault_Handler [WEAK]
+ B .
+ ENDP
+UsageFault_Handler\
+ PROC
+ EXPORT UsageFault_Handler [WEAK]
+ B .
+ ENDP
+SVC_Handler PROC
+ EXPORT SVC_Handler [WEAK]
+ B .
+ ENDP
+DebugMon_Handler\
+ PROC
+ EXPORT DebugMon_Handler [WEAK]
+ B .
+ ENDP
+PendSV_Handler PROC
+ EXPORT PendSV_Handler [WEAK]
+ B .
+ ENDP
+SysTick_Handler PROC
+ EXPORT SysTick_Handler [WEAK]
+ B .
+ ENDP
+
+Default_Handler PROC
+
+ EXPORT WWDG_IRQHandler [WEAK]
+ EXPORT PVD_IRQHandler [WEAK]
+ EXPORT TAMPER_IRQHandler [WEAK]
+ EXPORT RTC_IRQHandler [WEAK]
+ EXPORT FLASH_IRQHandler [WEAK]
+ EXPORT RCC_IRQHandler [WEAK]
+ EXPORT EXTI0_IRQHandler [WEAK]
+ EXPORT EXTI1_IRQHandler [WEAK]
+ EXPORT EXTI2_IRQHandler [WEAK]
+ EXPORT EXTI3_IRQHandler [WEAK]
+ EXPORT EXTI4_IRQHandler [WEAK]
+ EXPORT DMA1_Channel1_IRQHandler [WEAK]
+ EXPORT DMA1_Channel2_IRQHandler [WEAK]
+ EXPORT DMA1_Channel3_IRQHandler [WEAK]
+ EXPORT DMA1_Channel4_IRQHandler [WEAK]
+ EXPORT DMA1_Channel5_IRQHandler [WEAK]
+ EXPORT DMA1_Channel6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel7_IRQHandler [WEAK]
+ EXPORT ADC1_2_IRQHandler [WEAK]
+ EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
+ EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
+ EXPORT CAN1_RX1_IRQHandler [WEAK]
+ EXPORT CAN1_SCE_IRQHandler [WEAK]
+ EXPORT EXTI9_5_IRQHandler [WEAK]
+ EXPORT TIM1_BRK_IRQHandler [WEAK]
+ EXPORT TIM1_UP_IRQHandler [WEAK]
+ EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
+ EXPORT TIM1_CC_IRQHandler [WEAK]
+ EXPORT TIM2_IRQHandler [WEAK]
+ EXPORT TIM3_IRQHandler [WEAK]
+ EXPORT TIM4_IRQHandler [WEAK]
+ EXPORT I2C1_EV_IRQHandler [WEAK]
+ EXPORT I2C1_ER_IRQHandler [WEAK]
+ EXPORT I2C2_EV_IRQHandler [WEAK]
+ EXPORT I2C2_ER_IRQHandler [WEAK]
+ EXPORT SPI1_IRQHandler [WEAK]
+ EXPORT SPI2_IRQHandler [WEAK]
+ EXPORT USART1_IRQHandler [WEAK]
+ EXPORT USART2_IRQHandler [WEAK]
+ EXPORT USART3_IRQHandler [WEAK]
+ EXPORT EXTI15_10_IRQHandler [WEAK]
+ EXPORT RTCAlarm_IRQHandler [WEAK]
+ EXPORT USBWakeUp_IRQHandler [WEAK]
+ EXPORT TIM8_BRK_IRQHandler [WEAK]
+ EXPORT TIM8_UP_IRQHandler [WEAK]
+ EXPORT TIM8_TRG_COM_IRQHandler [WEAK]
+ EXPORT TIM8_CC_IRQHandler [WEAK]
+ EXPORT ADC3_IRQHandler [WEAK]
+ EXPORT FSMC_IRQHandler [WEAK]
+ EXPORT SDIO_IRQHandler [WEAK]
+ EXPORT TIM5_IRQHandler [WEAK]
+ EXPORT SPI3_IRQHandler [WEAK]
+ EXPORT UART4_IRQHandler [WEAK]
+ EXPORT UART5_IRQHandler [WEAK]
+ EXPORT TIM6_IRQHandler [WEAK]
+ EXPORT TIM7_IRQHandler [WEAK]
+ EXPORT DMA2_Channel1_IRQHandler [WEAK]
+ EXPORT DMA2_Channel2_IRQHandler [WEAK]
+ EXPORT DMA2_Channel3_IRQHandler [WEAK]
+ EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
+
+WWDG_IRQHandler
+PVD_IRQHandler
+TAMPER_IRQHandler
+RTC_IRQHandler
+FLASH_IRQHandler
+RCC_IRQHandler
+EXTI0_IRQHandler
+EXTI1_IRQHandler
+EXTI2_IRQHandler
+EXTI3_IRQHandler
+EXTI4_IRQHandler
+DMA1_Channel1_IRQHandler
+DMA1_Channel2_IRQHandler
+DMA1_Channel3_IRQHandler
+DMA1_Channel4_IRQHandler
+DMA1_Channel5_IRQHandler
+DMA1_Channel6_IRQHandler
+DMA1_Channel7_IRQHandler
+ADC1_2_IRQHandler
+USB_HP_CAN1_TX_IRQHandler
+USB_LP_CAN1_RX0_IRQHandler
+CAN1_RX1_IRQHandler
+CAN1_SCE_IRQHandler
+EXTI9_5_IRQHandler
+TIM1_BRK_IRQHandler
+TIM1_UP_IRQHandler
+TIM1_TRG_COM_IRQHandler
+TIM1_CC_IRQHandler
+TIM2_IRQHandler
+TIM3_IRQHandler
+TIM4_IRQHandler
+I2C1_EV_IRQHandler
+I2C1_ER_IRQHandler
+I2C2_EV_IRQHandler
+I2C2_ER_IRQHandler
+SPI1_IRQHandler
+SPI2_IRQHandler
+USART1_IRQHandler
+USART2_IRQHandler
+USART3_IRQHandler
+EXTI15_10_IRQHandler
+RTCAlarm_IRQHandler
+USBWakeUp_IRQHandler
+TIM8_BRK_IRQHandler
+TIM8_UP_IRQHandler
+TIM8_TRG_COM_IRQHandler
+TIM8_CC_IRQHandler
+ADC3_IRQHandler
+FSMC_IRQHandler
+SDIO_IRQHandler
+TIM5_IRQHandler
+SPI3_IRQHandler
+UART4_IRQHandler
+UART5_IRQHandler
+TIM6_IRQHandler
+TIM7_IRQHandler
+DMA2_Channel1_IRQHandler
+DMA2_Channel2_IRQHandler
+DMA2_Channel3_IRQHandler
+DMA2_Channel4_5_IRQHandler
+ B .
+
+ ENDP
+
+ ALIGN
+
+;*******************************************************************************
+; User Stack and Heap initialization
+;*******************************************************************************
+ IF :DEF:__MICROLIB
+
+ EXPORT __initial_sp
+ EXPORT __heap_base
+ EXPORT __heap_limit
+
+ ELSE
+
+ IMPORT __use_two_region_memory
+ EXPORT __user_initial_stackheap
+
+__user_initial_stackheap
+
+ LDR R0, = Heap_Mem
+ LDR R1, =(Stack_Mem + Stack_Size)
+ LDR R2, = (Heap_Mem + Heap_Size)
+ LDR R3, = Stack_Mem
+ BX LR
+
+ ALIGN
+
+ ENDIF
+
+ END
+
+;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****
diff --git a/source/interface/if_timer.c b/source/interface/if_timer.c
new file mode 100644
index 0000000..b0da7c1
--- /dev/null
+++ b/source/interface/if_timer.c
@@ -0,0 +1,73 @@
+
+
+
+#include "board.h"
+#include "stm32f10x.h"
+
+
+
+static int init(timer_def *t){
+ static int inited=0;
+ if(inited!=0) return 0;
+ inited=1;
+ TIM_TimeBaseInitTypeDef timer;
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE );
+ NVIC_DisableIRQ(TIM4_IRQn);
+ TIM_DeInit(TIM4);
+ timer.TIM_Period = 10000-1; //1s
+ timer.TIM_Prescaler = 7200-1;//1K; //预分频72MHz主频,分频后时钟周期0.1ms
+ timer.TIM_ClockDivision = TIM_CKD_DIV1; //分频
+ timer.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
+ timer.TIM_RepetitionCounter=0;
+ TIM_TimeBaseInit(TIM4,&timer);
+ TIM_SetCounter(TIM4,0);
+ TIM_ARRPreloadConfig(TIM4, ENABLE);
+ TIM_SelectOutputTrigger(TIM4,TIM_TRGOSource_Update);
+ TIM_Cmd(TIM4, ENABLE);
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE );
+ NVIC_DisableIRQ(TIM5_IRQn);
+ TIM_DeInit(TIM5);
+ timer.TIM_Period = 0xffff;//
+ timer.TIM_Prescaler = 0;//不分频
+ timer.TIM_ClockDivision = TIM_CKD_DIV1;
+ timer.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
+ timer.TIM_RepetitionCounter=0;
+ TIM_TimeBaseInit(TIM5,&timer);
+ TIM_SetCounter(TIM5,0);
+ TIM_ARRPreloadConfig(TIM5, ENABLE);
+ TIM_ITRxExternalClockConfig(TIM5, TIM_TS_ITR2);
+ TIM_Cmd(TIM5, ENABLE);
+
+
+ return 0;
+}
+
+static int deinit(timer_def *t){
+ TIM_DeInit(TIM4);
+ TIM_DeInit(TIM5);
+ return 0;
+}
+
+static uint32_t read(timer_def *t)
+{
+ uint32_t ms;
+ ms=TIM_GetCounter(TIM4)/10+TIM_GetCounter(TIM5)*1000;
+ return ms;
+}
+static int write(timer_def *t,const uint32_t value)
+{
+ TIM_Cmd(TIM4,DISABLE);
+ TIM_SetCounter(TIM4,(value%1000)*10);
+ TIM_SetCounter(TIM5,value/1000);
+ TIM_Cmd(TIM4,ENABLE);
+ return 0;
+}
+
+
+
+
+
+timer_init_export(timer,init,deinit,read,write,0);
+
diff --git a/source/interface/if_timer.h b/source/interface/if_timer.h
new file mode 100644
index 0000000..c7ddf2b
--- /dev/null
+++ b/source/interface/if_timer.h
@@ -0,0 +1,17 @@
+
+#ifndef if_timer_h__
+#define if_timer_h__
+
+
+
+
+
+
+
+
+
+#endif
+
+
+
+
diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h
index fe1e720..201e60d 100644
--- a/source/main/compiler_info.h
+++ b/source/main/compiler_info.h
@@ -6,7 +6,7 @@
-#define BUILD_DATE "2023-12-04 17:01:27"
+#define BUILD_DATE "2023-12-05 18:14:33"
#define SOFT_VERSION "2.07"
diff --git a/source/main/main.c b/source/main/main.c
index 38adcc3..1de180b 100644
--- a/source/main/main.c
+++ b/source/main/main.c
@@ -57,7 +57,11 @@ int main()
connect(protu2,protu_recv_signal,0,cmd,cmd_recv_slot);
connect(cmd,cmd_reply_signal,0,protu2,protu_send_call);
-
+
+ timer_def *timer=dev_get("timer");
+ timer->init(timer);
+// rt_thread_mdelay(5000);
+// timer->write(timer,0);
while(1)
{
elec_led2_power(1);
diff --git a/source/rt_thread/board.h b/source/rt_thread/board.h
index 21692ae..9afbb73 100644
--- a/source/rt_thread/board.h
+++ b/source/rt_thread/board.h
@@ -58,6 +58,18 @@ typedef struct __gpioout_def{
+typedef struct __timer_def{
+ const char *name;
+ int (*init)(struct __timer_def *u);
+ int (*deinit)(struct __timer_def *u);
+ uint32_t (*read)(struct __timer_def *u);
+ int (*write)(struct __timer_def *u,const uint32_t value);
+ void *private_data;
+}timer_def;
+
+
+
+
#define CHECK_DO(s,to) if(s) {to(s);}
@@ -136,7 +148,26 @@ typedef struct __gpioout_def{
};
-
+
+
+#define timer_init_export(name_,init_,deinit_,read_,write_,priv_) \
+ const static char __dev_##name_##_name[] SECTION(".rodata.devstr") = #name_; \
+ RT_USED static timer_def _timer_##name_={\
+ .name=__dev_##name_##_name,\
+ .init=init_,\
+ .deinit=deinit_,\
+ .read=read_,\
+ .write=write_,\
+ .private_data=priv_,\
+ };\
+ RT_USED static const struct dev_struct __dev_##name_ SECTION("devstruct")= \
+ { \
+ __dev_##name_##_name, \
+ &_timer_##name_, \
+ };
+
+
+
struct init_struct{
int (*init_fun)(void);
diff --git a/source/task/prot_uc.c b/source/task/prot_uc.c
index 120264d..12128d0 100644
--- a/source/task/prot_uc.c
+++ b/source/task/prot_uc.c
@@ -11,7 +11,8 @@
#include "debug.h"
#include "crc.h"
#include "dev_flash.h"
-
+#include "mymisc.h"
+#include "elec_det.h"
@@ -259,7 +260,8 @@ protu_def *protu_creat(uart_def *uart)
p->uart->init(p->uart,0);
//p->uart->set_irq(p->uart,recv_irq,p);
p->uart->set_end_irq(p->uart,p->buff,RECV_BUFF_SIZE,recv_end_irq,p);
-
+ p->timer=dev_get("timer");
+ p->timer->init(p->timer);
count++;
return p;
}
@@ -275,33 +277,63 @@ int protu_send(protu_def *p,array_def *data)
}
+
+
+typedef struct{
+protu_def *p;
+array_def *t;
+}send_pkt_def;
+
+static void protu_send_later(void *ptr)
+{
+ send_pkt_def *s=ptr;
+ protu_send(s->p,s->t);
+ arr_delete(s->t);
+}
+
+static send_pkt_def g_send_pkt;
+
+
+
+// 在指定时间间隙中发送
+static void protu_send_ontime(protu_def *p,send_pkt_def *s)
+{
+ uint32_t tick=p->timer->read(p->timer);
+ int delay=tick%100;
+ int gap=5*(elec_local_addr()-1);
+ if(delay<=gap){
+ delay=gap-delay;
+ }else{
+ delay=gap+100-delay;
+ }
+ later_execute(protu_send_later,s,delay);
+}
+
+
// 槽函数,回复上位机
void protu_reply_call(protu_def *p,array_def *data)
{
param_check(p);
array_def *t=0;
-// if(p->silent)
-// return;
if(p->codec)
t=p->codec->encode(p,data);
// DBG_LOG("send encode:%s",arr_string(t));
if(t){
- protu_send(p,t);
- arr_delete(t);
+ g_send_pkt.p=p;
+ g_send_pkt.t=t;
+ protu_send_ontime(p,&g_send_pkt);
}
}
+
+
// 槽函数,主动上发
void protu_send_call(protu_def *p,uint8_t cmd,array_def *data)
{
array_def *t=0;
-// if(p->silent)
-// return;
if(cmd!=0){
p->cmd=cmd;
- // 上报数据不增加流水号 2023.7.14
- //p->cmd_no++;
if(p->codec)
t=p->codec->encode(p,data);
}else if(p->cmd==0)
@@ -310,8 +342,9 @@ void protu_send_call(protu_def *p,uint8_t cmd,array_def *data)
t=protu_encode_str(p,data);
}
if(t){
- protu_send(p,t);
- arr_delete(t);
+ g_send_pkt.p=p;
+ g_send_pkt.t=t;
+ protu_send_ontime(p,&g_send_pkt);
}
}
diff --git a/source/task/prot_uc.h b/source/task/prot_uc.h
index fcc3134..ec422a2 100644
--- a/source/task/prot_uc.h
+++ b/source/task/prot_uc.h
@@ -1,3 +1,6 @@
+/*
+ * @text: 测试
+ */
#ifndef prot_uc_h__
#define prot_uc_h__
@@ -32,6 +35,7 @@ struct _protu_def{
int is_big_data;
codec_item *codec;
int silent;// 此项为1,不返回数据
+ timer_def *timer;
};
typedef struct _protu_def protu_def;