-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
write/read should allow to send/read from any position in the buffer #2
Comments
@FWeinb I cannot reproduce your issue. Today I had some time to look at the library again. It should be fine already in the current version: If you do I did the tests with an ADT7420, here is the full code: #include "brzo_i2c\brzo_i2c.h"
uint8_t SDA_PIN = 5;
uint8_t SCL_PIN = 4;
uint8_t ADT7420_ADR = 0x49;
uint8_t buffer[10];
uint8_t error = 0;
float temp = 0.0;
uint8_t ICACHE_RAM_ATTR get_temp_celsius(float *t) {
uint32_t ADC_code = 0;
uint8_t bcode = 0;
brzo_i2c_start_transaction(ADT7420_ADR, 400);
buffer[0] = 0x03;
buffer[1] = 0xA0;
buffer[5] = 0x03;
buffer[6] = 0xA0;
// sends buffer[0] and buffer[1]
brzo_i2c_write(buffer, 2, false);
// Works, too: I.e. sends buffer[5] and buffer[6]
brzo_i2c_write(&buffer[5], 2, false);
buffer[0] = 0x00;
brzo_i2c_write(buffer, 1, true);
brzo_i2c_read(buffer, 2, false);
bcode = brzo_i2c_end_transaction();
if (bcode == 0) {
ADC_code = ((buffer[0] << 8) | buffer[1]);
*t = ADC_code / 128.0;
return 0;
}
else return bcode;
}
void setup() {
delay(1000);
Serial.begin(115200);
brzo_i2c_setup(SDA_PIN, SCL_PIN, 2000);
}
void loop() {
Serial.println("Waiting 5 seconds...");
delay(5000);
error = get_temp_celsius(&temp);
if (error == 0) {
Serial.print("Temp = ");
Serial.println(temp, 8);
}
else {
Serial.print("Brzo error : ");
Serial.println(error);
}
} |
I will do my tests again. Thank you for investigating. |
I tried the following for communicating with an OLED display using an SSD1306 uint8_t sendBuffer[1];
sendBuffer[0] = 0x40;
brzo_i2c_start_transaction(this->_address, BRZO_I2C_SPEED);
for (uint16_t i=0; i<DISPLAY_BUFFER_SIZE; i += 16) {
brzo_i2c_write(sendBuffer, 1, true);
brzo_i2c_write(&buffer[i], 16, true);
yield();
}
brzo_i2c_end_transaction(); In this example I want to send the whole image (saved in Is it supported to have to |
Without having yet tested/checked your code, I think it should work (concerning the However, after the loop has finished, the last |
brzo_i2c_write/read(uint8_t *data, uint8_t no_of_bytes, boolean repeated_start)
expects a pointer to a buffer
*data
. It then always sends/reads theno_of_bytes
starting from the beginning of the buffer, i.e.data[0]
...data[no_of_bytes - 1]
.Instead,
brzo_i2c_write/read
should allow that any pointer to an elemen (of array of byte) is passed to it and that this then taken as the base address from whichno_of_bytes
is sent/read. E.g.,brzo_i2c_write(&buffer[4], 5, true)
would send 5 bytes starting frombuffer[4]
The text was updated successfully, but these errors were encountered: