WPILibC++  2018.4.1-20180729040223-1137-g011f0ff
 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/Types.h"
14 
15 // clang-format off
16 HAL_ENUM(HAL_SPIPort) {
17  HAL_SPI_kOnboardCS0 = 0,
18  HAL_SPI_kOnboardCS1,
19  HAL_SPI_kOnboardCS2,
20  HAL_SPI_kOnboardCS3,
21  HAL_SPI_kMXP
22 };
23 // clang-format on
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
36 void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status);
37 
51 int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend,
52  uint8_t* dataReceived, int32_t size);
53 
65 int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend,
66  int32_t sendSize);
67 
83 int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count);
84 
90 void HAL_CloseSPI(HAL_SPIPort port);
91 
99 void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed);
100 
112 void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
113  HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh);
114 
120 void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status);
121 
127 void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status);
128 
136 int32_t HAL_GetSPIHandle(HAL_SPIPort port);
137 
145 void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle);
146 
154 void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status);
155 
162 void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t* status);
163 
171 void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t* status);
172 
188 void HAL_StartSPIAutoTrigger(HAL_SPIPort port, HAL_Handle digitalSourceHandle,
189  HAL_AnalogTriggerType analogTriggerType,
190  HAL_Bool triggerRising, HAL_Bool triggerFalling,
191  int32_t* status);
192 
199 void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status);
200 
211 void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
212  int32_t dataSize, int32_t zeroSize,
213  int32_t* status);
214 
221 void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t* status);
222 
233 int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint8_t* buffer,
234  int32_t numToRead, double timeout,
235  int32_t* status);
236 
244 int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status);
245 
246 #ifdef __cplusplus
247 } // extern "C"
248 #endif