mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +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
@@ -28,8 +28,8 @@ static IndexedHandleResource<HAL_RelayHandle, Relay, kNumRelayPins,
|
||||
static priority_recursive_mutex digitalRelayMutex;
|
||||
|
||||
extern "C" {
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle port_handle, uint8_t fwd,
|
||||
int32_t* status) {
|
||||
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle port_handle,
|
||||
HAL_Bool fwd, int32_t* status) {
|
||||
initializeDigital(status);
|
||||
|
||||
if (*status != 0) return HAL_kInvalidHandle;
|
||||
@@ -69,18 +69,19 @@ void HAL_FreeRelayPort(HAL_RelayHandle relay_port_handle) {
|
||||
relayHandles.Free(relay_port_handle);
|
||||
}
|
||||
|
||||
bool HAL_CheckRelayChannel(uint8_t pin) {
|
||||
HAL_Bool HAL_CheckRelayChannel(int32_t pin) {
|
||||
// roboRIO only has 4 headers, and the FPGA has
|
||||
// seperate functions for forward and reverse,
|
||||
// instead of seperate pin IDs
|
||||
return pin < kNumRelayHeaders;
|
||||
return (pin < kNumRelayHeaders) && (pin >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of a relay.
|
||||
* Set the state of a relay output.
|
||||
*/
|
||||
void HAL_SetRelay(HAL_RelayHandle relay_port_handle, bool on, int32_t* status) {
|
||||
void HAL_SetRelay(HAL_RelayHandle relay_port_handle, HAL_Bool on,
|
||||
int32_t* status) {
|
||||
auto port = relayHandles.Get(relay_port_handle);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
@@ -112,7 +113,7 @@ void HAL_SetRelay(HAL_RelayHandle relay_port_handle, bool on, int32_t* status) {
|
||||
/**
|
||||
* Get the current state of the relay channel
|
||||
*/
|
||||
bool HAL_GetRelay(HAL_RelayHandle relay_port_handle, int32_t* status) {
|
||||
HAL_Bool HAL_GetRelay(HAL_RelayHandle relay_port_handle, int32_t* status) {
|
||||
auto port = relayHandles.Get(relay_port_handle);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user