mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Prepends all HAL functions with HAL_ (#146)
This commit is contained in:
committed by
Peter Johnson
parent
5ad28d58ec
commit
b637b9ee4c
@@ -20,18 +20,18 @@
|
||||
SPI::SPI(Port SPIport) {
|
||||
m_port = SPIport;
|
||||
int32_t status = 0;
|
||||
spiInitialize(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiInitialize(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
static int32_t instances = 0;
|
||||
instances++;
|
||||
HALReport(HALUsageReporting::kResourceType_SPI, instances);
|
||||
HAL_Report(HALUsageReporting::kResourceType_SPI, instances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
SPI::~SPI() { spiClose(m_port); }
|
||||
SPI::~SPI() { HAL_SpiClose(m_port); }
|
||||
|
||||
/**
|
||||
* Configure the rate of the generated clock signal.
|
||||
@@ -41,7 +41,7 @@ SPI::~SPI() { spiClose(m_port); }
|
||||
*
|
||||
* @param hz The clock rate in Hertz.
|
||||
*/
|
||||
void SPI::SetClockRate(double hz) { spiSetSpeed(m_port, hz); }
|
||||
void SPI::SetClockRate(double hz) { HAL_SpiSetSpeed(m_port, hz); }
|
||||
|
||||
/**
|
||||
* Configure the order that bits are sent and received on the wire
|
||||
@@ -49,8 +49,8 @@ void SPI::SetClockRate(double hz) { spiSetSpeed(m_port, hz); }
|
||||
*/
|
||||
void SPI::SetMSBFirst() {
|
||||
m_msbFirst = true;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +59,8 @@ void SPI::SetMSBFirst() {
|
||||
*/
|
||||
void SPI::SetLSBFirst() {
|
||||
m_msbFirst = false;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ void SPI::SetLSBFirst() {
|
||||
*/
|
||||
void SPI::SetSampleDataOnFalling() {
|
||||
m_sampleOnTrailing = true;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,8 +79,8 @@ void SPI::SetSampleDataOnFalling() {
|
||||
*/
|
||||
void SPI::SetSampleDataOnRising() {
|
||||
m_sampleOnTrailing = false;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ void SPI::SetSampleDataOnRising() {
|
||||
*/
|
||||
void SPI::SetClockActiveLow() {
|
||||
m_clk_idle_high = true;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,8 +99,8 @@ void SPI::SetClockActiveLow() {
|
||||
*/
|
||||
void SPI::SetClockActiveHigh() {
|
||||
m_clk_idle_high = false;
|
||||
spiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +108,8 @@ void SPI::SetClockActiveHigh() {
|
||||
*/
|
||||
void SPI::SetChipSelectActiveHigh() {
|
||||
int32_t status = 0;
|
||||
spiSetChipSelectActiveHigh(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetChipSelectActiveHigh(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +117,8 @@ void SPI::SetChipSelectActiveHigh() {
|
||||
*/
|
||||
void SPI::SetChipSelectActiveLow() {
|
||||
int32_t status = 0;
|
||||
spiSetChipSelectActiveLow(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetChipSelectActiveLow(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ void SPI::SetChipSelectActiveLow() {
|
||||
*/
|
||||
int32_t SPI::Write(uint8_t* data, uint8_t size) {
|
||||
int32_t retVal = 0;
|
||||
retVal = spiWrite(m_port, data, size);
|
||||
retVal = HAL_SpiWrite(m_port, data, size);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
|
||||
if (initiate) {
|
||||
auto dataToSend = new uint8_t[size];
|
||||
std::memset(dataToSend, 0, size);
|
||||
retVal = spiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
retVal = HAL_SpiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
} else
|
||||
retVal = spiRead(m_port, dataReceived, size);
|
||||
retVal = HAL_SpiRead(m_port, dataReceived, size);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
|
||||
int32_t SPI::Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
|
||||
uint8_t size) {
|
||||
int32_t retVal = 0;
|
||||
retVal = spiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
retVal = HAL_SpiTransaction(m_port, dataToSend, dataReceived, size);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -192,10 +192,10 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
|
||||
uint8_t data_shift, uint8_t data_size, bool is_signed,
|
||||
bool big_endian) {
|
||||
int32_t status = 0;
|
||||
spiInitAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size,
|
||||
valid_mask, valid_value, data_shift, data_size, is_signed,
|
||||
big_endian, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiInitAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size,
|
||||
valid_mask, valid_value, data_shift, data_size,
|
||||
is_signed, big_endian, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,8 +203,8 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
|
||||
*/
|
||||
void SPI::FreeAccumulator() {
|
||||
int32_t status = 0;
|
||||
spiFreeAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiFreeAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,8 +212,8 @@ void SPI::FreeAccumulator() {
|
||||
*/
|
||||
void SPI::ResetAccumulator() {
|
||||
int32_t status = 0;
|
||||
spiResetAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiResetAccumulator(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,8 +226,8 @@ void SPI::ResetAccumulator() {
|
||||
*/
|
||||
void SPI::SetAccumulatorCenter(int32_t center) {
|
||||
int32_t status = 0;
|
||||
spiSetAccumulatorCenter(m_port, center, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetAccumulatorCenter(m_port, center, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,8 +235,8 @@ void SPI::SetAccumulatorCenter(int32_t center) {
|
||||
*/
|
||||
void SPI::SetAccumulatorDeadband(int32_t deadband) {
|
||||
int32_t status = 0;
|
||||
spiSetAccumulatorDeadband(m_port, deadband, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiSetAccumulatorDeadband(m_port, deadband, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,8 +244,8 @@ void SPI::SetAccumulatorDeadband(int32_t deadband) {
|
||||
*/
|
||||
int32_t SPI::GetAccumulatorLastValue() const {
|
||||
int32_t status = 0;
|
||||
int32_t retVal = spiGetAccumulatorLastValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int32_t retVal = HAL_SpiGetAccumulatorLastValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -256,8 +256,8 @@ int32_t SPI::GetAccumulatorLastValue() const {
|
||||
*/
|
||||
int64_t SPI::GetAccumulatorValue() const {
|
||||
int32_t status = 0;
|
||||
int64_t retVal = spiGetAccumulatorValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
int64_t retVal = HAL_SpiGetAccumulatorValue(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -271,8 +271,8 @@ int64_t SPI::GetAccumulatorValue() const {
|
||||
*/
|
||||
uint32_t SPI::GetAccumulatorCount() const {
|
||||
int32_t status = 0;
|
||||
uint32_t retVal = spiGetAccumulatorCount(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
uint32_t retVal = HAL_SpiGetAccumulatorCount(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -283,8 +283,8 @@ uint32_t SPI::GetAccumulatorCount() const {
|
||||
*/
|
||||
double SPI::GetAccumulatorAverage() const {
|
||||
int32_t status = 0;
|
||||
double retVal = spiGetAccumulatorAverage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
double retVal = HAL_SpiGetAccumulatorAverage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -299,6 +299,6 @@ double SPI::GetAccumulatorAverage() const {
|
||||
*/
|
||||
void SPI::GetAccumulatorOutput(int64_t& value, uint32_t& count) const {
|
||||
int32_t status = 0;
|
||||
spiGetAccumulatorOutput(m_port, &value, &count, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
HAL_SpiGetAccumulatorOutput(m_port, &value, &count, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user