M1M3 Support System
Loading...
Searching...
No Matches
FPGA.h
1/*
2 * This file is part of LSST M1M3 support system package.
3 *
4 * Developed for the Vera C. Rubin Telescope and Site System.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef FPGA_H_
25#define FPGA_H_
26
27#include <IFPGA.h>
28#include <NiFpga.h>
29
30namespace LSST {
31namespace M1M3 {
32namespace SS {
33
44class FPGA : public IFPGA {
45public:
46 FPGA();
47 virtual ~FPGA();
48
49 void initialize() override;
50 void open() override;
51 void close() override;
52 void finalize() override;
53
54 void waitForOuterLoopClock(uint32_t timeout) override;
55 void ackOuterLoopClock() override;
56
57 void waitForPPS(uint32_t timeout) override;
58 void ackPPS() override;
59
60 void waitForModbusIRQs(uint32_t warning_timeout, uint32_t error_timeout) override;
61 void ackModbusIRQs() override;
62
63 void pullTelemetry() override;
64 void pullHealthAndStatus() override;
65
66 void writeCommandFIFO(uint16_t *data, size_t length, uint32_t timeoutInMs) override;
67 void writeRequestFIFO(uint16_t *data, size_t length, uint32_t timeoutInMs) override;
68 void writeTimestampFIFO(uint64_t timestamp) override;
69 void readU8ResponseFIFO(uint8_t *data, size_t length, uint32_t timeoutInMs) override;
70 void readU16ResponseFIFO(uint16_t *data, size_t length, uint32_t timeoutInMs) override;
71
72 void waitOnIrqs(uint32_t irqs, uint32_t timeout, bool &timedout, uint32_t *triggered = NULL) override;
73 void ackIrqs(uint32_t irqs) override;
74
75 void writeHealthAndStatusFIFO(uint16_t request, uint16_t param = 0) override;
76 void readHealthAndStatusFIFO(uint64_t *data, size_t length, uint32_t timeoutInMs = 10) override;
77
78 void readRawAccelerometerFIFO(uint64_t *raw, size_t samples) override;
79
80private:
81 uint32_t _session;
82 size_t _remaining;
83 std::map<size_t, NiFpga_IrqContext> _contexes;
84 NiFpga_IrqContext _outerLoopIRQContext;
85 NiFpga_IrqContext _modbusIRQContext;
86 NiFpga_IrqContext _ppsIRQContext;
87
88 uint32_t _modbus_irqs;
89};
90
91} /* namespace SS */
92} /* namespace M1M3 */
93} /* namespace LSST */
94
95#endif /* FPGA_H_ */
void writeHealthAndStatusFIFO(uint16_t request, uint16_t param=0) override
Requests HealthAndStatus data.
Definition FPGA.cpp:296
void readRawAccelerometerFIFO(uint64_t *raw, size_t samples) override
Reads raw accelerometer FIFO.
Definition FPGA.cpp:312
void pullTelemetry() override
Retrieve telemetry data.
Definition FPGA.cpp:167
void writeTimestampFIFO(uint64_t timestamp) override
Write current timestamp value into timestampFIFO.
Definition FPGA.cpp:255
void waitForPPS(uint32_t timeout) override
Waits for Peer-to-Peer Synchronization interrupt (10).
Definition FPGA.cpp:102
void readU8ResponseFIFO(uint8_t *data, size_t length, uint32_t timeoutInMs) override
Definition FPGA.cpp:262
void ackOuterLoopClock() override
Acknowledge (clear interrupt 0) outer loop clock.
Definition FPGA.cpp:98
void waitForOuterLoopClock(uint32_t timeout) override
Wait for outer loop clock interrupt for synchronization between C++ and FPGA code.
Definition FPGA.cpp:91
void pullHealthAndStatus() override
Retrieve Health&Status data.
Definition FPGA.cpp:236
void readHealthAndStatusFIFO(uint64_t *data, size_t length, uint32_t timeoutInMs=10) override
Copy HealthAndStatus data into supplied data buffer.
Definition FPGA.cpp:305
void ackPPS() override
Acknowledge (clear) Peer-to-Peer Synchronization interrupt.
Definition FPGA.cpp:109
void ackModbusIRQs() override
Acknowledge ModBus interrupt reception.
Definition FPGA.cpp:163
void waitForModbusIRQs(uint32_t warning_timeout, uint32_t error_timeout) override
Wait for ModBus interrupts.
Definition FPGA.cpp:113