WPILibC++  2019.1.1-beta-1-37-g43d188a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
SPI.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 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 
230 int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint8_t* buffer,
231  int32_t numToRead, double timeout,
232  int32_t* status);
233 
241 int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status);
242 
243 #ifdef __cplusplus
244 } // extern "C"
245 #endif
246 
void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t *status)
Immediately forces an SPI read to happen.
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst, HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh)
Sets the SPI options.
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.
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t *status)
Sets the CS Active low for a SPI port.
int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t *dataToSend, uint8_t *dataReceived, int32_t size)
Performs an SPI send/receive transaction.
void HAL_InitializeSPI(HAL_SPIPort port, int32_t *status)
Initializes the SPI port.
void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t *status)
Frees an SPI automatic accumulator.
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle)
Sets the stored handle for a SPI port.
int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint8_t *buffer, int32_t numToRead, double timeout, int32_t *status)
Reads data received by the SPI accumulator.
void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t *status)
Initializes the SPI automatic accumulator.
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t *status)
Gets the count of how many SPI accumulations have been missed.
int32_t HAL_GetSPIHandle(HAL_SPIPort port)
Gets the stored handle for a SPI port.
void HAL_StopSPIAuto(HAL_SPIPort port, int32_t *status)
Stops an automatic SPI accumlation.
void HAL_CloseSPI(HAL_SPIPort port)
Closes the SPI port.
void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t *status)
Sets the period for automatic SPI accumulation.
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed)
Sets the clock speed for the SPI bus.
int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t *dataToSend, int32_t sendSize)
Executes a write transaction with the device.
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.
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t *buffer, int32_t count)
Executes a read from the device.
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t *status)
Sets the CS Active high for a SPI port.