SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
spi.hpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS control library
3 *
4 * Copyright (C) 2022-2024, Libre Space Foundation <http://libre.space>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: GNU General Public License v3.0 or later
20 */
21
22#pragma once
23
24#include "gpio.hpp"
25#include <cstddef>
26#include <cstdint>
27
29{
40class spi
41{
42public:
47 spi() {}
48 ~spi() {}
49
58 virtual void
59 read(uint8_t *rx, const uint8_t *tx, size_t tx_len, size_t rx_len) = 0;
60
67 virtual void
68 write(const uint8_t *tx, size_t len) = 0;
69
78 virtual gpio &
80 {
81 return m_cs;
82 }
83
84private:
85 dummy_gpio m_cs;
86};
87
88} // namespace satnogs::comms::lib::bsp
A dummy GPIO implementation with no effect. Can be used for CI testing or default construction of gpi...
Definition gpio.hpp:119
GPIO device abstraction.
Definition gpio.hpp:38
virtual gpio & cs()
Returns a GPIO control handle for the CS of the SPI. If this is performed automatically by the hardwa...
Definition spi.hpp:79
spi()
Construct a new SPI object.
Definition spi.hpp:47
virtual void read(uint8_t *rx, const uint8_t *tx, size_t tx_len, size_t rx_len)=0
Performs an SPI read operation.
virtual void write(const uint8_t *tx, size_t len)=0
Performs an SPI write operation.