1// Copyright 2023 The Pigweed Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not 4// use this file except in compliance with the License. You may obtain a copy of 5// the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12// License for the specific language governing permissions and limitations under 13// the License. 14syntax = "proto3"; 15 16package pw.i2c; 17 18message I2cWriteRequest { 19 // Which I2C initiator bus to communicate on. 20 uint32 bus_index = 1; 21 // 7-bit I2C target address to write to. 22 uint32 target_address = 2; 23 // Register address to write. Follow the endianness required by the 24 // responder for multi-byte address. 25 bytes register_address = 3; 26 // Value to write. Follow the endianness required by the responder. 27 bytes value = 4; 28} 29 30message I2cWriteResponse {} 31 32message I2cReadRequest { 33 // Which I2C initiator bus to communicate on. 34 uint32 bus_index = 1; 35 // 7-bit I2C target address to read from. 36 uint32 target_address = 2; 37 // Register address to write. Follow the endianness required by the 38 // responder for multi-byte address. 39 bytes register_address = 3; 40 // Expected number of bytes from the responder. 41 uint32 read_size = 4; 42} 43 44message I2cReadResponse { 45 bytes value = 1; 46} 47 48service I2c { 49 // Enable access to I2C devices implementing register read/writes. 50 rpc I2cWrite(I2cWriteRequest) returns (I2cWriteResponse) {} 51 rpc I2cRead(I2cReadRequest) returns (I2cReadResponse) {} 52} 53