F4_softTimer.zip
大小:6.8MB
价格:12积分
下载量:0
评分:
5.0
上传者:m0_58526902
更新日期:2025-09-22

F4-softTimer.zip

资源文件列表(大概)

文件名
大小
F4_softTimer/.mxproject
8.55KB
F4_softTimer/component/
-
F4_softTimer/component/softTimer/
-
F4_softTimer/component/softTimer/MultiTimer.c
1.92KB
F4_softTimer/component/softTimer/MultiTimer.h
2.46KB
F4_softTimer/Core/
-
F4_softTimer/Core/Inc/
-
F4_softTimer/Core/Inc/gpio.h
1.28KB
F4_softTimer/Core/Inc/main.h
1.97KB
F4_softTimer/Core/Inc/stm32f4xx_hal_conf.h
19.55KB
F4_softTimer/Core/Inc/stm32f4xx_it.h
1.94KB
F4_softTimer/Core/Inc/tim.h
1.31KB
F4_softTimer/Core/Inc/usart.h
1.36KB
F4_softTimer/Core/Src/
-
F4_softTimer/Core/Src/gpio.c
1.94KB
F4_softTimer/Core/Src/main.c
6.64KB
F4_softTimer/Core/Src/stm32f4xx_hal_msp.c
2.18KB
F4_softTimer/Core/Src/stm32f4xx_it.c
6.08KB
F4_softTimer/Core/Src/system_stm32f4xx.c
26.94KB
F4_softTimer/Core/Src/tim.c
3.15KB
F4_softTimer/Core/Src/usart.c
3.38KB
F4_softTimer/Drivers/
-
F4_softTimer/Drivers/CMSIS/
-
F4_softTimer/Drivers/CMSIS/Device/
-
F4_softTimer/Drivers/CMSIS/Device/ST/
-
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/
-
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/Include/
-
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h
1.15MB
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
11.94KB
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h
2.26KB
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/LICENSE.txt
377B
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/Source/
-
F4_softTimer/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/
-
F4_softTimer/Drivers/CMSIS/Include/
-
F4_softTimer/Drivers/CMSIS/Include/cachel1_armv7.h
12.21KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_armcc.h
28.21KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_armclang.h
48.75KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_armclang_ltm.h
56.59KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_compiler.h
9.54KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_gcc.h
64.05KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_iccarm.h
29.37KB
F4_softTimer/Drivers/CMSIS/Include/cmsis_version.h
1.68KB
F4_softTimer/Drivers/CMSIS/Include/core_armv81mml.h
274.29KB
F4_softTimer/Drivers/CMSIS/Include/core_armv8mbl.h
114.48KB
F4_softTimer/Drivers/CMSIS/Include/core_armv8mml.h
182.03KB
F4_softTimer/Drivers/CMSIS/Include/core_cm0.h
41.6KB
F4_softTimer/Drivers/CMSIS/Include/core_cm0plus.h
49.77KB
F4_softTimer/Drivers/CMSIS/Include/core_cm1.h
42.58KB
F4_softTimer/Drivers/CMSIS/Include/core_cm23.h
120.95KB
F4_softTimer/Drivers/CMSIS/Include/core_cm3.h
108.86KB
F4_softTimer/Drivers/CMSIS/Include/core_cm33.h
188.28KB
F4_softTimer/Drivers/CMSIS/Include/core_cm35p.h
188.3KB
F4_softTimer/Drivers/CMSIS/Include/core_cm4.h
120.22KB
F4_softTimer/Drivers/CMSIS/Include/core_cm55.h
314.71KB
F4_softTimer/Drivers/CMSIS/Include/core_cm7.h
138KB
F4_softTimer/Drivers/CMSIS/Include/core_cm85.h
305.66KB
F4_softTimer/Drivers/CMSIS/Include/core_sc000.h
46.48KB
F4_softTimer/Drivers/CMSIS/Include/core_sc300.h
107.85KB
F4_softTimer/Drivers/CMSIS/Include/core_starmc1.h
192.04KB
F4_softTimer/Drivers/CMSIS/Include/mpu_armv7.h
11.72KB
F4_softTimer/Drivers/CMSIS/Include/mpu_armv8.h
11.45KB
F4_softTimer/Drivers/CMSIS/Include/pac_armv81.h
6.12KB
F4_softTimer/Drivers/CMSIS/Include/pmu_armv8.h
22.58KB
F4_softTimer/Drivers/CMSIS/Include/tz_context.h
2.69KB
F4_softTimer/Drivers/CMSIS/LICENSE.txt
11.29KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/
-
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/
-
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/
-
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
234.41KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h
12.68KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h
17KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h
7.59KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h
37.76KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h
2.69KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h
14.84KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h
14.51KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h
63.73KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h
2.24KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h
13.68KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h
80.79KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h
14.54KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h
15.84KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h
73.15KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h
434.46KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h
122.19KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h
16.54KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h
45.35KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h
99.52KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h
24.36KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h
107.33KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h
34.2KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h
37.53KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h
31.76KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h
340.04KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h
70.69KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_tim.h
174.88KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h
97.79KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h
10.68KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/LICENSE.txt
383B
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/
-
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
19.34KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
18.85KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
39.87KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
10.34KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c
15.11KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c
24.21KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c
50.05KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c
6.05KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
18.92KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
22.05KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
22.83KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
42.45KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
155.73KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
245.9KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
82.04KB
F4_softTimer/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c
136.16KB
F4_softTimer/F4_softTimer.ioc
5.33KB
F4_softTimer/MDK-ARM/
-
F4_softTimer/MDK-ARM/DebugConfig/
-
F4_softTimer/MDK-ARM/DebugConfig/F4_softTimer_STM32F407ZGTx.dbgconf
2.78KB
F4_softTimer/MDK-ARM/F4_softTimer.uvguix.geek-
176.01KB
F4_softTimer/MDK-ARM/F4_softTimer.uvoptx
16.42KB
F4_softTimer/MDK-ARM/F4_softTimer.uvprojx
19.82KB
F4_softTimer/MDK-ARM/F4_softTimer/
-
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.axf
181.1KB
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.build_log.htm
4.07KB
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.hex
23.65KB
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.htm
72.86KB
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.lnp
1.15KB
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.map
274.65KB
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer.sct
555B
F4_softTimer/MDK-ARM/F4_softTimer/F4_softTimer_F4_softTimer.dep
73.8KB
F4_softTimer/MDK-ARM/F4_softTimer/gpio.crf
796.2KB
F4_softTimer/MDK-ARM/F4_softTimer/gpio.d
1.85KB
F4_softTimer/MDK-ARM/F4_softTimer/gpio.o
4.25KB
F4_softTimer/MDK-ARM/F4_softTimer/main.crf
798.22KB
F4_softTimer/MDK-ARM/F4_softTimer/main.d
1.95KB
F4_softTimer/MDK-ARM/F4_softTimer/main.o
11.44KB
F4_softTimer/MDK-ARM/F4_softTimer/multitimer.crf
9.21KB
F4_softTimer/MDK-ARM/F4_softTimer/multitimer.d
210B
F4_softTimer/MDK-ARM/F4_softTimer/multitimer.o
6.13KB
F4_softTimer/MDK-ARM/F4_softTimer/softtime.crf
1.63KB
F4_softTimer/MDK-ARM/F4_softTimer/softtime.d
120B
F4_softTimer/MDK-ARM/F4_softTimer/softtime.o
13.54KB
F4_softTimer/MDK-ARM/F4_softTimer/startup_stm32f407xx.d
59B
F4_softTimer/MDK-ARM/F4_softTimer/startup_stm32f407xx.o
7.57KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal.crf
793.27KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal.d
1.81KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal.o
19.07KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_cortex.crf
792.65KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_cortex.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_cortex.o
25.3KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_dma.crf
799.31KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_dma.d
1.81KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_dma.o
18.74KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_dma_ex.crf
801.76KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_dma_ex.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_dma_ex.o
9.56KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_exti.crf
794.08KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_exti.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_exti.o
9.89KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash.crf
795.85KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash.o
13.87KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash_ex.crf
795.78KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash_ex.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash_ex.o
13.87KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash_ramfunc.crf
790.9KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash_ramfunc.d
1.83KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_flash_ramfunc.o
604B
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_gpio.crf
794.48KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_gpio.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_gpio.o
10.48KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_msp.crf
795.66KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_msp.d
1.86KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_msp.o
3.07KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_pwr.crf
793.55KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_pwr.d
1.81KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_pwr.o
11.88KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_pwr_ex.crf
792.27KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_pwr_ex.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_pwr_ex.o
6.86KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_rcc.crf
802.03KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_rcc.d
1.81KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_rcc.o
16.54KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_rcc_ex.crf
796KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_rcc_ex.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_rcc_ex.o
9.48KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_tim.crf
858.48KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_tim.d
1.81KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_tim.o
108.86KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_tim_ex.crf
818.69KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_tim_ex.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_tim_ex.o
44.55KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_uart.crf
819.23KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_uart.d
1.82KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_hal_uart.o
57.46KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_it.crf
796.14KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_it.d
1.88KB
F4_softTimer/MDK-ARM/F4_softTimer/stm32f4xx_it.o
11.31KB
F4_softTimer/MDK-ARM/F4_softTimer/system_stm32f4xx.crf
791.51KB
F4_softTimer/MDK-ARM/F4_softTimer/system_stm32f4xx.d
1.78KB
F4_softTimer/MDK-ARM/F4_softTimer/system_stm32f4xx.o
5.51KB
F4_softTimer/MDK-ARM/F4_softTimer/tim.crf
796.22KB
F4_softTimer/MDK-ARM/F4_softTimer/tim.d
1.85KB
F4_softTimer/MDK-ARM/F4_softTimer/tim.o
12.25KB
F4_softTimer/MDK-ARM/F4_softTimer/usart.crf
796.54KB
F4_softTimer/MDK-ARM/F4_softTimer/usart.d
1.85KB
F4_softTimer/MDK-ARM/F4_softTimer/usart.o
12.12KB
F4_softTimer/MDK-ARM/RTE/
-
F4_softTimer/MDK-ARM/RTE/_F4_softTimer/
-
F4_softTimer/MDK-ARM/RTE/_F4_softTimer/RTE_Components.h
348B
F4_softTimer/MDK-ARM/startup_stm32f407xx.lst
70.07KB
F4_softTimer/MDK-ARM/startup_stm32f407xx.s
28.14KB
F4_softTimer/MultiTimer-main/
-
F4_softTimer/MultiTimer-main/.gitignore
28B
F4_softTimer/MultiTimer-main/examples/
-
F4_softTimer/MultiTimer-main/examples/test_linux.c
1.58KB
F4_softTimer/MultiTimer-main/LICENSE
1.04KB
F4_softTimer/MultiTimer-main/Makefile
604B
F4_softTimer/MultiTimer-main/MultiTimer.c
1.92KB
F4_softTimer/MultiTimer-main/MultiTimer.h
2.46KB
F4_softTimer/MultiTimer-main/README.md
3.17KB

