mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
SPI Mode setting was very broken. MSB and LSB sets did not work (MSB is the only one supported) and if LSB was set (which was the default) the ioct to set clock phase would fail. This deprecates all the individual functions, the LSB/MSB functions, and adds an SPI mode selection function. This is usually more understandable, and shows up in a lot more documentation
75 lines
2.9 KiB
C++
75 lines
2.9 KiB
C++
// 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.
|
|
|
|
#include "hal/SPI.h"
|
|
|
|
#include "HALInitializer.h"
|
|
#include "mockdata/SPIDataInternal.h"
|
|
|
|
using namespace hal;
|
|
|
|
namespace hal::init {
|
|
void InitializeSPI() {}
|
|
} // namespace hal::init
|
|
|
|
extern "C" {
|
|
|
|
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
|
hal::init::CheckInit();
|
|
SimSPIData[port].initialized = true;
|
|
}
|
|
int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
|
uint8_t* dataReceived, int32_t size) {
|
|
return SimSPIData[port].Transaction(dataToSend, dataReceived, size);
|
|
}
|
|
int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
|
int32_t sendSize) {
|
|
return SimSPIData[port].Write(dataToSend, sendSize);
|
|
}
|
|
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count) {
|
|
return SimSPIData[port].Read(buffer, count);
|
|
}
|
|
void HAL_CloseSPI(HAL_SPIPort port) {
|
|
SimSPIData[port].initialized = false;
|
|
}
|
|
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed) {}
|
|
void HAL_SetSPIMode(HAL_SPIPort port, HAL_SPIMode mode) {}
|
|
HAL_SPIMode HAL_GetSPIMode(HAL_SPIPort port) {
|
|
return HAL_SPI_kMode0;
|
|
}
|
|
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) {}
|
|
|
|
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, uint32_t* buffer,
|
|
int32_t numToRead, double timeout,
|
|
int32_t* status) {
|
|
return SimSPIData[port].ReadAutoReceivedData(buffer, numToRead, timeout,
|
|
status);
|
|
}
|
|
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
|
|
return 0;
|
|
}
|
|
|
|
void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
|
|
int32_t stallTicks, int32_t pow2BytesPerRead,
|
|
int32_t* status) {}
|
|
|
|
} // extern "C"
|