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