diff --git a/src/ldc1612.c b/src/ldc1612.c index f8c4fbf..0dedb02 100644 --- a/src/ldc1612.c +++ b/src/ldc1612.c @@ -12,7 +12,7 @@ void ldc1612_set_conversion_time(uint8_t channel, uint16_t result) { uint8_t data[2] = {0}; data[0] = (result >> 8) & 0xFF; data[1] = result & 0xFF; - i2c_read_16bits(LDC1612_ADDR, SET_CONVERSION_TIME_REG_START + channel, data); + i2c_write_16bits(LDC1612_ADDR, SET_CONVERSION_TIME_REG_START + channel, data); } /** @brief set conversion offset. @@ -23,7 +23,7 @@ void ldc1612_set_conversion_offset(uint8_t channel, uint16_t result) { uint8_t data[2] = {0}; data[0] = (result >> 8) & 0xFF; data[1] = result & 0xFF; - i2c_read_16bits(LDC1612_ADDR, SET_CONVERSION_OFFSET_REG_START + channel, data); + i2c_write_16bits(LDC1612_ADDR, SET_CONVERSION_OFFSET_REG_START + channel, data); } /** @brief Before conversion,wait LC sensor stabilize for a short time. @@ -34,7 +34,7 @@ void ldc1612_set_LC_stabilize_time(uint8_t channel, uint16_t result) { uint8_t data[2] = {0}; data[0] = (result >> 8) & 0xFF; data[1] = result & 0xFF; - i2c_read_16bits(LDC1612_ADDR, SET_LC_STABILIZE_REG_START + channel, data); + i2c_write_16bits(LDC1612_ADDR, SET_LC_STABILIZE_REG_START + channel, data); } /** @brief set input frequency divide and fref divide. @@ -66,7 +66,7 @@ void ldc1612_set_freq_divide(uint8_t channel) { data[1] = value & 0xFF; // printf("\tFIN_DIV: %d, FREF_DIV: %d\r\n", fin_div, freq_div); - i2c_read_16bits(LDC1612_ADDR, SET_FREQ_REG_START + channel, data); + i2c_write_16bits(LDC1612_ADDR, SET_FREQ_REG_START + channel, data); } /** @brief Error output config. @@ -77,7 +77,7 @@ void ldc1612_set_error_config(uint16_t value) { data[0] = (value >> 8) & 0xFF; data[1] = value & 0xFF; - i2c_read_16bits(LDC1612_ADDR, ERROR_CONFIG_REG, data); + i2c_write_16bits(LDC1612_ADDR, ERROR_CONFIG_REG, data); } /** @brief mux config. @@ -88,7 +88,7 @@ void ldc1612_set_mux_config(uint16_t value) { data[0] = (value >> 8) & 0xFF; data[1] = value & 0xFF; - i2c_read_16bits(LDC1612_ADDR, MUL_CONFIG_REG, data); + i2c_write_16bits(LDC1612_ADDR, MUL_CONFIG_REG, data); } /** @brief reset sensor. @@ -98,7 +98,7 @@ void ldc1612_reset_sensor(void) { uint8_t data[2] = {0}; data[0] = 0x80; data[1] = 0x00; - i2c_read_16bits(LDC1612_ADDR, SENSOR_RESET_REG, data); + i2c_write_16bits(LDC1612_ADDR, SENSOR_RESET_REG, data); } /** @brief set drive current of sensor. @@ -109,7 +109,7 @@ void ldc1612_set_drive_current(uint8_t channel, uint16_t value) { data[0] = (value >> 8) & 0xFF; data[1] = value & 0xFF; - i2c_read_16bits(LDC1612_ADDR, SET_DRIVER_CURRENT_REG + channel, data); + i2c_write_16bits(LDC1612_ADDR, SET_DRIVER_CURRENT_REG + channel, data); } /** @brief Main config part of sensor.Contains select channel、start conversion、sleep mode、sensor activation mode、INT pin disable .. @@ -120,7 +120,7 @@ void ldc1612_set_sensor_config(uint16_t value) { data[0] = (value >> 8) & 0xFF; data[1] = value & 0xFF; - i2c_read_16bits(LDC1612_ADDR, SENSOR_CONFIG_REG, data); + i2c_write_16bits(LDC1612_ADDR, SENSOR_CONFIG_REG, data); } void ldc1612_single_ch0_config(void) {