我想我找到了另一个“WTF?”:
对于SPI驱动,Peripherals Tool提供了一个回调函数模板:
选择一个 Flexcomm 实例并单击“复制到剪贴板”。
这就是你会得到的:
/* FLEXCOMM3 signal event callback func
tion */
void SPI_SignalEvent(uint32_t event) {
/* Master/Slave Transmit/Receive finished */
if (event & ARM_SPI_EVENT_TRANSFER_DONE) {
/* Place your code here */
}
/* Master/Slave Transmit/Receive incomplete transfer */
if (event & ARM_SPI_EVENT_TRANSFER_INCOMPLETE) {
/* Place your code here */
}
/* Address not acknowledged from Slave */
if (event & ARM_SPI_EVENT_ADDRESS_NACK) {
/* Place your code here */
}
/* Master lost arbitration */
if (event & ARM_SPI_EVENT_ARBITRATION_LOST) {
/* Place your code here */
}
}但是,这不会编译,因为没有定义任何“事件宏”。
文件 Driver_SPI.h 仅定义:
/****** SPI Event *****/
#define ARM_SPI_EVENT_TRANSFER_COMPLETE (1UL << 0) ///< Data Transfer completed
#define ARM_SPI_EVENT_DATA_LOST (1UL << 1) ///< Data lost: Receive overflow / Transmit underflow
#define ARM_SPI_EVENT_MODE_FAULT (1UL << 2) ///< Master Mode Fault (SS deactivated when Master)
这些是ARM 模板驱动程序中指定的“官方”SPI 事件宏。