aboutsummaryrefslogtreecommitdiff
path: root/pw_i2c/i2c.proto
blob: d68654b726670cb43472b2fd1c00a49b58e89217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2023 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
syntax = "proto3";

package pw.i2c;

message I2cWriteRequest {
  // Which I2C initiator bus to communicate on.
  uint32 bus_index = 1;
  // 7-bit I2C target address to write to.
  uint32 target_address = 2;
  // Register address to write. Follow the endianness required by the
  // responder for multi-byte address.
  bytes register_address = 3;
  // Value to write. Follow the endianness required by the responder.
  bytes value = 4;
}

message I2cWriteResponse {}

message I2cReadRequest {
  // Which I2C initiator bus to communicate on.
  uint32 bus_index = 1;
  // 7-bit I2C target address to read from.
  uint32 target_address = 2;
  // Register address to write. Follow the endianness required by the
  // responder for multi-byte address.
  bytes register_address = 3;
  // Expected number of bytes from the responder.
  uint32 read_size = 4;
}

message I2cReadResponse {
  bytes value = 1;
}

service I2c {
  // Enable access to I2C devices implementing register read/writes.
  rpc I2cWrite(I2cWriteRequest) returns (I2cWriteResponse) {}
  rpc I2cRead(I2cReadRequest) returns (I2cReadResponse) {}
}