SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
fpga.hpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS control library
3 *
4 * Copyright (C) 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 <cstdint>
25#include <etl/string.h>
29
30namespace satnogs::comms::lib
31{
32class fpga
33{
34public:
35 enum class reg : uint32_t
36 {
37 id = 0,
40 };
41
42 enum class hw : uint8_t
43 {
47 };
48
49 enum class boot_mode : uint8_t
50 {
55 };
56
57 fpga(hw h, bsp::spi &spi, power &pwr, bsp::gpio &fpga_done,
58 bsp::gpio &boot_sel_1, bsp::gpio &boot_sel_0);
59
60 void
61 enable(bool en = true);
62
63 bool
64 enabled() const;
65
66 void
67 write_reg(uint32_t reg, uint32_t val);
68
69 uint32_t
70 read_reg(uint32_t reg);
71
72 void
73 write_reg(reg r, uint32_t val);
74
75 uint32_t
76 read_reg(reg r);
77
78 bool
79 get_fpga_done() const;
80
81 void
83
85 get_boot_mode() const;
86
87private:
88 const hw m_hw;
89 etl::string<32> m_name;
90 bsp::spi &m_spi;
91 power &m_pwr;
92 bsp::gpio &m_fpga_done;
93 bsp::gpio &m_boot_sel_1;
94 bsp::gpio &m_boot_sel_0;
95};
96
97} // namespace satnogs::comms::lib
GPIO device abstraction.
Definition gpio.hpp:38
SPI device abstraction.
Definition spi.hpp:41
fpga(hw h, bsp::spi &spi, power &pwr, bsp::gpio &fpga_done, bsp::gpio &boot_sel_1, bsp::gpio &boot_sel_0)
Construct a new fpga::fpga object and disables it to ensure now excess power is accidentally used dur...
Definition fpga.cpp:49
boot_mode get_boot_mode() const
Definition fpga.cpp:164
void set_boot_mode(boot_mode mode)
Definition fpga.cpp:133
uint32_t read_reg(uint32_t reg)
Definition fpga.cpp:107
void write_reg(uint32_t reg, uint32_t val)
Definition fpga.cpp:101
void enable(bool en=true)
Enable/disable the FPGA subsystem.
Definition fpga.cpp:83
bool get_fpga_done() const
Definition fpga.cpp:127
bool enabled() const
Returns the state of the FPGA.
Definition fpga.cpp:95
Manages power supplies and monitors subsystem status.
Definition power.hpp:43
const struct gpio_dt_spec fpga_done
Definition startup.cpp:46