mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +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
@@ -10,6 +10,7 @@
|
||||
#include <atomic>
|
||||
|
||||
#include "DigitalInternal.h"
|
||||
#include "HAL/DIO.h"
|
||||
#include "HAL/HAL.h"
|
||||
#include "spilib/spi-lib.h"
|
||||
|
||||
@@ -78,19 +79,24 @@ void spiInitialize(uint8_t port, int32_t* status) {
|
||||
break;
|
||||
case 4:
|
||||
initializeDigital(status);
|
||||
if (!allocateDIO(getPort(14), false, status)) {
|
||||
if (*status != 0) return;
|
||||
if (!allocateDIO(initializeDigitalPort(getPort(14), status), false,
|
||||
status)) {
|
||||
printf("Failed to allocate DIO 14\n");
|
||||
return;
|
||||
}
|
||||
if (!allocateDIO(getPort(15), false, status)) {
|
||||
if (!allocateDIO(initializeDigitalPort(getPort(15), status), false,
|
||||
status)) {
|
||||
printf("Failed to allocate DIO 15\n");
|
||||
return;
|
||||
}
|
||||
if (!allocateDIO(getPort(16), true, status)) {
|
||||
if (!allocateDIO(initializeDigitalPort(getPort(16), status), true,
|
||||
status)) {
|
||||
printf("Failed to allocate DIO 16\n");
|
||||
return;
|
||||
}
|
||||
if (!allocateDIO(getPort(17), false, status)) {
|
||||
if (!allocateDIO(initializeDigitalPort(getPort(17), status), false,
|
||||
status)) {
|
||||
printf("Failed to allocate DIO 17\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user