davids5 opened a new pull request, #8456:
URL: https://github.com/apache/nuttx/pull/8456
## Summary
Allows creation simple of the GPIO devices by pin name
For Example:
```
/****************************************************************************
* Private Types
****************************************************************************/
struct myboard_gpio_dev_s {
struct gpio_dev_s dev;
uint32_t pincfg;
pin_interrupt_t callback;
};
...
/****************************************************************************
* Name: myboard_gpio_register
*
* Description:
* Initialize GPIO driver for input pin.
*
* Input Parameters:
* pincfg - The pin configuration mask for the IO pin.
* pintype - The pin type
* devname - The name of the GPIO device path to register the IO pin as.
*
****************************************************************************/
int myboard_gpio_register(uint32_t pincfg, enum gpio_pintype_e pintype,
const char *devname)
{
FAR struct myboard_gpio_dev_s *priv;
priv = (myboard_gpio_dev_s *) kmm_zalloc(sizeof(struct
myboard_gpio_dev_s));
if (priv == NULL) {
gpioerr("Failed to allocate myboard_gpio_dev_s struct ERRNO:
%d\n", errno);
return -1;
}
priv->dev.gp_pintype = pintype;
priv->dev.gp_ops = &myboard_gpio_ops;
priv->pincfg = pincfg;
return gpio_pin_register_byname(&priv->dev, devname);
}
/****************************************************************************
* Public Functions
****************************************************************************/
void myboard_gpio_init(void)
{
(void)myboard_gpio_register(GPIO_nLED_RED, GPIO_OUTPUT_PIN,
"nLED_RED");
(void)myboard_gpio_register(GPIO_nLED_GREEN, GPIO_OUTPUT_PIN,
"nLED_GREEN");
(void)myboard_gpio_register(GPIO_nLED_BLUE, GPIO_OUTPUT_PIN,
"nLED_BLUE");
}
```
## Impact
None - New Method
## Testing
PX4
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]