diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..0859405 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "windows-gcc-arm", + "configurationProvider": "ms-vscode.makefile-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/bsp/can/bsp_can.c b/bsp/can/bsp_can.c index 5f2b890..52d09e6 100644 --- a/bsp/can/bsp_can.c +++ b/bsp/can/bsp_can.c @@ -80,7 +80,7 @@ CANInstance *CANRegister(CAN_Init_Config_s *config) LOGERROR("[}bsp_can] CAN id crash ,tx [%d] or rx [%d] already registered", &config->tx_id, &config->rx_id); } } - + CANInstance *instance = (CANInstance *)malloc(sizeof(CANInstance)); // 分配空间 memset(instance, 0, sizeof(CANInstance)); // 分配的空间未必是0,所以要先清空 // 进行发送报文的配置 diff --git a/bsp/dwt/bsp_dwt.c b/bsp/dwt/bsp_dwt.c index 61d95d6..b9703d8 100644 --- a/bsp/dwt/bsp_dwt.c +++ b/bsp/dwt/bsp_dwt.c @@ -16,7 +16,6 @@ static uint32_t CPU_FREQ_Hz, CPU_FREQ_Hz_ms, CPU_FREQ_Hz_us; static uint32_t CYCCNT_RountCount; static uint32_t CYCCNT_LAST; static uint64_t CYCCNT64; -static osMutexId DWT_MUTEX; /** * @brief 私有函数,用于检查DWT CYCCNT寄存器是否溢出,并更新CYCCNT_RountCount @@ -28,16 +27,17 @@ static osMutexId DWT_MUTEX; */ static void DWT_CNT_Update(void) { - if (__get_CONTROL()) // 不在中断中,使用互斥锁;在中断则直接执行即可,本框架将所有中断优先级设置为相同,故不会被其他中断重入 - if (osOK != osMutexWait(DWT_MUTEX, 0)) - return; + static volatile uint8_t bit_locker = 0; + if (!bit_locker) + { + bit_locker = 1; + volatile uint32_t cnt_now = DWT->CYCCNT; + if (cnt_now < CYCCNT_LAST) + CYCCNT_RountCount++; - volatile uint32_t cnt_now = DWT->CYCCNT; - if (cnt_now < CYCCNT_LAST) - CYCCNT_RountCount++; - - CYCCNT_LAST = DWT->CYCCNT; - osMutexRelease(DWT_MUTEX); + CYCCNT_LAST = DWT->CYCCNT; + bit_locker = 0; + } } void DWT_Init(uint32_t CPU_Freq_mHz) @@ -55,8 +55,7 @@ void DWT_Init(uint32_t CPU_Freq_mHz) CPU_FREQ_Hz_ms = CPU_FREQ_Hz / 1000; CPU_FREQ_Hz_us = CPU_FREQ_Hz / 1000000; CYCCNT_RountCount = 0; - osMutexDef(dwt_mutex); - DWT_MUTEX = osMutexCreate(osMutex(dwt_mutex)); + DWT_CNT_Update(); }