2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2016-05-25 20:23:37 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "hal/SPI.h"
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2018-05-13 22:02:47 -07:00
|
|
|
#include "HALInitializer.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "mockdata/SPIDataInternal.h"
|
2017-10-19 02:01:58 -04:00
|
|
|
|
|
|
|
|
using namespace hal;
|
|
|
|
|
|
2020-12-28 01:19:59 -08:00
|
|
|
namespace hal::init {
|
2017-12-10 19:38:53 -08:00
|
|
|
void InitializeSPI() {}
|
2020-12-28 01:19:59 -08:00
|
|
|
} // namespace hal::init
|
2017-12-10 19:38:53 -08:00
|
|
|
|
2019-12-24 10:52:58 -08:00
|
|
|
extern "C" {
|
|
|
|
|
|
2017-10-19 02:01:58 -04:00
|
|
|
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
2018-05-13 22:02:47 -07:00
|
|
|
hal::init::CheckInit();
|
2018-09-03 16:08:07 -07:00
|
|
|
SimSPIData[port].initialized = true;
|
2017-10-19 02:01:58 -04:00
|
|
|
}
|
2017-11-14 00:00:45 -08:00
|
|
|
int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
2017-08-18 21:35:53 -07:00
|
|
|
uint8_t* dataReceived, int32_t size) {
|
2017-10-19 02:01:58 -04:00
|
|
|
return SimSPIData[port].Transaction(dataToSend, dataReceived, size);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2017-11-14 00:00:45 -08:00
|
|
|
int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
|
|
|
|
int32_t sendSize) {
|
2017-10-19 02:01:58 -04:00
|
|
|
return SimSPIData[port].Write(dataToSend, sendSize);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
|
|
|
|
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count) {
|
2017-10-19 02:01:58 -04:00
|
|
|
return SimSPIData[port].Read(buffer, count);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2020-12-28 12:58:06 -08:00
|
|
|
void HAL_CloseSPI(HAL_SPIPort port) {
|
|
|
|
|
SimSPIData[port].initialized = false;
|
|
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed) {}
|
2017-05-09 12:12:46 -07:00
|
|
|
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
|
2017-08-18 21:35:53 -07:00
|
|
|
HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh) {}
|
|
|
|
|
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status) {}
|
|
|
|
|
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status) {}
|
2020-12-28 12:58:06 -08:00
|
|
|
int32_t HAL_GetSPIHandle(HAL_SPIPort port) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-08-18 21:35:53 -07:00
|
|
|
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle) {}
|
2016-05-24 00:58:10 -07:00
|
|
|
|
2017-12-13 23:41:37 -08:00
|
|
|
void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status) {}
|
|
|
|
|
void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t* status) {}
|
|
|
|
|
void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t* status) {}
|
|
|
|
|
void HAL_StartSPIAutoTrigger(HAL_SPIPort port, HAL_Handle digitalSourceHandle,
|
|
|
|
|
HAL_AnalogTriggerType analogTriggerType,
|
|
|
|
|
HAL_Bool triggerRising, HAL_Bool triggerFalling,
|
|
|
|
|
int32_t* status) {}
|
|
|
|
|
void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status) {}
|
|
|
|
|
void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
|
|
|
|
|
int32_t dataSize, int32_t zeroSize,
|
|
|
|
|
int32_t* status) {}
|
|
|
|
|
void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t* status) {}
|
2018-12-06 22:29:20 -08:00
|
|
|
int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint32_t* buffer,
|
2017-12-13 23:41:37 -08:00
|
|
|
int32_t numToRead, double timeout,
|
|
|
|
|
int32_t* status) {
|
2017-12-31 15:37:14 -05:00
|
|
|
return SimSPIData[port].ReadAutoReceivedData(buffer, numToRead, timeout,
|
|
|
|
|
status);
|
2017-08-18 21:35:53 -07:00
|
|
|
}
|
2017-12-13 23:41:37 -08:00
|
|
|
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return 0;
|
|
|
|
|
}
|
2019-12-24 10:52:58 -08:00
|
|
|
|
|
|
|
|
void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
|
|
|
|
|
int32_t stallTicks, int32_t pow2BytesPerRead,
|
|
|
|
|
int32_t* status) {}
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|