WPILibC++  2020.3.2
SPI.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
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 #pragma once
9 
10 #include <stdint.h>
11 
12 #include "hal/AnalogTrigger.h"
13 #include "hal/SPITypes.h"
14 #include "hal/Types.h"
15 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
33 void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status);
34 
48 int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend,
49  uint8_t* dataReceived, int32_t size);
50 
62 int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend,
63  int32_t sendSize);
64 
80 int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count);
81 
87 void HAL_CloseSPI(HAL_SPIPort port);
88 
96 void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed);
97 
109 void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
110  HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh);
111 
117 void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status);
118 
124 void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status);
125 
133 int32_t HAL_GetSPIHandle(HAL_SPIPort port);
134 
142 void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle);
143 
151 void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status);
152 
159 void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t* status);
160 
168 void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t* status);
169 
185 void HAL_StartSPIAutoTrigger(HAL_SPIPort port, HAL_Handle digitalSourceHandle,
186  HAL_AnalogTriggerType analogTriggerType,
187  HAL_Bool triggerRising, HAL_Bool triggerFalling,
188  int32_t* status);
189 
196 void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status);
197 
208 void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
209  int32_t dataSize, int32_t zeroSize,
210  int32_t* status);
211 
218 void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t* status);
219 
234 int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint32_t* buffer,
235  int32_t numToRead, double timeout,
236  int32_t* status);
237 
245 int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status);
246 
256 void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
257  int32_t stallTicks, int32_t pow2BytesPerRead,
258  int32_t* status);
259 
260 #ifdef __cplusplus
261 } // extern "C"
262 #endif
263 
HAL_SetSPIOpts
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst, HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh)
Sets the SPI options.
HAL_SetSPIChipSelectActiveHigh
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t *status)
Sets the CS Active high for a SPI port.
HAL_SetSPIChipSelectActiveLow
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t *status)
Sets the CS Active low for a SPI port.
HAL_ReadSPI
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t *buffer, int32_t count)
Executes a read from the device.
HAL_ForceSPIAutoRead
void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t *status)
Immediately forces an SPI read to happen.
HAL_SetSPIAutoTransmitData
void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t *dataToSend, int32_t dataSize, int32_t zeroSize, int32_t *status)
Sets the data to be transmitted to the device to initiate a read.
HAL_ReadSPIAutoReceivedData
int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint32_t *buffer, int32_t numToRead, double timeout, int32_t *status)
Reads data received by the SPI accumulator.
HAL_ConfigureSPIAutoStall
void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks, int32_t stallTicks, int32_t pow2BytesPerRead, int32_t *status)
Configure the Auto SPI Stall time between reads.
HAL_TransactionSPI
int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t *dataToSend, uint8_t *dataReceived, int32_t size)
Performs an SPI send/receive transaction.
HAL_SetSPIHandle
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle)
Sets the stored handle for a SPI port.
HAL_InitializeSPI
void HAL_InitializeSPI(HAL_SPIPort port, int32_t *status)
Initializes the SPI port.
HAL_FreeSPIAuto
void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t *status)
Frees an SPI automatic accumulator.
HAL_InitSPIAuto
void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t *status)
Initializes the SPI automatic accumulator.
HAL_StopSPIAuto
void HAL_StopSPIAuto(HAL_SPIPort port, int32_t *status)
Stops an automatic SPI accumlation.
HAL_GetSPIAutoDroppedCount
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t *status)
Gets the count of how many SPI accumulations have been missed.
HAL_GetSPIHandle
int32_t HAL_GetSPIHandle(HAL_SPIPort port)
Gets the stored handle for a SPI port.
HAL_CloseSPI
void HAL_CloseSPI(HAL_SPIPort port)
Closes the SPI port.
HAL_StartSPIAutoRate
void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t *status)
Sets the period for automatic SPI accumulation.
HAL_StartSPIAutoTrigger
void HAL_StartSPIAutoTrigger(HAL_SPIPort port, HAL_Handle digitalSourceHandle, HAL_AnalogTriggerType analogTriggerType, HAL_Bool triggerRising, HAL_Bool triggerFalling, int32_t *status)
Starts the auto SPI accumulator on a specific trigger.
HAL_SetSPISpeed
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed)
Sets the clock speed for the SPI bus.
HAL_WriteSPI
int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t *dataToSend, int32_t sendSize)
Executes a write transaction with the device.