From 2656eff0472262bd13bab16b41a3176a52895d69 Mon Sep 17 00:00:00 2001 From: zhangbo <zhangbo@qq.com> Date: 星期五, 25 七月 2025 16:46:18 +0800 Subject: [PATCH] 添加了运动静止位,V2.15 --- keil/include/drivers/mk_misc.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 92 insertions(+), 6 deletions(-) diff --git a/keil/include/drivers/mk_misc.c b/keil/include/drivers/mk_misc.c index 5fbbdb2..8b4a272 100644 --- a/keil/include/drivers/mk_misc.c +++ b/keil/include/drivers/mk_misc.c @@ -382,14 +382,88 @@ void sys_reset(uint32_t error) { - LOG_INFO(TRACE_MODULE_DRIVER, "system reboot%x", error); + //LOG_INFO(TRACE_MODULE_DRIVER, "system reboot%x", error); delay_us(10000); // reboot reset_module(RESET_MODULE_REBOOT); } - +void delay_US(uint32_t nTimer) +{ + uint32_t i=0; + for(i=0; i<nTimer; i++) { + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); + } +} +void delay_ms(uint32_t nTimer) +{ + uint32_t i=1000*nTimer; + delay_US(i); +} void delay_us(uint32_t cnt) { #define SYSTEM_CLOCK_MHZ 62.4 @@ -425,15 +499,27 @@ "bhi loop%=\n" "pop {r4,r5}\n" "exit%=:\n" - : - : [mult_hi] "i"(SYSTEM_CLOCK_MULT_HI), [mult_lo] "i"(SYSTEM_CLOCK_MULT_LO), [shift] "i"(SYSTEM_CLOCK_LSLS_BITS), [adjust] "i"(AAPCS_PREP_CYCLES), - [decr] "i"(DELAY_LOOP_CYCLES)); + : + : [mult_hi] "i"(SYSTEM_CLOCK_MULT_HI), [mult_lo] "i"(SYSTEM_CLOCK_MULT_LO), [shift] "i"(SYSTEM_CLOCK_LSLS_BITS), [adjust] "i"(AAPCS_PREP_CYCLES), + [decr] "i"(DELAY_LOOP_CYCLES)); #if defined(__GNUC__) && !defined(__ARMCC_VERSION) __asm volatile(".syntax divided\n"); #endif } - +//void delay_us(uint32_t nTimer) +//{ +// uint32_t i=0; +// for(i=0;i<nTimer;i++){ +// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); +// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); +// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); +// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); +// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); +// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); +// __NOP();__NOP();__NOP();__NOP(); +// } +//} uint8_t count_bits(uint32_t value) { uint8_t count = 0; -- Gitblit v1.9.3