Skip to content

sh4r1k7/rpc-service-spi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPC Service - I2C

This service provides an ability to manage I2C peripherals on devices remotely. It is possible to call this service programmatically via serial, HTTP/RESTful, Websocket, MQTT or other transports (see RPC section) or via the mos tool.

Below is a list of exported RPC methods and arguments:

I2C.Scan

Scan the I2C bus, return a list of available device addresses. Arguments: none.

Example usage:

mos call I2C.Scan
[
  31    # There is only 1 device with address 31 attached to the I2C bus
]

I2C.Read

Read data from the I2C device. Arguments:

{
  "addr: 31,    // Required. Device address.
  "len": 2      // Required. Number of bytes to read.
}

Reply:

{
  // Hex-encoded data. Each byte is encoded as XX hex code, e.g. 0x00 0x1d:
  "data_hex": "001d"
}

Example usage:

mos call I2C.Read '{"addr": 31, "len": 2}'
{
  "data_hex": "001d"
}

I2C.Write

Write data to the I2C device. Arguments:

{
  "addr: 31,              // Required. Device address.
  "data_hext": "1f3c6a"   // Required. Hex-encoded data to write
}

Example usage (showing failed write):

mos call I2C.Write '{"addr": 31, "data_hex": "1f3c6a"}'
Error: remote error: I2C write failed

I2C.ReadRegB

Read 1-byte register value. Arguments:

{
  "addr: 31,  // Required. Device address.
  "reg": 0    // Required. Register number.
}

Example usage:

mos call I2C.ReadRegB '{"addr": 31, "reg": 0}'
{
  "value": 0
}

I2C.WriteRegB

Write 1-byte register value. Arguments:

{
  "addr: 31,    // Required. Device address.
  "reg": 0,     // Required. Register number.
  "value": 0    // Required. 1-byte value to write.
}

Example usage:

mos call I2C.WriteRegB '{"addr": 31, "reg": 0, "value": 0}'

I2C.ReadRegW

Same as I2C.ReadRegB, but read 2-byte (word) register value.

I2C.WriteRegW

Same as I2C.WriteRegB, but write 2-byte (word) register value.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages