Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
James Kuszmaul | 397f6fe | 2020-01-04 16:21:52 -0800 | [diff] [blame^] | 2 | /* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "hal/SPI.h" |
| 9 | |
| 10 | #include "HALInitializer.h" |
| 11 | #include "mockdata/SPIDataInternal.h" |
| 12 | |
| 13 | using namespace hal; |
| 14 | |
| 15 | namespace hal { |
| 16 | namespace init { |
| 17 | void InitializeSPI() {} |
| 18 | } // namespace init |
| 19 | } // namespace hal |
| 20 | |
James Kuszmaul | 397f6fe | 2020-01-04 16:21:52 -0800 | [diff] [blame^] | 21 | extern "C" { |
| 22 | |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 23 | void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) { |
| 24 | hal::init::CheckInit(); |
| 25 | SimSPIData[port].initialized = true; |
| 26 | } |
| 27 | int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend, |
| 28 | uint8_t* dataReceived, int32_t size) { |
| 29 | return SimSPIData[port].Transaction(dataToSend, dataReceived, size); |
| 30 | } |
| 31 | int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend, |
| 32 | int32_t sendSize) { |
| 33 | return SimSPIData[port].Write(dataToSend, sendSize); |
| 34 | } |
| 35 | int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count) { |
| 36 | return SimSPIData[port].Read(buffer, count); |
| 37 | } |
| 38 | void HAL_CloseSPI(HAL_SPIPort port) { SimSPIData[port].initialized = false; } |
| 39 | void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed) {} |
| 40 | void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst, |
| 41 | HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh) {} |
| 42 | void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status) {} |
| 43 | void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status) {} |
| 44 | int32_t HAL_GetSPIHandle(HAL_SPIPort port) { return 0; } |
| 45 | void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle) {} |
| 46 | |
| 47 | void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status) {} |
| 48 | void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t* status) {} |
| 49 | void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t* status) {} |
| 50 | void HAL_StartSPIAutoTrigger(HAL_SPIPort port, HAL_Handle digitalSourceHandle, |
| 51 | HAL_AnalogTriggerType analogTriggerType, |
| 52 | HAL_Bool triggerRising, HAL_Bool triggerFalling, |
| 53 | int32_t* status) {} |
| 54 | void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status) {} |
| 55 | void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend, |
| 56 | int32_t dataSize, int32_t zeroSize, |
| 57 | int32_t* status) {} |
| 58 | void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t* status) {} |
| 59 | int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint32_t* buffer, |
| 60 | int32_t numToRead, double timeout, |
| 61 | int32_t* status) { |
| 62 | return SimSPIData[port].ReadAutoReceivedData(buffer, numToRead, timeout, |
| 63 | status); |
| 64 | } |
| 65 | int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) { |
| 66 | return 0; |
| 67 | } |
James Kuszmaul | 397f6fe | 2020-01-04 16:21:52 -0800 | [diff] [blame^] | 68 | |
| 69 | void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks, |
| 70 | int32_t stallTicks, int32_t pow2BytesPerRead, |
| 71 | int32_t* status) {} |
| 72 | |
| 73 | } // extern "C" |