Don't fail silently if DIO or PWM allocation fails

Change-Id: I800c429507c3436c2d49561ba279700ad52569fe
This commit is contained in:
Dustin Spicuzza
2014-12-16 14:24:14 -05:00
parent 786e844a9f
commit 0d8c454727
2 changed files with 12 additions and 2 deletions

View File

@@ -384,7 +384,11 @@ bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status) {
DigitalPort* port = (DigitalPort*) digital_port_pointer;
char buf[64];
snprintf(buf, 64, "DIO %d", port->port.pin);
if (DIOChannels->Allocate(port->port.pin, buf) == ~0ul) return false;
if (DIOChannels->Allocate(port->port.pin, buf) == ~0ul) {
*status = RESOURCE_IS_ALLOCATED;
return false;
}
{
Synchronized sync(digitalDIOSemaphore);
@@ -420,7 +424,11 @@ bool allocatePWMChannel(void* digital_port_pointer, int32_t *status) {
DigitalPort* port = (DigitalPort*) digital_port_pointer;
char buf[64];
snprintf(buf, 64, "PWM %d", port->port.pin);
if (PWMChannels->Allocate(port->port.pin, buf) == ~0ul) return false;
if (PWMChannels->Allocate(port->port.pin, buf) == ~0ul) {
*status = RESOURCE_IS_ALLOCATED;
return false;
}
if (port->port.pin > tPWM::kNumHdrRegisters-1) {
snprintf(buf, 64, "PWM %d and DIO %d", port->port.pin, remapMXPPWMChannel(port->port.pin) + 10);
if (DIOChannels->Allocate(remapMXPPWMChannel(port->port.pin) + 10, buf) == ~0ul) return false;