Skip to content

Commit

Permalink
Pass bus number argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Aug 20, 2024
1 parent 7a8712c commit 19e6245
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
5 changes: 4 additions & 1 deletion include/cRIO/FPGA.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ class FPGA : public SimpleFPGA {
/**
* Commands FPGA to write to MPU commands buffer.
*
* @param bus serial bus to write to. The FPGA can use either dedicated
* FIFO, or sends those data to a multiplexed FIFO sharing more serial
* ports on FPGA.
* @param data data to write to the MPU command buffer
* @param timeout timeout in milliseconds
*/
virtual void writeMPUFIFO(const std::vector<uint8_t>& data, uint32_t timeout) = 0;
virtual void writeMPUFIFO(uint8_t bus, const std::vector<uint8_t>& data, uint32_t timeout) = 0;

/**
* Commands FPGA to copy MPU output FIFO to FPGA-C/C++ output FIFO. This
Expand Down
8 changes: 1 addition & 7 deletions src/LSST/cRIO/FPGA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,7 @@ void FPGA::mpuCommands(MPU &mpu, const std::chrono::duration<double> &timeout) {
// construct buffer to send
std::vector<uint8_t> data;

data.push_back(mpu.getBus());
data.push_back(cmd.buffer.size() + 2);
data.push_back(MPUCommands::WRITE);
data.push_back(cmd.buffer.size());
data.insert(data.end(), cmd.buffer.begin(), cmd.buffer.end());

writeMPUFIFO(data, 0);
writeMPUFIFO(mpu.getBus(), cmd.buffer, 0);

// read reply
auto answer = readMPUFIFO(mpu);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestFPGA.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestFPGA : public LSST::cRIO::FPGA, public LSST::cRIO::PrintILC {
uint16_t getTxCommand(uint8_t bus) override { return FPGAAddress::MODBUS_A_TX; }
uint16_t getRxCommand(uint8_t bus) override { return FPGAAddress::MODBUS_A_RX; }
uint32_t getIrq(uint8_t bus) override { return 1; }
void writeMPUFIFO(const std::vector<uint8_t>& data, uint32_t timeout) override {}
void writeMPUFIFO(uint8_t bus, const std::vector<uint8_t>& data, uint32_t timeout) override {}
std::vector<uint8_t> readMPUFIFO(LSST::cRIO::MPU&) override {
return std::vector<uint8_t>({0xff, 0x0fe});
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_CSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TestFPGA : public FPGA {
uint16_t getTxCommand(uint8_t) override { return 0; }
uint16_t getRxCommand(uint8_t) override { return 0; }
uint32_t getIrq(uint8_t) override { return 0; }
void writeMPUFIFO(const std::vector<uint8_t>& data, uint32_t timeout) override {}
void writeMPUFIFO(uint8_t bus, const std::vector<uint8_t>& data, uint32_t timeout) override {}
std::vector<uint8_t> readMPUFIFO(MPU&) override { return std::vector<uint8_t>({0x04, 0x05}); }
void writeCommandFIFO(uint16_t*, size_t, uint32_t) override {}
void writeRequestFIFO(uint16_t*, size_t, uint32_t) override {}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_FirmwareLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TestFPGA : public FPGA {
uint16_t getRxCommand(uint8_t bus) override { return bus + 14; }
uint32_t getIrq(uint8_t bus) override { return 1; }

void writeMPUFIFO(const std::vector<uint8_t>& data, uint32_t timeout) override {}
void writeMPUFIFO(uint8_t bus, const std::vector<uint8_t>& data, uint32_t timeout) override {}
std::vector<uint8_t> readMPUFIFO(MPU& mpu) override { return std::vector<uint8_t>({0x01, 0x02}); }

void writeCommandFIFO(uint16_t* data, size_t length, uint32_t timeout) override;
Expand Down

0 comments on commit 19e6245

Please sign in to comment.