syntax = "proto3";

import "google/rpc/status.proto";

option cc_generic_services = true;

package mesytec.mnode.proto.vme;

enum DataWidth
{
    D16 = 0;
    D32 = 1;
}

message AddressModifier
{
    uint32 value = 1;
}

enum EsstRate
{
    UNKNOWN = 0;
    RATE_160MB = 1;
    RATE_276MB = 2;
    RATE_320MB = 3;
}

message ReadRequestOptions
{
    optional bool late_read = 1;
    optional bool fifo_read = 2;
    optional bool swapped_read = 3;
    optional EsstRate esst_rate = 4;
    optional uint32 max_transfers = 5;
}

message ReadRequest
{
    uint32 address = 1;
    AddressModifier amod = 2;
    DataWidth data_width = 3;
    ReadRequestOptions options = 4;
}

message WriteRequest
{
    uint32 address = 1;
    uint32 value = 2;
    AddressModifier amod = 3;
    DataWidth data_width = 4;
}

enum ResponseFlags
{
    NONE = 0;
    TIMEOUT = 1;
    BUS_ERROR = 2;
    SYNTAX_ERROR = 3;
}

message ReadResponse
{
    repeated uint32 values = 1;
    optional ResponseFlags flags = 2;
    optional google.rpc.Status status = 3;
}

message WriteResponse
{
    optional ResponseFlags flags = 2;
    optional google.rpc.Status status = 3;
}

service VmeAccess
{
    rpc Read(ReadRequest) returns (ReadResponse);
    rpc Write(WriteRequest) returns (WriteResponse);
}
