Hi everyone
I have read espressif's document about how to use i2c. I also read example and i know how to send one byte. But how can i send byte (slave address) then register address and finally value that i want to write into this register?
Slave address: 0xD0
Register address: 0x0E
Value: 0x0
I am using eclipse with esp-idf
i2c how to set register in ds3231
Re: i2c how to set register in ds3231
Have you looked at the examples for I2c?
Code: Select all
I2C_WriteByte(0xD0, 0x0E, 0x00);
esp_err_t I2C_WriteByte(uint8_t icAddress, uint8_t reg, uint8_t value)
{
esp_err_t espRc;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (icAddress << 1) | I2C_MASTER_WRITE, ACK_CHECK_EN);
i2c_master_write_byte(cmd, reg, ACK_CHECK_EN);
i2c_master_write_byte(cmd, value, ACK_CHECK_EN);
i2c_master_stop(cmd);
espRc = i2c_master_cmd_begin(I2C_NUM_1, cmd, 10 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (espRc == ESP_FAIL)
{
printf("WriteByte Fail\r\n");
}
return espRc;
}
Re: i2c how to set register in ds3231
Yes, i have looked. Thank you very much, that's what i was looking for
Who is online
Users browsing this forum: Bing [Bot] and 122 guests