Add support for configuring SPI Auto Stall Config (#2193)

This commit is contained in:
Thad House
2019-12-24 10:52:58 -08:00
committed by Peter Johnson
parent 3259cffc63
commit bdc1cab013
8 changed files with 89 additions and 9 deletions

View File

@@ -631,12 +631,21 @@ int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
return spiSystem->readTransferSkippedFullCount(status);
}
// These 2 functions are so the new stall functionality
// can be tested. How they're used is not very clear
// but I want them to be testable so we can add an impl.
// We will not be including these in the headers
void* HAL_GetSPIDMAManager() { return spiAutoDMA.get(); }
void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
int32_t stallTicks, int32_t pow2BytesPerRead,
int32_t* status) {
std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
return;
}
void* HAL_GetSPISystem() { return spiSystem.get(); }
tSPI::tStallConfig stallConfig;
stallConfig.CsToSclkTicks = static_cast<uint8_t>(csToSclkTicks);
stallConfig.StallTicks = static_cast<uint16_t>(stallTicks);
stallConfig.Pow2BytesPerRead = static_cast<uint8_t>(pow2BytesPerRead);
spiSystem->writeStallConfig(stallConfig, status);
}
} // extern "C"