imxieyi / esp32-i2c-mpu6050

ESP32 I2C MPU6050 driver for esp-idf
31 stars 16 forks source link

build error inside i2c.cpp #2

Open shantanubanerjee opened 6 years ago

shantanubanerjee commented 6 years ago

A great contribution. I have tried to build this source but I got some error.

make menuconfig

and change the default serial port to /dev/ttyUSB0 but every time I am getting the below error.

CXX build/main/i2c.o /home/shantanu/development/connected_worker/cw_zaphyr/projects/i2c/esp32-i2c-mpu6050-master/main/./i2c.cpp: In member function 'bool I2C::slave_read(uint8_t, uint8_t, uint8_t, uint32_t)': /home/shantanu/development/connected_worker/cw_zaphyr/projects/i2c/esp32-i2c-mpu6050-master/main/./i2c.cpp:50:50: error: cannot convert 'bool' to 'i2c_ack_type_t' for argument '3' to 'esp_err_t i2c_master_read_byte(i2c_cmd_handle_t, uint8_t, i2c_ack_type_t)' i2c_master_read_byte(cmd, buf, (len == 1)); ^ /home/shantanu/development/connected_worker/cw_zaphyr/projects/i2c/esp32-i2c-mpu6050-master/main/./i2c.cpp: In member function 'uint8_t I2C::slave_read_byte(uint8_t, uint8_t)': /home/shantanu/development/connected_worker/cw_zaphyr/projects/i2c/esp32-i2c-mpu6050-master/main/./i2c.cpp:77:38: error: invalid conversion from 'int' to 'i2c_ack_type_t' [-fpermissive] i2c_master_read_byte(cmd, &buf, 1); ^ In file included from /home/shantanu/development/connected_worker/cw_zaphyr/projects/i2c/esp32-i2c-mpu6050-master/main/include/i2c.hpp:3:0, from /home/shantanu/development/connected_worker/cw_zaphyr/projects/i2c/esp32-i2c-mpu6050-master/main/./i2c.cpp:1: /home/shantanu/development/connected_worker/cw_zaphyr/esp-idf/components/driver/include/driver/i2c.h:298:11: note: initializing argument 3 of 'esp_err_t i2c_master_read_byte(i2c_cmd_handle_t, uint8_t, i2c_ack_type_t)' esp_err_t i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, uint8_t data, i2c_ack_type_t ack); ^ /home/shantanu/development/connected_worker/cw_zaphyr/esp-idf/make/component_wrapper.mk:273: recipe for target 'i2c.o' failed make[1]: [i2c.o] Error 1 /home/shantanu/development/connected_worker/cw_zaphyr/esp-idf/make/project.mk:450: recipe for target 'component-main-build' failed make: [component-main-build] Error 2

@imxieyi Could you please help me to fix this..

pfrench42 commented 6 years ago

line 50 becomes:

    i2c_master_read_byte(cmd, buf, (len == 1) ? I2C_MASTER_NACK : I2C_MASTER_ACK );

line 77 becomes:

i2c_master_read_byte(cmd, &buf, I2C_MASTER_NACK );