gpio-admin.c

Defines

GPIO_CLASS_PATH
GPIO_EXPORT_PATH
GPIO_UNEXPORT_PATH
DOWN
UP
BLOCK_SIZE
GPIO_BASE
GPPUD
GPPUDCLK0
BIT(x)
BANK(x)

Functions

static void usage_error(char **argv)

Prints a help message in case of wrongful invocation

Parameters
  • argv -

    The array of arguments (only argv[0] is used)

static void allow_access_by_user(unsigned int pin, const char *filename)

Sets the ownership of a pin

Parameters
  • pin -

    The number of the pin

  • filename -

    The filename

static unsigned int parse_gpio_pin(const char *pin_str)

Checks the input and returns the value of the pin

Return
An integer with the value of the pin
Parameters
  • pin_str -

    the number of the pin in a string

static void write_pin_to_path(const char *path, unsigned int pin)

Writes the pin value in the desired path

Parameters
  • path -

    The path of the file to write

  • pin -

    The number of the pin

static void set_pullupdown(int pin, int direction)

Sets the direction of the pin

Parameters
  • pin -

    The value of the pin

  • direction -

    The direction (0 for out, 1 for in)

int main(int argc, char **argv)

Parses the console parameters and executes the desired action.

Parameters
  • argc -

    The number of console parameters

  • argv -

    The value of the console parameters