Преглед изворни кода

Adds ability to remove a node from the device tree

pull/148/head
riban пре 2 година
родитељ
комит
3fa5d82c83
2 измењених фајлова са 48 додато и 0 уклоњено
  1. +47
    -0
      wiringPi/wiringPi.c
  2. +1
    -0
      wiringPi/wiringPi.h

+ 47
- 0
wiringPi/wiringPi.c Прегледај датотеку

@@ -1369,6 +1369,53 @@ struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins)
return node ;
}

/*
* wiringPiRemoveNode:
* Remove an existing GPIO node from the wiringPi handling system
*********************************************************************************
*/

int wiringPiRemoveNode (int pinBase)
{
struct wiringPiNodeStruct *node ;
struct wiringPiNodeStruct *nodePrevious ;

// Don't try if there are no nodes in the tree or pinBase in naitive GPI range
if (wiringPiNodes == NULL || pinBase < 64)
return FALSE;

// Find node
node = wiringPiFindNode (pinBase) ;
if (node == NULL)
return FALSE;

// Remove node pointer from tree
if (node == wiringPiNodes)
{
wiringPiNodes = node->next;
}
else
{

nodePrevious = wiringPiNodes;

while (nodePrevious != NULL) {
if (nodePrevious->next == node) {
nodePrevious->next = node->next;
break;
}
nodePrevious = nodePrevious->next;
}
}

//!@todo Run device specific code

// Recover memory allocated to node
free(node);

return TRUE ;
}


#ifdef notYetReady
/*


+ 1
- 0
wiringPi/wiringPi.h Прегледај датотеку

@@ -198,6 +198,7 @@ extern int wiringPiFailure (int fatal, const char *message, ...) ;

extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ;
extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ;
extern int wiringPiRemoveNode (int pinBase) ;

extern void wiringPiVersion (int *major, int *minor) ;
extern int wiringPiSetup (void) ;


Loading…
Откажи
Сачувај