Parcourir la source

Adds ability to remove a node from the device tree

pull/148/head
riban il y a 2 ans
Parent
révision
3fa5d82c83
2 fichiers modifiés avec 48 ajouts et 0 suppressions
  1. +47
    -0
      wiringPi/wiringPi.c
  2. +1
    -0
      wiringPi/wiringPi.h

+ 47
- 0
wiringPi/wiringPi.c Voir le fichier

@@ -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 Voir le fichier

@@ -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) ;


Chargement…
Annuler
Enregistrer