peary/interfaces/SPI/spi.hpp

Peary SPI Interface. More…

Namespaces

Name
peary
peary::interface

Classes

Name
struct peary::interface::SpiInterface
class peary::interface::SPIEndpoint SPI interface endpoint class.

Detailed Description

Peary SPI Interface.

Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only

Source code

  
#pragma once

#include <cstdint>
#include <string>
#include <vector>

#include "peary/interfaces/Endpoint.hpp"

namespace peary::interface {

    struct SpiInterface {};

    template <typename REG_T = uint8_t> class SPIEndpoint : public Endpoint<SpiInterface, REG_T, uint8_t> {
        using Base = Endpoint<SpiInterface, REG_T, uint8_t>;

    public:
        using reg_t = typename Base::reg_t;
        using pair_t = typename Base::pair_t;
        using data_t = typename Base::data_t;
        using vector_t = typename Base::vector_t;

    public:
        explicit SPIEndpoint(const std::string& bus);

        ~SPIEndpoint();

    protected:
        pair_t write_impl(const pair_t& data) override;

        vector_t write_impl(const reg_t& reg, const vector_t& data) override;

        std::vector<pair_t> write_impl(const std::vector<pair_t>& data) override;

        vector_t read_impl(const reg_t& reg, const unsigned int length) override;

    protected:
        // Descriptor of the device
        int fd_;

        // SPI bits per word
        const uint32_t bits_per_word = 8;

    }; // class SPIEndpoint

} // namespace peary::interface

#ifdef SPI_EMULATED
#include "emulator.tcc"
#else
#include "spi.tcc"
#endif
  

Updated on 2026-01-30 at 22:01:05 +0100