mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Adds port constants to the HAL (#130)
This commit is contained in:
committed by
Peter Johnson
parent
0e127679c1
commit
b45e0917ae
@@ -8,11 +8,9 @@
|
||||
#include "HAL/PWM.h"
|
||||
|
||||
#include "DigitalInternal.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "handles/HandlesInternal.h"
|
||||
|
||||
static_assert(sizeof(uint32_t) <= sizeof(void*),
|
||||
"This file shoves uint32_ts into pointers.");
|
||||
|
||||
using namespace hal;
|
||||
|
||||
extern "C" {
|
||||
@@ -30,8 +28,8 @@ HalDigitalHandle initializePWMPort(HalPortHandle port_handle, int32_t* status) {
|
||||
|
||||
uint8_t origPin = static_cast<uint8_t>(pin);
|
||||
|
||||
if (origPin < kNumHeaders) {
|
||||
pin += kDigitalPins; // remap Headers to end of allocations
|
||||
if (origPin < kNumPWMHeaders) {
|
||||
pin += kNumDigitalPins; // remap Headers to end of allocations
|
||||
} else {
|
||||
pin = remapMXPPWMChannel(pin) + 10; // remap MXP to proper channel
|
||||
}
|
||||
@@ -74,7 +72,7 @@ void freePWMPort(HalDigitalHandle pwm_port_handle, int32_t* status) {
|
||||
digitalPinHandles.Free(pwm_port_handle, HalHandleEnum::PWM);
|
||||
}
|
||||
|
||||
bool checkPWMChannel(uint8_t pin) { return pin < kPwmPins; }
|
||||
bool checkPWMChannel(uint8_t pin) { return pin < kNumPWMPins; }
|
||||
|
||||
/**
|
||||
* Set a PWM channel to the desired value. The values range from 0 to 255 and
|
||||
|
||||
Reference in New Issue
Block a user