mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Switches HAL to fixed length signed integers, and adds our own HAL_Bool Type (#155)
* Switches HAL to fixed length signed integers, and adds our own HAL_Bool type * Replaces HAL Floats with Doubles Doubles are just as fast as floats with optimizations turned on, so switches to all doubles. All made doubles for consistency. * Prepends HAL/ to HAL include files. Also fixes some range errors
This commit is contained in:
committed by
Peter Johnson
parent
4a98e68815
commit
b51e85ae26
@@ -14,7 +14,7 @@ static uint32_t m_portHandle[2];
|
||||
|
||||
extern "C" {
|
||||
|
||||
void HAL_InitializeSerialPort(uint8_t port, int32_t* status) {
|
||||
void HAL_InitializeSerialPort(int32_t port, int32_t* status) {
|
||||
char const* portName;
|
||||
|
||||
if (m_resourceManagerHandle == 0)
|
||||
@@ -33,44 +33,44 @@ void HAL_InitializeSerialPort(uint8_t port, int32_t* status) {
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialBaudRate(uint8_t port, uint32_t baud, int32_t* status) {
|
||||
void HAL_SetSerialBaudRate(int32_t port, int32_t baud, int32_t* status) {
|
||||
*status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_BAUD, baud);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialDataBits(uint8_t port, uint8_t bits, int32_t* status) {
|
||||
void HAL_SetSerialDataBits(int32_t port, int32_t bits, int32_t* status) {
|
||||
*status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_DATA_BITS, bits);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialParity(uint8_t port, uint8_t parity, int32_t* status) {
|
||||
void HAL_SetSerialParity(int32_t port, int32_t parity, int32_t* status) {
|
||||
*status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_PARITY, parity);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialStopBits(uint8_t port, uint8_t stopBits, int32_t* status) {
|
||||
void HAL_SetSerialStopBits(int32_t port, int32_t stopBits, int32_t* status) {
|
||||
*status =
|
||||
viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_STOP_BITS, stopBits);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialWriteMode(uint8_t port, uint8_t mode, int32_t* status) {
|
||||
void HAL_SetSerialWriteMode(int32_t port, int32_t mode, int32_t* status) {
|
||||
*status = viSetAttribute(m_portHandle[port], VI_ATTR_WR_BUF_OPER_MODE, mode);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialFlowControl(uint8_t port, uint8_t flow, int32_t* status) {
|
||||
void HAL_SetSerialFlowControl(int32_t port, int32_t flow, int32_t* status) {
|
||||
*status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_FLOW_CNTRL, flow);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialTimeout(uint8_t port, float timeout, int32_t* status) {
|
||||
void HAL_SetSerialTimeout(int32_t port, double timeout, int32_t* status) {
|
||||
*status = viSetAttribute(m_portHandle[port], VI_ATTR_TMO_VALUE,
|
||||
(uint32_t)(timeout * 1e3));
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_EnableSerialTermination(uint8_t port, char terminator,
|
||||
void HAL_EnableSerialTermination(int32_t port, char terminator,
|
||||
int32_t* status) {
|
||||
viSetAttribute(m_portHandle[port], VI_ATTR_TERMCHAR_EN, VI_TRUE);
|
||||
viSetAttribute(m_portHandle[port], VI_ATTR_TERMCHAR, terminator);
|
||||
@@ -79,25 +79,24 @@ void HAL_EnableSerialTermination(uint8_t port, char terminator,
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_DisableSerialTermination(uint8_t port, int32_t* status) {
|
||||
void HAL_DisableSerialTermination(int32_t port, int32_t* status) {
|
||||
viSetAttribute(m_portHandle[port], VI_ATTR_TERMCHAR_EN, VI_FALSE);
|
||||
*status =
|
||||
viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_END_IN, VI_ASRL_END_NONE);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialReadBufferSize(uint8_t port, uint32_t size, int32_t* status) {
|
||||
void HAL_SetSerialReadBufferSize(int32_t port, int32_t size, int32_t* status) {
|
||||
*status = viSetBuf(m_portHandle[port], VI_READ_BUF, size);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_SetSerialWriteBufferSize(uint8_t port, uint32_t size,
|
||||
int32_t* status) {
|
||||
void HAL_SetSerialWriteBufferSize(int32_t port, int32_t size, int32_t* status) {
|
||||
*status = viSetBuf(m_portHandle[port], VI_WRITE_BUF, size);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
int32_t HAL_GetSerialBytesReceived(uint8_t port, int32_t* status) {
|
||||
int32_t HAL_GetSerialBytesReceived(int32_t port, int32_t* status) {
|
||||
int32_t bytes = 0;
|
||||
|
||||
*status = viGetAttribute(m_portHandle[port], VI_ATTR_ASRL_AVAIL_NUM, &bytes);
|
||||
@@ -105,8 +104,8 @@ int32_t HAL_GetSerialBytesReceived(uint8_t port, int32_t* status) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
uint32_t HAL_ReadSerial(uint8_t port, char* buffer, int32_t count,
|
||||
int32_t* status) {
|
||||
int32_t HAL_ReadSerial(int32_t port, char* buffer, int32_t count,
|
||||
int32_t* status) {
|
||||
uint32_t retCount = 0;
|
||||
|
||||
*status =
|
||||
@@ -119,31 +118,31 @@ uint32_t HAL_ReadSerial(uint8_t port, char* buffer, int32_t count,
|
||||
}
|
||||
|
||||
if (*status == VI_ERROR_TMO || *status > 0) *status = 0;
|
||||
return retCount;
|
||||
return static_cast<int32_t>(retCount);
|
||||
}
|
||||
|
||||
uint32_t HAL_WriteSerial(uint8_t port, const char* buffer, int32_t count,
|
||||
int32_t* status) {
|
||||
int32_t HAL_WriteSerial(int32_t port, const char* buffer, int32_t count,
|
||||
int32_t* status) {
|
||||
uint32_t retCount = 0;
|
||||
|
||||
*status =
|
||||
viWrite(m_portHandle[port], (ViPBuf)buffer, count, (ViPUInt32)&retCount);
|
||||
|
||||
if (*status > 0) *status = 0;
|
||||
return retCount;
|
||||
return static_cast<int32_t>(retCount);
|
||||
}
|
||||
|
||||
void HAL_FlushSerial(uint8_t port, int32_t* status) {
|
||||
void HAL_FlushSerial(int32_t port, int32_t* status) {
|
||||
*status = viFlush(m_portHandle[port], VI_WRITE_BUF);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_ClearSerial(uint8_t port, int32_t* status) {
|
||||
void HAL_ClearSerial(int32_t port, int32_t* status) {
|
||||
*status = viClear(m_portHandle[port]);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
void HAL_CloseSerial(uint8_t port, int32_t* status) {
|
||||
void HAL_CloseSerial(int32_t port, int32_t* status) {
|
||||
*status = viClose(m_portHandle[port]);
|
||||
if (*status > 0) *status = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user