在Mbed中,“ main.cpp”中不允许使用合格名称来修复我的代码?

时间:2019-10-17 07:29:59

标签: mbed

我正在研究使用mbed(mbed LPX LPC1768板)的IAQ_core气体传感器

但是我失败了。

我想在带有气体传感器的串行监视器上查看数据。

请帮助我

我试图输入其他代码。

AQ_Core::iAQ_Core_status_t  
iAQ_Core::iAQ_Core_GetNewReading(iAQ_Core_data_t* myData)  (error 
//Qualified name is not allowed in "main.cpp")


iAQ_Core::iAQ_Core_status_t iAQ_Core_GetNewReading(iAQ_Core_data_t* 
myData)
(Error: Identifier "iAQ_Core_data_t" is undefined in "main.cpp", )

我尝试使用“;”在代码末尾,但是出现了相同的错误。

我尝试删除int main(),但出现了相同的错误。

///////////////////////////////head(iAQ_Core.h)///////////////////////////////////////
#include "mbed.h"

class iAQ_Core
{
public:
    typedef enum {
        IAQ_Core_ADDRess = 0x5A      //address         

    }IAQ_Core_address_t;

    typedef enum {                          //status 
        IAQ_Core_STATUS_OK = 0x00,
        IAQ_Core_STATUS_RUNIN = 0x10,
        IAQ_Core_STATUS_BUSY = 0x01,
        IAQ_Core_STATUS_ERROR = 0x80
    }iAQ_Core_status_flag_t;

    typedef struct {                   ////
        uint16_t pred;                 //Prediction=byte0 *2^8 + byte1 
        iAQ_Core_status_flag_t status;
        uint32_t resistance;           //Resistance = byte4*2^16 + byte5*2^8 + byte6
        uint16_t Tvoc;                 //Tvoc eq = byte7*2^8 + byte8
    }iAQ_Core_data_t;

    typedef enum {
        IAQ_Core_SUCCESS = 0,
        IAQ_Core_FAILURE = 1,
        I2C_SUCCESS = 0
    }iAQ_Core_status_t;


    // iAQ_Core ( PinName sda, PinName scl, uint32_t addr );  //


    iAQ_Core_status_t iAQ_Core_GetNewReading(iAQ_Core_data_t* myData);     //
//}iAQ_Core_I2C_data_t;

private:
    I2C i2c;  //i2c
    uint32_t iAQ_Core_Addr;  //

};
////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////main.cpp////////////////////////////////////////
#include "iAQ_Core.h"


Serial pc(USBTX, USBRX);
I2C iAQ_Core(p28, p27);

int main() {
    pc.baud(115200);
    int iAQ_Core_Addr = 0x5A;



    iAQ_Core::iAQ_Core_status_t  
    iAQ_Core::iAQ_Core_GetNewReading(iAQ_Core_data_t* myData)//(error 
    word)Error: Qualified name is not allowed in "main.cpp"

    {
        char     cmd[9] = { 0 };
        uint32_t aux = 0;


        /* Get the data */
        aux = i2c.read(iAQ_Core_Addr, &cmd[0], sizeof(cmd) /        
                       sizeof(cmd[0]));


        /* Update the parameters    */
        myData->pred = ((cmd[0] << 8) + cmd[1]);                           
        myData->status = (iAQ_Core_status_flag_t)cmd[2];
        myData->resistance = ((cmd[4] << 16) + (cmd[5] << 8) + cmd[6]);        
        myData->Tvoc = ((cmd[7] << 8) + cmd[8]);                           



    //check
        if (aux == I2C_SUCCESS) {
            printf("SUCCESS");
            return   IAQ_Core_SUCCESS;
        }
        else {
            printf("FAILURE");
            return   IAQ_Core_FAILURE;
             }
        }
    }

错误:“ main.cpp”中不允许使用限定名称,

0 个答案:

没有答案