CLSH1001-Firmware/include/sw7203/sw7203.c
2024-03-06 15:21:06 -06:00

20 lines
645 B
C

#include <sw7203.h>
#include "driver/i2c.h"
#include "esp_log.h"
esp_err_t sw7203_register_read(i2c_port_t i2c_num, uint8_t i2c_addr, uint8_t reg_addr, uint8_t *data, size_t len)
{
return i2c_master_write_read_device(i2c_num, i2c_addr, &reg_addr, 1, data, len, 14000 / portTICK_PERIOD_MS);
}
esp_err_t sw7203_register_write(i2c_port_t i2c_num, uint8_t i2c_addr, uint8_t reg_addr, uint8_t *data, size_t len)
{
return i2c_master_write_to_device(i2c_num, i2c_addr, data, len, 14000 / portTICK_PERIOD_MS);
}
uint8_t sw7203_I2C_address_find(i2c_port_t i2c_num)
{
esp_err_t errcode;
errcode = i2c_master_probe(i2c_num, 0x22, -1);
}