blob: e2b1e185406d9a2086a67a0b67e05c8381044556 [file] [log] [blame]
// Copyright 2024 Google LLC
//
// 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
//
// http://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.
#pragma once
extern "C"
{
#include <transports/libhoth_device.h>
#include <transports/libhoth_spi.h>
}
#include <memory>
// NOLINTNEXTLINE(cert-dcl58-cpp)
namespace google
{
namespace hoth
{
class LibHothSpiDevIntf
{
public:
using option = libhoth_spi_device_init_options;
using device = libhoth_device;
virtual int open(const option* opt, device** dev) = 0;
virtual int send(device* dev, const void* request, size_t size) = 0;
virtual int recv(device* dev, void* response, size_t response_size,
size_t* actual_size, int timeout_ms) = 0;
virtual int close(device* dev) = 0;
virtual int claim(device* dev) = 0;
virtual int release(device* dev) = 0;
};
class LibHothSpiDevImpl : public LibHothSpiDevIntf
{
public:
int open(const option* opt, device** dev) override;
int send(device* dev, const void* request, size_t size) override;
int recv(device* dev, void* response, size_t response_size,
size_t* actual_size, int timeout_ms) override;
int close(device* dev) override;
int claim(device* dev) override;
int release(device* dev) override;
};
extern LibHothSpiDevImpl libhoth_spidev;
} // namespace hoth
} // namespace google