Merge pull request #50 from yatli/cherry-upstream

wiringPi: allow external pins in pinMode, digitalRead, digitalWrite
This commit is contained in:
GNU 2023-04-10 19:59:42 +08:00 committed by GitHub
commit 3ef60f89d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1446,7 +1446,14 @@ void pinMode (int pin, int mode)
setupCheck ("pinMode") ; setupCheck ("pinMode") ;
#ifdef CONFIG_CLOCKWORKPI #ifdef CONFIG_CLOCKWORKPI
CPiPinMode(pin, mode);
if ((pin & PI_GPIO_MASK) == 0) // On-board pin
{
CPiPinMode(pin, mode);
} else if ((node = wiringPiFindNode (pin)) != NULL)
{
node->pinMode (node, pin, mode) ;
}
return; return;
#endif #endif
@ -1565,7 +1572,14 @@ int digitalRead (int pin)
struct wiringPiNodeStruct *node = wiringPiNodes ; struct wiringPiNodeStruct *node = wiringPiNodes ;
#ifdef CONFIG_CLOCKWORKPI #ifdef CONFIG_CLOCKWORKPI
return CPiDigitalRead(pin); if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
{
return CPiDigitalRead(pin);
} else {
if ((node = wiringPiFindNode (pin)) == NULL)
return LOW ;
return node->digitalRead (node, pin) ;
}
#endif #endif
if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
@ -1632,7 +1646,13 @@ void digitalWrite (int pin, int value)
struct wiringPiNodeStruct *node = wiringPiNodes ; struct wiringPiNodeStruct *node = wiringPiNodes ;
#ifdef CONFIG_CLOCKWORKPI #ifdef CONFIG_CLOCKWORKPI
CPiDigitalWrite(pin, value); if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
{
CPiDigitalWrite(pin, value);
} else {
if ((node = wiringPiFindNode (pin)) != NULL)
node->digitalWrite (node, pin, value) ;
}
return; return;
#endif #endif