资源内容介绍

F4-softTimer.zip
# MultiTimer## IntroductionMultiTimer is a software timer extension module that allows for the expansion of timer tasks as needed, replacing the traditional flag-checking method. It offers a more elegant and convenient way to manage the timing sequences of a program.## How to Use1. Configure the system time base interface and install the timer driver:```cuint64_t PlatformTicksGetFunc(void){ }multiTimerInstall(PlatformTicksGetFunc);```2. Instantiate a timer object:```cMultiTimer timer1;```3. Set the timing, timeout callback function, user data pointer, and start the timer:```cint multiTimerStart(MultiTimer* timer, uint64_t timing, MultiTimerCallback_t callback, void* userData);```4. Call the timer background processing function in the main loop:```cint main(int argc, char *argv[]){ ... while (1) { ... multiTimerYield(); }}```## Limitations1. The clock frequency of the timer directly affects its accuracy. It is recommended to use ticks with higher precision such as 1ms, 5ms, or 10ms.2. The callback function of the timer should not perform time-consuming operations, as this may occupy too much time, causing other timers to not timeout properly.3. Since the timer's callback function is executed within `multiTimerYield`, care should be taken not to use too much stack space to avoid stack overflow.## ExampleThe `test_linux.c` file serves as a demo for Linux platforms, showcasing how to use MultiTimer for creating and managing multiple timers with different intervals and behaviors.```c#include "MultiTimer.h"#include <stdio.h>#include <unistd.h>#include <sys/time.h>// Platform-specific function to get current ticks (milliseconds)uint64_t getPlatformTicks() { struct timeval now; gettimeofday(&now, NULL); return now.tv_sec * 1000LL + now.tv_usec / 1000;}// Callback functions for the timersvoid timerCallback1(MultiTimer* timer, void* userData) { printf("Timer 1 fired at %lu ms\n", getPlatformTicks()); multiTimerStart(timer, 500, timerCallback1, NULL); // Restart timer}void timerCallback2(MultiTimer* timer, void* userData) { printf("Timer 2 fired at %lu ms\n", getPlatformTicks()); multiTimerStart(timer, 1000, timerCallback2, NULL); // Restart timer}void timerCallback3(MultiTimer* timer, void* userData) { printf("Timer 3 (one-shot) fired at %lu ms\n", getPlatformTicks());}void timerCallback4(MultiTimer* timer, void* userData) { printf("Timer 4 is stopping Timer 1 at %lu ms\n", getPlatformTicks()); multiTimerStop((MultiTimer*)userData);}int main() { multiTimerInstall(getPlatformTicks); MultiTimer timer1, timer2, timer3, timer4; multiTimerStart(&timer1, 500, timerCallback1, NULL); // 500 ms repeating multiTimerStart(&timer2, 1000, timerCallback2, NULL); // 1000 ms repeating multiTimerStart(&timer3, 2000, timerCallback3, NULL); // 2000 ms one-shot multiTimerStart(&timer4, 3000, timerCallback4, &timer1); // 3000 ms, stops timer1 // Main loop to simulate time passage and process timers while (1) { multiTimerYield(); usleep(1000); // Sleep for 1 ms } return 0;}```

用户评论 (0)

发表评论

captcha