1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

IO: handle NONE (NULL) io pin

This commit is contained in:
Martin 2017-03-16 11:26:14 -04:00
parent 1acf06c69c
commit dcdaa6c7ad

View file

@ -238,6 +238,8 @@ void IOToggle(IO_t io)
// claim IO pin, set owner and resources // claim IO pin, set owner and resources
void IOInit(IO_t io, resourceOwner_e owner, uint8_t index) void IOInit(IO_t io, resourceOwner_e owner, uint8_t index)
{ {
if (!io)
return;
ioRec_t *ioRec = IO_Rec(io); ioRec_t *ioRec = IO_Rec(io);
ioRec->owner = owner; ioRec->owner = owner;
ioRec->index = index; ioRec->index = index;
@ -245,12 +247,16 @@ void IOInit(IO_t io, resourceOwner_e owner, uint8_t index)
void IORelease(IO_t io) void IORelease(IO_t io)
{ {
if (!io)
return;
ioRec_t *ioRec = IO_Rec(io); ioRec_t *ioRec = IO_Rec(io);
ioRec->owner = OWNER_FREE; ioRec->owner = OWNER_FREE;
} }
resourceOwner_e IOGetOwner(IO_t io) resourceOwner_e IOGetOwner(IO_t io)
{ {
if (!io)
return OWNER_FREE;
ioRec_t *ioRec = IO_Rec(io); ioRec_t *ioRec = IO_Rec(io);
return ioRec->owner; return ioRec->owner;
} }