1

I cant seem to find a clear answer what "pinBase" does. Does anyone have an idea what it does? Thanks!

Code

node = wiringPiNewNode (pinBase, 8) ;

Function

struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins)
{
  int    pin ;
  struct wiringPiNodeStruct *node ;

// Minimum pin base is 64

  if (pinBase < 64)
    (void)wiringPiFailure (WPI_FATAL, "wiringPiNewNode: pinBase of %d is < 64\n", pinBase) ;

// Check all pins in-case there is overlap:

  for (pin = pinBase ; pin < (pinBase + numPins) ; ++pin)
    if (wiringPiFindNode (pin) != NULL)
      (void)wiringPiFailure (WPI_FATAL, "wiringPiNewNode: Pin %d overlaps with existing definition\n", pin) ;

  node = (struct wiringPiNodeStruct *)calloc (sizeof (struct wiringPiNodeStruct), 1) ;  // calloc zeros
  if (node == NULL)
    (void)wiringPiFailure (WPI_FATAL, "wiringPiNewNode: Unable to allocate memory: %s\n", strerror (errno)) ;

  node->pinBase         = pinBase ;
  node->pinMax          = pinBase + numPins - 1 ;
  node->pinMode         = pinModeDummy ;
  node->pullUpDnControl = pullUpDnControlDummy ;
  node->digitalRead     = digitalReadDummy ;
  node->digitalWrite    = digitalWriteDummy ;
  node->pwmWrite        = pwmWriteDummy ;
  node->analogRead      = analogReadDummy ;
  node->analogWrite     = analogWriteDummy ;
  node->next            = wiringPiNodes ;
  wiringPiNodes         = node ;

  return node ;
}
1

As far as I am aware this area is only relevant to those who want to write wiringPi extensions.

An extension is a software module which extends wiringPi by adding support for a new type of hardware chip. E.g. if a new chip is created with 128 GPIO you could write an extension to use those GPIO with the wiringPi digitalRead and digitalWrite commands etc.

The pinbase for the chip would be the number to be used for the first GPIO on the chip to distinguish those GPIO from any other currently being used by wiringPi.

  • Makes sense to me because when I changed the pinBase it didnt really affect my program – lauro199471 May 3 '18 at 21:29
  • 1
    A good example is that of a shift register. For example, an MCP3008 has eight output pins. So you normally have access to the standard GPIO via their number. To access the eight additional shiftreg pins, you give it a "pin base" of say 100. Now using the normal wiringPi functions, you can enable/disable the sr pins just like normal GPIO pins by referencing them as pins 100-107. – stevieb May 4 '18 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.