Version 4 (modified by Ben Gras, on 05/06/15 at 11:29:29) (diff) |
---|
Basic GPIO API just covering GPIO_DIGITAL_OUTPUT.
/* <rtems/gpio.h> */ /* a configured GPIO pin handle. this is filled in by rtems_gpio_configure_pin_* * and can then be passed to other api functions. */ typedef struct gpio_pin_handle; /* fill in gpio_pin struct to use this pin in a digital out manner. * must be currently unused. * pin_number is a number that is interpreted by the BSP and will be defined * with device-specific names such as BBB_P9_33, indicating pin 33 on header P9 * on the board. * * the gpio_pin struct is then filled in and can be passed to other functions. */ int rtems_gpio_configure_pin_digital_out(&gpio_pin_handle, pin_number); /* for a digital_out pin, set it to logical high */ int rtems_gpio_digital_set(&gpio_pin_handle); /* for a digital_out pin, set it to logical low */ int rtems_gpio_digital_clear(&gpio_pin_handle); /* a currently configured pin is to be released and made unused, allowing repurposing. */ int rtems_gpio_release_pin(&gpio_pin_handle); /* returned error codes */ #define GPIO_SUCCESSFUL 0 /* operation OK */ #define GPIO_UNKNOWN_PIN 1 /* pin not known by bsp */ #define GPIO_UNCONFIGURED_PIN 2 /* pin not configured with rtems_gpio_configure_* */ #define GPIO_MISCONFIGURED_PIN 3 /* pin configuration doesn't match operation */ /* <libcpu/am335x.h> */ /* gpio pin definitions for the AM335X SOC */ #define AM335X_V9 63 /* GPIO1[31], SOC pin V9 */ #define AM335X_V15 53 /* GPIO1[21], SOC pin V15 */ #define AM335X_U15 86 /* GPIO2[22], SOC pin U15 */ #define AM335X_T15 87 /* GPIO2[23], SOC pin T15 */ #define AM335X_V16 88 /* GPIO2[24], SOC pin V16 */ /* <bsp/beagleboneblack.h> */ /* gpio pin definitions - same as above but with names * indicating how they are wired on the Beaglebone Black board */ #define BBB_P8_20 71 63 /* GPIO1[31], BBB P8 header pin 20 */ #define BBB_LED_USR0 53 /* GPIO1[21], BBB USR0 LED */ #define BBB_LED_USR1 86 /* GPIO2[22], BBB USR1 LED */ #define BBB_LED_USR2 87 /* GPIO2[23], BBB USR2 LED */ #define BBB_LED_USR3 88 /* GPIO2[24], BBB USR3 LED */ /* example usage */ #include <rtems/gpio.h> struct gpio_pin_handle led_usr0_handle; /* opaque to the user */ if(rtems_gpio_configure_pin_digital_out(&handle, led_usr0_handle) == GPIO_SUCCESS) { rtems_gpio_digital_set(&led_usr0_handle); rtems_gpio_release_pin(&led_usr0_handle); }