mega 2560 编译报错-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 311|回复: 1

[已解答] mega 2560 编译报错

[复制链接]
发表于 2022-8-21 13:59 | 显示全部楼层 |阅读模式
/*
Test on MEGA 2560. use WT901CTTL sensor

WT901CTTL     MEGA 2560
    VCC <--->  5V/3.3V
    TX  <--->  19(TX1)
    RX  <--->  18(RX1)
    GND <--->  GND
*/
#include <REG.h>
#include <wit_c_sdk.h>
#define BLINKER_BLE
#include <Blinker.h>

BlinkerNumber PITCH("num-pitch");
BlinkerNumber ROLL("num-roll");

//#define ACC_UPDATE    0x01
//#define GYRO_UPDATE   0x02
#define ANGLE_UPDATE  0x04
//#define MAG_UPDATE    0x08
#define READ_UPDATE   0x80
static volatile char s_cDataUpdate = 0, s_cCmd = 0xff;

static void CmdProcess(void);
static void AutoScanSensor(void);
static void SensorUartSend(uint8_t *p_data, uint32_t uiSize);
static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum);
static void Delayms(uint16_t ucMs);
const uint32_t c_uiBaud[8] = {0,4800, 9600, 19200, 38400, 57600, 115200, 230400};


//void send_blinker()
//{   
//    PITCH.print(pitch_read);
//    ROLL.print(roll_read);
//    timer2 = millis();
//}

//void dataStorage(){
//   Blinker.dataStorage("num-pitch", pitch);
//   Blinker.dataStorage("num-roll", roll);
//}

void setup()
{
  Serial.begin(115200);

//  BLINKER_DEBUG.stream(Serial);
//  pinMode(LED_BUILTIN, OUTPUT);
//  digitalWrite(LED_BUILTIN, LOW);

//  Blinker.begin(15, 14, 9600);
//  Blinker.attachData(dataStorage);

  WitInit(WIT_PROTOCOL_NORMAL, 0x50);
  WitSerialWriteRegister(SensorUartSend);
  WitRegisterCallBack(SensorDataUpdata);
  WitDelayMsRegister(Delayms);
  Serial.print("\r\n********************** wit-motion normal example  ************************\r\n");
  AutoScanSensor();
}
int i;
float fAngle[3];
void loop()
{
//  timer = millis();
    while (Serial1.available())
    {
      WitSerialDataIn(Serial1.read());
    }
    while (Serial.available())
    {
      CopeCmdData(Serial.read());
    }
  // Print values
    if(s_cDataUpdate)
    {
      for(i = 0; i < 3; i++)
      {
        fAngle[i] = sReg[Roll+i] / 32768.0f * 180.0f;
      }
      if(s_cDataUpdate & ANGLE_UPDATE)
      {
        Serial.print("angle:");
        Serial.print(fAngle[0], 3);
        Serial.print(" ");
        Serial.print(fAngle[1], 3);
        Serial.print(" ");
        Serial.print(fAngle[2], 3);
        Serial.print("\r\n");
        s_cDataUpdate &= ~ANGLE_UPDATE;
      }
      s_cDataUpdate = 0;
    }
//  delay((timeStep*1000) - (millis() - timer)); //makes sure we read only at a an interval of 0.01 secounds

//    PITCH.print(pitch);
//    ROLL.print(roll);
//    Blinker.run();
//    Blinker.delay(50);
  

//  if ((millis()-timer2) > 200)
//    {
//      pitch_read = pitch;
//      roll_read = roll;
//    }
  
}
void CopeCmdData(unsigned char ucData)
{
  static unsigned char s_ucData[50], s_ucRxCnt = 0;
  
  s_ucData[s_ucRxCnt++] = ucData;
  if(s_ucRxCnt<3)return;                    //Less than three data returned
  if(s_ucRxCnt >= 50) s_ucRxCnt = 0;
  if(s_ucRxCnt >= 3)
  {
    if((s_ucData[1] == '\r') && (s_ucData[2] == '\n'))
    {
      s_cCmd = s_ucData[0];
      memset(s_ucData,0,50);
      s_ucRxCnt = 0;
    }
    else
    {
      s_ucData[0] = s_ucData[1];
      s_ucData[1] = s_ucData[2];
      s_ucRxCnt = 2;
      
    }
  }
}
static void SensorUartSend(uint8_t *p_data, uint32_t uiSize)
{
  Serial1.write(p_data, uiSize);
  Serial1.flush();
}
static void Delayms(uint16_t ucMs)
{
  delay(ucMs);
}
static void SensorDataUpdata(uint32_t uiReg, uint32_t uiRegNum)
{
  int i;
    for(i = 0; i < uiRegNum; i++)
    {
        switch(uiReg)
        {
            case Yaw:
        s_cDataUpdate |= ANGLE_UPDATE;
            break;
            default:
        s_cDataUpdate |= READ_UPDATE;
      break;
        }
    uiReg++;
    }
}

