IO: handle NONE (NULL) io pin

This commit is contained in:
Martin 2017-03-16 11:26:14 -04:00
parent 1acf06c69c
commit dcdaa6c7ad
1 changed files with 6 additions and 0 deletions

View File

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