2022-02-27 01:37 PM
I have this functions to work with:
void write8(uint8_t reg, uint32_t value)
read8(uint8_t reg)
I am a newbie when it comes to c programming and have little knowledge when it comes to registers and how to write and read them.
Right now the functions look something like this:
void Adafruit_TCS34725::write8(uint8_t reg, uint32_t value) {
uint8_t buffer[2] = {TCS34725_COMMAND_BIT | reg, value & 0xFF};
i2c_dev->write(buffer, 2);
}
uint8_t Adafruit_TCS34725::read8(uint8_t reg) {
uint8_t buffer[1] = {TCS34725_COMMAND_BIT | reg};
i2c_dev->write_then_read(buffer, 1, buffer, 1);
return buffer[0];
}
Please help :(
Solved! Go to Solution.
2022-02-28 04:44 AM
2022-02-27 10:19 PM
Check out the HAL_I2C_Mem_Write and HAL_I2C_Mem_Read functions. There are also STM32 ports out in the web for your studies.
hth
KnarfB
2022-02-28 04:39 AM
Thank you for your reply!
I have tried looking for relevant stm32 ports but I could not find any. Would you mind reffering me one?
regarding the functions. I find it difficult to fill out all the parameters required for those two. As far as i know, the trasmit and recieve do the same without a memory adress. Since Adafruit_TCS34725::write8 only uses two parameters containing reg and value, how would I fill out the other ones?
Thanks!
2022-02-28 04:44 AM
2022-02-28 05:10 AM
Thank you so much. Great help!