-3

これらのエラーが発生します:

error: lvalue required as left operand of assignment
error: void value not ignored as it ought to be

基本的に、私は常にスキャンし、スキャンしたデータをチェックし、必要に応じてアクションを実行してから繰り返すi2c静電容量式タッチコントローラーを持っています。

これが私のコードです:

#include <avr/io.h>
#include <util/delay.h> 
#include "i2cmaster.h"

#define mpr03x 0x4A

int main(void)
{
    unsigned char tou;

    DDRA = 0xff;
    DDRB = 0xff;
    PORTA = 0x03;
    _delay_ms(500);
    PORTA = 0x00;

    i2c_init();     //Initialize I2C

    i2c_start_wait(mpr03x+I2C_WRITE);   //Set device address and write mode
    i2c_write(0x44);                    //Write address = 68
    i2c_write(0x03);                    //Calibration = ON, Runmode = 1, Enabled = ELE0, ELE1, ELE2

    while(1)
    {
        PORTA = 0x01;
        i2c_start_wait(mpr03x=I2C_WRITE);   //Set device address and write mode
        i2c_write(0x00);                    //Write address = 68
        i2c_rep_start(mpr03x+I2C_READ);     // set device address and read mode
        tou = i2c_readNak;
        i2c_stop;

        if(tou == 0x00);                    //If no pads are pressed
        {
            PORTA = 0x00;
            _delay_ms(1);
        }
        else
        {
            if(tou == 0x01);                //If pad 1 is pressed
            {
                PORTA = 0x05;
                if(tou == 0x02);            //If pad 2 is pressed
                {
                    PORTA = 0x09;
                    if(tou == 0x03);        //If pad 3 is pressed
                    {
                        PORTA = 0x11;
                        _delay_ms(1000);
                    }
                }
                else
                {
                    if(tou == 0x02);        //If pad 2 is pressed
                    {
                        PORTA = 0x09;
                        if(tou == 0x03);    //If pad 3 is pressed
                        {
                            PORTA = 0x11;
                            _delay_ms(1000);
                        }
                        else
                        {
                            if(tou == 0x03);//If pad 3 is pressed
                            {
                                PORTA = 0x11;
                                _delay_ms(1000);
                            }
                        }
                    }
                }

        }

    }
}`

どんな助けでも大歓迎です。

4

1 に答える 1

0

これは確かに問題を引き起こします:

    i2c_start_wait(mpr03x=I2C_WRITE);   //Set device address and write mode
                         ^

...mpr03x変数ではないためです。

私の仮定では、バックティックは実際には最後の行のコードにはありませんが、とにかく言及します。

他の人が指摘したi2c_stop;ように、間違いのようです。

于 2014-06-27T18:21:01.713 に答える