尝试使用 LoRaFi 库编译 STM32duino 项目时,设备头文件中出现莫名其妙"error: expected ')' before '*' token"错误



我正在尝试编译LoRaFi库中包含的一个示例,用于SX1272 LoRa无线电帽和STM32 IoT节点发现工具包。这是一个STM32duino项目。

该错误特别指向STM32core包中包含的IoT节点的设备标头。

C:UsersmonouDocumentsArduinoDatapackagesSTM32hardwarestm321.9.0system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l475xx.h:1397:43: error: expected ')' before '*' token
1397 | #define CRC                 ((CRC_TypeDef *) CRC_BASE)
|                              ~            ^
C:UsersmonouDocumentsArduinolibrariesLoRaFisrc/LoRaFi.h:122:8: note: in expansion of macro 'CRC'
122 |   void CRC(uint8_t crc = ON);
|        ^~~

这个错误对我来说没有任何意义,因为CRC_TypeDef的结构在标头本身中定义得很好。

typedef struct
{
__IO uint32_t DR;          /*!< CRC Data register,                           Address offset: 0x00 */
__IO uint8_t  IDR;         /*!< CRC Independent data register,               Address offset: 0x04 */
uint8_t       RESERVED0;   /*!< Reserved,                                                    0x05 */
uint16_t      RESERVED1;   /*!< Reserved,                                                    0x06 */
__IO uint32_t CR;          /*!< CRC Control register,                        Address offset: 0x08 */
uint32_t      RESERVED2;   /*!< Reserved,                                                    0x0C */
__IO uint32_t INIT;        /*!< Initial CRC value register,                  Address offset: 0x10 */
__IO uint32_t POL;         /*!< CRC polynomial register,                     Address offset: 0x14 */
} CRC_TypeDef;

然后是CRC自己定义的

#define FLASH               ((FLASH_TypeDef *) FLASH_R_BASE)
#define CRC                 ((CRC_TypeDef *) CRC_BASE)
#define TSC                 ((TSC_TypeDef *) TSC_BASE)

LoRa无线电需要打开CRC,所以我不能只评论LoRaFi.h中的违规代码。我不知道如何解决这个问题。CRC_TypeDef定义正确,CRC也应可定义。

任何帮助都将不胜感激。

如果有帮助的话,下面是LoRaFi提供的例子。值得注意的是,这个错误发生在所有提供的示例中,而不仅仅是这个示例。

// LoRaFi receiving data using interrupt
#include <LoRaFi.h>
//creat object to call functions of LoRaFi library
LoRaFi LoRaFi;
const int messageLength = 11;
char message[messageLength];

void setup() {

//initialize serial communication
Serial.begin(9600);
delay(100);
//initialize LoRa module
LoRaFi.begin();
delay(100);
// activate the interrupt on LoRaFi receiving
LoRaFi.ReceivingInterrupt(receiveMessage);
}
void loop() {
//Just waiting the interrupt and do nothing
delay(1000);
}
//callback function to receve the temperature and humidity using interrupt routine
void receiveMessage()
{
Serial.print("Received Message: ");
//Receive message
LoRaFi.ReceivePackage(message,messageLength);
//Print received message
int i;
for(i=0; i<messageLength; i++)
{
Serial.print(message[i]);
}
Serial.println();
}

不幸的是,这个库写得很糟糕。您有冲突的符号。

注释#define CRC ....,因为您不会使用硬件CRC。

最新更新