static void AutoScanSensor(void)
{
  int i, iRetry;
  
  for(i = 0; i < sizeof(c_uiBaud)/sizeof(c_uiBaud[0]); i++)
  {
    Serial1.begin(c_uiBaud[i]);
    Serial1.flush();
    iRetry = 2;
    s_cDataUpdate = 0;
    do
    {
      WitReadReg(AX, 3);
      delay(200);
      while (Serial1.available())
      {
        WitSerialDataIn(Serial1.read());
      }
      if(s_cDataUpdate != 0)
      {
        Serial.print(c_uiBaud[i]);
        Serial.print(" baud find sensor\r\n\r\n");
//        ShowHelp();
        return ;
      }
      iRetry--;
    }while(iRetry);   
  }
  Serial.print("can not find sensor\r\n");
  Serial.print("please check your connection\r\n");
}
In file included from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/BlinkerSerialBLE.h:25:0,
                 from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker.h:21,
                 from F:\qingjiaoyi\qingjiaoyi\qingjiaoyiblinker\qingjiaoyiblinker.ino:8:
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Adapters/BlinkerSerial.h: In member function 'virtual char* BlinkerSerial::lastRead()':
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Adapters/BlinkerSerial.h:36:75: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
         char * lastRead()   { if (isFresh) return streamData; else return ""; }
                                                                           ^~
In file included from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerApi.h:96:0,
                 from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/BlinkerSerialBLE.h:26,
                 from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker.h:21,
                 from F:\qingjiaoyi\qingjiaoyi\qingjiaoyiblinker\qingjiaoyiblinker.ino:8:
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::dataParse()':
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerProtocol.h:257:86: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
         char* dataParse()       { if (canParse) return conn->lastRead(); else return ""; }
                                                                                      ^~
In file included from F:\qingjiaoyi\qingjiaoyi\qingjiaoyiblinker\qingjiaoyiblinker.ino:5:0:
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerApi.h: At global scope:
F:\qingjiaoyi\arduino-1.8.19\libraries\ArduinoJ61/REG.h:73:17: error: expected identifier before numeric constant
#define Yaw     0x3f
                 ^
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerApi.h:106:5: note: in expansion of macro 'Yaw'
     Yaw,
     ^~~
F:\qingjiaoyi\arduino-1.8.19\libraries\ArduinoJ61/REG.h:73:17: error: expected '}' before numeric constant
#define Yaw     0x3f
                 ^
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerApi.h:106:5: note: in expansion of macro 'Yaw'
     Yaw,
     ^~~
F:\qingjiaoyi\arduino-1.8.19\libraries\ArduinoJ61/REG.h:73:17: error: expected unqualified-id before numeric constant
#define Yaw     0x3f
                 ^
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerApi.h:106:5: note: in expansion of macro 'Yaw'
     Yaw,
     ^~~
In file included from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/BlinkerSerialBLE.h:26:0,
                 from F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker.h:21,
                 from F:\qingjiaoyi\qingjiaoyi\qingjiaoyiblinker\qingjiaoyiblinker.ino:8:
F:\qingjiaoyi\arduino-1.8.19\libraries\blinker-library-0.3.9\src/Blinker/BlinkerApi.h:109:1: error: expected declaration before '}' token
};
^
exit status 1
为开发板 Arduino Mega or Mega 2560 编译时出错。
发表于 2022-8-21 23:10 | 显示全部楼层
F:\qingjiaoyi\arduino-1.8.19\libraries\ArduinoJ61/REG.h:73:17: error: expected identifier before numeric constant
#define Yaw     0x3f

看起来是您引用的库报错了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 08:32 , Processed in 0.096933 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表