mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
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:
committed by
Peter Johnson
parent
5a82f73d9b
commit
fc515f4572
@@ -9,9 +9,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Handles.h"
|
||||
|
||||
extern "C" {
|
||||
// Analog input functions
|
||||
void* initializeAnalogInputPort(void* port_pointer, int32_t* status);
|
||||
void* initializeAnalogInputPort(HalPortHandle port_handle, int32_t* status);
|
||||
void freeAnalogInputPort(void* analog_port_pointer);
|
||||
bool checkAnalogModule(uint8_t module);
|
||||
bool checkAnalogInputChannel(uint32_t pin);
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Handles.h"
|
||||
|
||||
extern "C" {
|
||||
void* initializeAnalogOutputPort(void* port_pointer, int32_t* status);
|
||||
void* initializeAnalogOutputPort(HalPortHandle port_handle, int32_t* status);
|
||||
void freeAnalogOutputPort(void* analog_port_pointer);
|
||||
void setAnalogOutput(void* analog_port_pointer, double voltage,
|
||||
int32_t* status);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Handles.h"
|
||||
|
||||
enum AnalogTriggerType {
|
||||
kInWindow = 0,
|
||||
kState = 1,
|
||||
@@ -17,7 +19,7 @@ enum AnalogTriggerType {
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
void* initializeAnalogTrigger(void* port_pointer, uint32_t* index,
|
||||
void* initializeAnalogTrigger(HalPortHandle port_handle, uint32_t* index,
|
||||
int32_t* status);
|
||||
void cleanAnalogTrigger(void* analog_trigger_pointer, int32_t* status);
|
||||
void setAnalogTriggerLimitsRaw(void* analog_trigger_pointer, int32_t lower,
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Handles.h"
|
||||
|
||||
extern "C" {
|
||||
// the following 2 functions are here as they will be changed with
|
||||
// the handle changes to be DIO exclusive.
|
||||
void* initializeDigitalPort(void* port_pointer, int32_t* status);
|
||||
void* initializeDigitalPort(HalPortHandle port_handle, int32_t* status);
|
||||
void freeDigitalPort(void* digital_port_pointer);
|
||||
|
||||
void* allocatePWM(int32_t* status);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "DIO.h"
|
||||
#include "Encoder.h"
|
||||
#include "Errors.h"
|
||||
#include "Handles.h"
|
||||
#include "I2C.h"
|
||||
#include "Interrupts.h"
|
||||
#include "Notifier.h"
|
||||
@@ -211,9 +212,9 @@ extern const uint32_t solenoid_kNumDO7_0Elements;
|
||||
extern const uint32_t interrupt_kNumSystems;
|
||||
extern const uint32_t kSystemClockTicksPerMicrosecond;
|
||||
|
||||
void* getPort(uint8_t pin);
|
||||
void* getPortWithModule(uint8_t module, uint8_t pin);
|
||||
void freePort(void* port);
|
||||
HalPortHandle getPort(uint8_t pin);
|
||||
HalPortHandle getPortWithModule(uint8_t module, uint8_t pin);
|
||||
void freePort(HalPortHandle port);
|
||||
const char* getHALErrorMessage(int32_t code);
|
||||
|
||||
uint16_t getFPGAVersion(int32_t* status);
|
||||
|
||||
@@ -17,3 +17,5 @@
|
||||
#define HAL_HANDLE_NEGATIVE_INDEX -5
|
||||
|
||||
typedef int32_t HalHandle;
|
||||
|
||||
typedef HalHandle HalPortHandle;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef struct port_t {
|
||||
uint8_t pin;
|
||||
uint8_t module;
|
||||
} Port;
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Handles.h"
|
||||
|
||||
extern "C" {
|
||||
void* initializeSolenoidPort(void* port_pointer, int32_t* status);
|
||||
void* initializeSolenoidPort(HalPortHandle port_handle, int32_t* status);
|
||||
void freeSolenoidPort(void* solenoid_port_pointer);
|
||||
bool checkSolenoidModule(uint8_t module);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user