mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Switches SPI and I2C to use enums in the HAL for ports (#531)
Closes #397
This commit is contained in:
committed by
Peter Johnson
parent
67d62ba164
commit
b2f3479692
@@ -9,19 +9,21 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum HAL_I2CPort : int32_t { HAL_I2C_kOnboard = 0, HAL_I2C_kMXP };
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HAL_InitializeI2C(int32_t port, int32_t* status);
|
||||
int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
|
||||
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status);
|
||||
int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize,
|
||||
uint8_t* dataReceived, int32_t receiveSize);
|
||||
int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
|
||||
int32_t sendSize);
|
||||
int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize);
|
||||
int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t count);
|
||||
void HAL_CloseI2C(int32_t port);
|
||||
void HAL_CloseI2C(HAL_I2CPort port);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,40 +11,49 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
enum HAL_SPIPort : int32_t {
|
||||
HAL_SPI_kOnboardCS0 = 0,
|
||||
HAL_SPI_kOnboardCS1,
|
||||
HAL_SPI_kOnboardCS2,
|
||||
HAL_SPI_kOnboardCS3,
|
||||
HAL_SPI_kMXP
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HAL_InitializeSPI(int32_t port, int32_t* status);
|
||||
int32_t HAL_TransactionSPI(int32_t port, uint8_t* dataToSend,
|
||||
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status);
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size);
|
||||
int32_t HAL_WriteSPI(int32_t port, uint8_t* dataToSend, int32_t sendSize);
|
||||
int32_t HAL_ReadSPI(int32_t port, uint8_t* buffer, int32_t count);
|
||||
void HAL_CloseSPI(int32_t port);
|
||||
void HAL_SetSPISpeed(int32_t port, int32_t speed);
|
||||
void HAL_SetSPIOpts(int32_t port, HAL_Bool msbFirst, HAL_Bool sampleOnTrailing,
|
||||
HAL_Bool clkIdleHigh);
|
||||
void HAL_SetSPIChipSelectActiveHigh(int32_t port, int32_t* status);
|
||||
void HAL_SetSPIChipSelectActiveLow(int32_t port, int32_t* status);
|
||||
int32_t HAL_GetSPIHandle(int32_t port);
|
||||
void HAL_SetSPIHandle(int32_t port, int32_t handle);
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, uint8_t* dataToSend, int32_t sendSize);
|
||||
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count);
|
||||
void HAL_CloseSPI(HAL_SPIPort port);
|
||||
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed);
|
||||
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
|
||||
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);
|
||||
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle);
|
||||
|
||||
void HAL_InitSPIAccumulator(int32_t port, int32_t period, int32_t cmd,
|
||||
void HAL_InitSPIAccumulator(HAL_SPIPort port, int32_t period, int32_t cmd,
|
||||
int32_t xferSize, int32_t validMask,
|
||||
int32_t validValue, int32_t dataShift,
|
||||
int32_t dataSize, HAL_Bool isSigned,
|
||||
HAL_Bool bigEndian, int32_t* status);
|
||||
void HAL_FreeSPIAccumulator(int32_t port, int32_t* status);
|
||||
void HAL_ResetSPIAccumulator(int32_t port, int32_t* status);
|
||||
void HAL_SetSPIAccumulatorCenter(int32_t port, int32_t center, int32_t* status);
|
||||
void HAL_SetSPIAccumulatorDeadband(int32_t port, int32_t deadband,
|
||||
int32_t* status);
|
||||
int32_t HAL_GetSPIAccumulatorLastValue(int32_t port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorValue(int32_t port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorCount(int32_t port, int32_t* status);
|
||||
double HAL_GetSPIAccumulatorAverage(int32_t port, int32_t* status);
|
||||
void HAL_GetSPIAccumulatorOutput(int32_t port, int64_t* value, int64_t* count,
|
||||
void HAL_FreeSPIAccumulator(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_ResetSPIAccumulator(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_SetSPIAccumulatorCenter(HAL_SPIPort port, int32_t center,
|
||||
int32_t* status);
|
||||
void HAL_SetSPIAccumulatorDeadband(HAL_SPIPort port, int32_t deadband,
|
||||
int32_t* status);
|
||||
int32_t HAL_GetSPIAccumulatorLastValue(HAL_SPIPort port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorValue(HAL_SPIPort port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorCount(HAL_SPIPort port, int32_t* status);
|
||||
double HAL_GetSPIAccumulatorAverage(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_GetSPIAccumulatorOutput(HAL_SPIPort port, int64_t* value,
|
||||
int64_t* count, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user