Changes HAL Port from a pointer to a handle (#93)

HAL Port is using a special handle, where the module and pin are bit
shifted straight into the handle. This is one of the few special cases
we have, but for the way port is used it is much cleaner and uses much
less memory.  Plus it is generic and not specific to one type.
This commit is contained in:
Thad House
2016-06-05 15:23:58 -07:00
committed by Peter Johnson
parent 5a82f73d9b
commit fc515f4572
44 changed files with 288 additions and 233 deletions

View File

@@ -24,8 +24,8 @@
#include "FRC_NetworkCommunication/LoadOut.h"
#include "FRC_NetworkCommunication/UsageReporting.h"
#include "HAL/Errors.h"
#include "HAL/Port.h"
#include "ctre/ctre.h"
#include "handles/HandlesInternal.h"
#include "visa/visa.h"
const uint32_t solenoid_kNumDO7_0Elements = 8;
@@ -42,28 +42,21 @@ static uint32_t timeEpoch = 0;
static uint32_t prevFPGATime = 0;
static HalNotifierHandle rolloverNotifier = 0;
using namespace hal;
extern "C" {
void* getPort(uint8_t pin) {
Port* port = new Port();
port->pin = pin;
port->module = 1;
return port;
}
HalPortHandle getPort(uint8_t pin) { return createPortHandle(pin, 1); }
/**
* @deprecated Uses module numbers
*/
void* getPortWithModule(uint8_t module, uint8_t pin) {
Port* port = new Port();
port->pin = pin;
port->module = module;
return port;
HalPortHandle getPortWithModule(uint8_t module, uint8_t pin) {
return createPortHandle(pin, module);
}
void freePort(void* port_pointer) {
Port* port = (Port*)port_pointer;
delete port;
void freePort(HalPortHandle port_handle) {
// noop
}
const char* getHALErrorMessage(int32_t code) {