From b5dc11acf7d70e2ddcff627db25445e2588b3f7a Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期六, 28 五月 2022 10:34:48 +0800 Subject: [PATCH] V1.64 增加碰撞随机跳时间片 --- 源码/核心板/Src/ExternalDevices/dw_driver.c | 72 +++++++++++++++++++++++++++++++++++- 1 files changed, 70 insertions(+), 2 deletions(-) diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c" index 62b7c23..a4c252b 100644 --- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c" +++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c" @@ -1,5 +1,5 @@ #include "dw_driver.h" -#include "deca_sleep.h" +#include "deca_device_api.h" void Reset_DW1000(void) { @@ -50,7 +50,75 @@ EXTI_InitStructure.EXTI_Line = DECAIRQ_EXTI; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //MPW3 IRQ polarity is high by default - EXTI_InitStructure.EXTI_LineCmd = DISABLE; + EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } + +//读取外部中断状态 +ITStatus Get_Ext_IRQ_Statues(void) +{ + return EXTI_GetITStatus(DECAIRQ_EXTI); +} + + +//使能外部中断 +void Enable_Ext_IRQ(void) +{ + NVIC_EnableIRQ(DECAIRQ_EXTI_IRQn); +} + +//禁止外部中断 +void Disable_Ext_IRQ(void) +{ + NVIC_DisableIRQ(DECAIRQ_EXTI_IRQn); +} + +/*! ------------------------------------------------------------------------------------------------------------------ + * Function: decamutexon() + * + * Description: This function should disable interrupts. This is called at the start of a critical section + * It returns the irq state before disable, this value is used to re-enable in decamutexoff call + * + * Note: The body of this function is defined in deca_mutex.c and is platform specific + * + * input parameters: + * + * output parameters + * + * returns the state of the DW1000 interrupt + */ +decaIrqStatus_t decamutexon(void) +{ + decaIrqStatus_t s = Get_Ext_IRQ_Statues(); + + if(s) + { + Disable_Ext_IRQ(); //disable the external interrupt line + } + return s ; // return state before disable, value is used to re-enable in decamutexoff call +} + +/*! ------------------------------------------------------------------------------------------------------------------ + * Function: decamutexoff() + * + * Description: This function should re-enable interrupts, or at least restore their state as returned(&saved) by decamutexon + * This is called at the end of a critical section + * + * Note: The body of this function is defined in deca_mutex.c and is platform specific + * + * input parameters: + * @param s - the state of the DW1000 interrupt as returned by decamutexon + * + * output parameters + * + * returns the state of the DW1000 interrupt + */ +void decamutexoff(decaIrqStatus_t s) // put a function here that re-enables the interrupt at the end of the critical section +{ + if(s) //need to check the port state as we can't use level sensitive interrupt on the STM ARM + { + Enable_Ext_IRQ(); + } +} + -- Gitblit v1.9.3