#include #include "max6884.h" #include "dwt.h" #include "gpio.h" #include "cmd.h" #define ADDR 0x52 static i2c_t _i2c; int i2c6884_read(uint8_t slv_addr, uint8_t reg, signed char *buf, uint32_t count) { i2c_start(_i2c); i2c_send_byte(_i2c, (slv_addr << 1)); if(i2c_wait_ack(_i2c)) { i2c_stop(_i2c); printf("address no ack\r\n"); return -1; } i2c_send_byte(_i2c, reg); if(i2c_wait_ack(_i2c)) { i2c_stop(_i2c); return -1; } i2c_start(_i2c); i2c_send_byte(_i2c,(slv_addr << 1) | 0x1); if(i2c_wait_ack(_i2c)) { i2c_stop(_i2c); return -1; } for(int i=0; i