24 lines
816 B
C++
24 lines
816 B
C++
#include "SpiTest.h"
|
|
#include "fsfw_hal/stm32h7/spi/stm32h743zi.h"
|
|
|
|
SpiTest::SpiTest(SpiComIF &spiComIF)
|
|
: spiComIF(spiComIF),
|
|
spiCookie(TEST_ADDRESS, spi::SpiBus::SPI_1, spi::TransferModes::POLLING,
|
|
&mspCfg, 1000000, spi::SpiModes::MODE_0, 32) {
|
|
stm32h7::h743zi::standardPollingCfg(mspCfg);
|
|
spiComIF.initializeInterface(&spiCookie);
|
|
}
|
|
|
|
ReturnValue_t SpiTest::performOperation(uint8_t opCode) {
|
|
std::array<uint8_t, 3> dummyData = {0x01, 0x02, 0x03};
|
|
ReturnValue_t result =
|
|
spiComIF.sendMessage(&spiCookie, dummyData.data(), dummyData.size());
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
return result;
|
|
}
|
|
std::array<uint8_t, 3> recBuf;
|
|
uint8_t *recPtr = recBuf.data();
|
|
size_t readLen = 0;
|
|
return spiComIF.readReceivedMessage(&spiCookie, &recPtr, &readLen);
|
|
}
|