<commit_before>// Framework-specific I2C methods, for Arduino and Particle devices

#if defined(ARDUINO) || defined(SPARK)

#ifdef ARDUINO
    #include "Arduino.h"
    #include <Wire.h>
#endif

#ifdef SPARK
    #include "application.h"
#endif

#include "I2CDevice.h"

int8_t I2CDevice::readBytes(uint8_t regAddr, uint8_t length, uint8_t *data) {
    uint8_t count = 0;

    // Select the slave address and register to read from
    Wire.beginTransmission(address);
    Wire.write(regAddr);
    Wire.endTransmission();

    // Request length bytes of data
    Wire.requestFrom(address, length);
    while(Wire.available()) {
        data[count] = Wire.read();
        count++;
    }

    return count;
}

int8_t I2CDevice::readWords(uint8_t regAddr, uint8_t length, uint16_t *data) {
    uint8_t count = 0;

    // Select the slave address and register to read from
    Wire.beginTransmission(address);
    Wire.write(regAddr);
    Wire.endTransmission();

    // Request length*2 bytes of data
    Wire.requestFrom(address, length * 2);
    bool msb = true;
    while(Wire.available()) {
        // Combine bytes into words
        if (msb) {
            data[count] = Wire.read() << 8;
        } else {
            data[count] |= Wire.read();
            count++;
        }
        msb = !msb;
    }

    return count;
}

bool I2CDevice::writeBytes(uint8_t regAddr, uint8_t length, uint8_t *data) {
    // Select the slave address and register to write to
    Wire.beginTransmission(address);
    Wire.write(regAddr);

    // Write the data
    Wire.write(data, length);

    // Finish transmission and return the status
    return (Wire.endTransmission() == 0);
}

bool I2CDevice::writeWords(uint8_t regAddr, uint8_t length, uint16_t *data) {
    // Select the slave address and register to write to
    Wire.beginTransmission(address);
    Wire.write(regAddr);<commit_msg>Fix ambiguous requestFrom call<commit_after>// Framework-specific I2C methods, for Arduino and Particle devices

#if defined(ARDUINO) || defined(SPARK)

#ifdef ARDUINO
    #include "Arduino.h"
    #include <Wire.h>
#endif

#ifdef SPARK
    #include "application.h"
#endif

#include "I2CDevice.h"

int8_t I2CDevice::readBytes(uint8_t regAddr, uint8_t length, uint8_t *data) {
    uint8_t count = 0;

    // Select the slave address and register to read from
    Wire.beginTransmission(address);
    Wire.write(regAddr);
    Wire.endTransmission();

    // Request length bytes of data
    Wire.requestFrom(address, length);
    while(Wire.available()) {
        data[count] = Wire.read();
        count++;
    }

    return count;
}

int8_t I2CDevice::readWords(uint8_t regAddr, uint8_t length, uint16_t *data) {
    uint8_t count = 0;

    // Select the slave address and register to read from
    Wire.beginTransmission(address);
    Wire.write(regAddr);
    Wire.endTransmission();

    // Request length*2 bytes of data
    Wire.requestFrom(address, (uint8_t)(length * 2));
    bool msb = true;
    while(Wire.available()) {
        // Combine bytes into words
        if (msb) {
            data[count] = Wire.read() << 8;
        } else {
            data[count] |= Wire.read();
            count++;
        }
        msb = !msb;
    }

    return count;
}

bool I2CDevice::writeBytes(uint8_t regAddr, uint8_t length, uint8_t *data) {
    // Select the slave address and register to write to
    Wire.beginTransmission(address);
    Wire.write(regAddr);

    // Write the data
    Wire.write(data, length);

    // Finish transmission and return the status
    return (Wire.endTransmission() == 0);
}

bool I2CDevice::writeWords(uint8_t regAddr, uint8_t length, uint16_t *data) {
    // Select the slave address and register to write to
    Wire.beginTransmission(address);
    Wire.write(regAddr);
{'fraction_non_alphanumeric': 0.11381683430386448, 'fraction_numerical': 0.01614610905240868, 'mean_word_length': 2.8878600823045266, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2941722', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1216, 'n_words': 326}