Treehopper C# API
SMBusDevice Class Reference

Device class used to abstract i2C interfacing More...

Inheritance diagram for SMBusDevice:
Adjds311

Public Member Functions

 SMBusDevice (byte address, I2C i2CModule, int rateKHz=100)
 Create a new SMBus device More...
 
async Task< byte > ReadByteAsync ()
 Read a single byte from the device More...
 
Task WriteByteAsync (byte data)
 Write a single byte to the device More...
 
Task WriteDataAsync (byte[] data)
 Write data directly to the device More...
 
Task< byte[]> ReadDataAsync (byte numBytesToRead)
 Read data directly from a device More...
 
Task< byte > ReadByteDataAsync (int register)
 Read an 8-bit register's value from the device More...
 
async Task< byte > ReadByteDataAsync (byte register)
 Read an 8-bit register's value from the device More...
 
async Task< ushort > ReadWordDataAsync (byte register)
 Read a 16-bit little-endian register value from the device More...
 
async Task< ushort > ReadWordDataBEAsync (byte register)
 Read a 16-bit big-endian register value from the device More...
 
async Task< ushort > ReadWordAsync ()
 Read a 16-bit little-endian value from the device More...
 
async Task< ushort > ReadWordBEAsync ()
 Read a 16-bit little-endian value from the device More...
 
Task WriteByteDataAsync (byte register, byte data)
 Write a byte to a register More...
 
Task WriteWordDataAsync (byte register, ushort data)
 Write a 16-bit little-endian word to a register More...
 
Task WriteWordDataBEAsync (byte register, ushort data)
 Write a 16-bit big-endian word to a register More...
 
Task< byte[]> ReadBufferDataAsync (byte register, int numBytes)
 Read one or more bytes from the specified register More...
 
Task WriteBufferDataAsync (byte register, byte[] buffer)
 

Detailed Description

Device class used to abstract i2C interfacing

Constructor & Destructor Documentation

◆ SMBusDevice()

SMBusDevice ( byte  address,
I2C  i2CModule,
int  rateKHz = 100 
)

Create a new SMBus device

Parameters
addressThe 7-bit address of the device
i2CModuleThe i2C module this device is connected to.
rateKHzthe rate, in kHz, that should be used to communicate with this device.

Member Function Documentation

◆ ReadByteAsync()

async Task<byte> ReadByteAsync ( )

Read a single byte from the device

Returns

◆ WriteByteAsync()

Task WriteByteAsync ( byte  data)

Write a single byte to the device

Parameters
datathe data to write
Returns

◆ WriteDataAsync()

Task WriteDataAsync ( byte []  data)

Write data directly to the device

Parameters
dataan array of bytes to write
Returns

◆ ReadDataAsync()

Task<byte[]> ReadDataAsync ( byte  numBytesToRead)

Read data directly from a device

Parameters
numBytesToReadthe number of bytes to read
Returns

◆ ReadByteDataAsync() [1/2]

Task<byte> ReadByteDataAsync ( int  register)

Read an 8-bit register's value from the device

Parameters
registerthe register address to read
Returns
the register's value as a byte

◆ ReadByteDataAsync() [2/2]

async Task<byte> ReadByteDataAsync ( byte  register)

Read an 8-bit register's value from the device

Parameters
registerthe register address to read
Returns
the register's value as a byte

◆ ReadWordDataAsync()

async Task<ushort> ReadWordDataAsync ( byte  register)

Read a 16-bit little-endian register value from the device

Parameters
registerthe 8-bit register address to read from
Returns
the register's 16-bit value

◆ ReadWordDataBEAsync()

async Task<ushort> ReadWordDataBEAsync ( byte  register)

Read a 16-bit big-endian register value from the device

Parameters
registerthe 8-bit register address to read from
Returns
the register's 16-bit value

◆ ReadWordAsync()

async Task<ushort> ReadWordAsync ( )

Read a 16-bit little-endian value from the device

Returns
the 16-bit value

◆ ReadWordBEAsync()

async Task<ushort> ReadWordBEAsync ( )

Read a 16-bit little-endian value from the device

Returns
the 16-bit value

◆ WriteByteDataAsync()

Task WriteByteDataAsync ( byte  register,
byte  data 
)

Write a byte to a register

Parameters
registerthe register to write the byte to
datathe byte to be written to the specified register
Returns
an awaitable task

◆ WriteWordDataAsync()

Task WriteWordDataAsync ( byte  register,
ushort  data 
)

Write a 16-bit little-endian word to a register

Parameters
registerthe register to write the 16-bit word to
datathe 16-bit word to write to the specified register
Returns
an awaitable task

◆ WriteWordDataBEAsync()

Task WriteWordDataBEAsync ( byte  register,
ushort  data 
)

Write a 16-bit big-endian word to a register

Parameters
registerthe register to write the 16-bit word to
datathe 16-bit word to write to the specified register
Returns
an awaitable task

◆ ReadBufferDataAsync()

Task<byte[]> ReadBufferDataAsync ( byte  register,
int  numBytes 
)

Read one or more bytes from the specified register

Parameters
registerThe register to read from
numBytesThe number of bytes to read
Returns
An awaitable array of bytes read

◆ WriteBufferDataAsync()

Task WriteBufferDataAsync ( byte  register,
byte []  buffer 
)

Parameters
register
buffer
Returns
An awaitable task that completes upon success.

The documentation for this class was generated from the following file: