<commit_before>// i2c libary for intel edison
// Taken for the embed project changes made for intel edison

// The MIT License (MIT)
// Copyright (c) 2015 NeuralSpaz
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package i2c

import (
	"fmt"
	"os"
	"reflect"
	"sync"
	"syscall"
	"time"
	"unsafe"
)

// S     (1 bit) : Start bit
// P     (1 bit) : Stop bit
// Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
// A, NA (1 bit) : Accept and reverse accept bit.
// Addr  (7 bits): I2C 7 bit address. Note that this can be expanded as usual to
//                 get a 10 bit I2C address.
// Comm  (8 bits): Command byte, a data byte which often selects a register on
//                 the device.
// Data  (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh
//                 for 16 bit data.
// Count (8 bits): A data byte containing the length of a block operation.
// {..}: Data sent by I2C slave, as opposed to data sent by master.
type I2CBus interface {
	// ReadByte reads a byte from the given address.
	// S Addr Rd {A} {value} NA P
	ReadByte(addr byte) (value byte, err error)
	// WriteByte writes a byte to the given address.
	// S Addr Wr {A} value {A} P
	WriteByte(addr, value byte) error
	// WriteBytes writes a slice bytes to the given address.
	// S Addr Wr {A} value[0] {A} value[1] {A} ... {A} value[n] {A} NA P
	WriteBytes(addr byte, value []byte) error
	// ReadFromReg reads n (len(value)) bytes from the given address and register.
	ReadFromReg(addr, reg byte, value []byte) error
	// ReadByteFromReg reads a byte from the given address and register.
	ReadByteFromReg(addr, reg byte) (value byte, err error)
	// ReadU16FromReg reads a unsigned 16 bit integer from the given address and register.
	ReadWordFromReg(addr, reg byte) (value uint16, err error)<commit_msg>LSBF word<commit_after>// i2c libary for intel edison
// Taken for the embed project changes made for intel edison

// The MIT License (MIT)
// Copyright (c) 2015 NeuralSpaz
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package i2c

import (
	"fmt"
	"os"
	"reflect"
	"sync"
	"syscall"
	"time"
	"unsafe"
)

// S     (1 bit) : Start bit
// P     (1 bit) : Stop bit
// Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
// A, NA (1 bit) : Accept and reverse accept bit.
// Addr  (7 bits): I2C 7 bit address. Note that this can be expanded as usual to
//                 get a 10 bit I2C address.
// Comm  (8 bits): Command byte, a data byte which often selects a register on
//                 the device.
// Data  (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh
//                 for 16 bit data.
// Count (8 bits): A data byte containing the length of a block operation.
// {..}: Data sent by I2C slave, as opposed to data sent by master.
type I2CBus interface {
	// ReadByte reads a byte from the given address.
	// S Addr Rd {A} {value} NA P
	ReadByte(addr byte) (value byte, err error)
	// WriteByte writes a byte to the given address.
	// S Addr Wr {A} value {A} P
	WriteByte(addr, value byte) error
	// WriteBytes writes a slice bytes to the given address.
	// S Addr Wr {A} value[0] {A} value[1] {A} ... {A} value[n] {A} NA P
	WriteBytes(addr byte, value []byte) error
	// ReadFromReg reads n (len(value)) bytes from the given address and register.
	ReadFromReg(addr, reg byte, value []byte) error
	// ReadByteFromReg reads a byte from the given address and register.
	ReadByteFromReg(addr, reg byte) (value byte, err error)
	// ReadU16FromReg reads a unsigned 16 bit integer from the given address and register.
	ReadWordFromReg(addr, reg byte) (value uint16, err error)
	ReadWordFromRegLSBF(addr, reg byte) (value uint16, err error)
{'fraction_non_alphanumeric': 0.08860094554368762, 'fraction_numerical': 0.011906846436701103, 'mean_word_length': 3.25, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2412010', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1611, 'n_words': 865}