2016-05-25 20:23:37 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
2016-05-25 20:23:37 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
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;
|
|
|
|
|
|
2017-12-10 19:38:53 -08:00
|
|
|
namespace hal {
|
|
|
|
|
namespace init {
|
|
|
|
|
void InitializeSPI() {}
|
|
|
|
|
} // namespace init
|
|
|
|
|
} // namespace hal
|
|
|
|
|
|
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
|
|
|
}
|
2018-09-03 16:08:07 -07: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) {}
|
|
|
|
|
int32_t HAL_GetSPIHandle(HAL_SPIPort port) { return 0; }
|
|
|
|
|
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) {}
|
|
|
|
|
int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint8_t* buffer,
|
|
|
|
|
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;
|
|
|
|
|
}
|