This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我的代码已经过优化、因为我相信 MSP432 SimpleLink DriverLib 中存在一个宏定义问题。
我正在使用: simplelink_msp432p4_sdk_2_10_00_14
我从 SPI_getEncableInterruptStatus 获取中断标志
// // //! 获取用启用的中断屏蔽的当前 SPI 中断状态。 //! 此函数可用于调用 ISR 以获取暂挂 //! 实际启用的中断、可能导致 //! ISR。 //! //! \param moduleInstance 是 eUSCI A/B 模块的实例。 有效 //! 参数因器件而异、但可能包括: //! -\b EUSCI_A0_BASE //! -\b EUSCI_A1_BASE //! -\b EUSCI_A2_BASE //! -\b EUSCI_A3_base //! -\b EUSCI_B0_BASE //! -\b EUSCI_B1_BASE //! -\b EUSCI_B2_BASE //! -\b EUSCI_B3_base //! //! 修改的寄存器为\b UCAxIFG。 //! //! 将当前中断状态返回为设置标志// ! 遮罩参数可以是以下任一选项: //! -\b EUSCI_SPI_Receive_interrupt -接收中断 //! -\b EUSCI_SPI_Transmit 中断-发送中断 // //************* extern uint_fast8_t SPI_getEnabledInterruptStatus (uint32_t moduleInstance);
注释中的注释是指(EUSCI_SPI_Receive_interrupt 和 EUSCI_SPI_Transmit 中断)。
这些掩码宏也用于:
当我查看宏是如何定义的时、您可以在(ti/simplelink_msp432p4_sdk_2_10_00_14/source/ti/devices/msp432p4xx/driverlib/spi.h)中获得以下内容
#define EUSCI_SPI_Transmit 中断 EUSCI_B_IE_TXIE_OFS #define EUSCI_SPI_RECEIVE_INTERRUPT EUSCI_B_IE_RXIE_OFS
现在问题是 、EUSCI_B_IE_TXIE_OFS 和 EUSCI_B_IE_RXIE_OFS 是指位图偏移、而不是位图值。 这可以在中看到:(TI/simplelink_msp432p4_sdk_2_10_00_14/source/ti/devices/msp432p4xx/inc)
/* EUSCI_B_IE[RXIE]位*/ #define EUSCI_B_IE_RXIE_OFS (0) /*!< UCRXIE 位偏移*/ #define EUSCI_B_IE_RXIE ((uint16_t) 0x0001) /*!<接收中断使能*/ /* EUSCI_B_IE[TXIE]位*/ #define EUSCI_B_IE_TXIE_OFS (1) /*!< UCTXIE 位偏移*/ #define EUSCI_B_IE_TXIE ((uint16_t) 0x0002) /*!<发送中断使能*/
请注意、定义 EUSCI_SPI_Receive_interrupt 的 EUSCI_B_IE_RXIE_OFS 为0、因此对其进行的任何屏蔽检查都将始终失败。 因此、下面的代码始终得到优化。
if (flags & EUSCI_SPI_receive_interrupt) { /* USCI_B0 TX 缓冲器准备好了吗? * while (!(SPI_getInterruptStatus (pCtxt->module、EUSCI_B_SPI_Transmit _interrupt))); rxData = SPI_receiveData (pCtxt->module);
我可以使用我自己对中断屏蔽位的定义来纠正这一点。
但是、我想知道 我是不是对有关"掩码"宏的评论有误解、还是宏定义中有错误?
或者、我在挖掘宏的头文件时意外地复制/粘贴宏的另一种可能性是?