GPIO operation function in linux kernel

1. gpio_set_value (unsigned gpio, int value) is used to set the value of the gpio register
2. gpio_direction_output(unsigned gpio, int value) is used to set gpio as the output function, and also set the value of gpio output.
Generally speaking, to set a GPIO port as an output, execute gpio_direction_output once, and then just execute gpio_set_value.

3. gpio_direction_input (unsigned gpio) is used to set gpio as the input function
4. gpio_get_value (unsigned gpio) is used to obtain the input value of the gpio port;

5. Before using the gpio port, use gpio_request (unsigned gpio, const char* label) to apply for the use of the gpio port. If the application is successful, it means that the gpio port is not used.
6. After using the gpio port, use gpio_free (unsigned gpio) to release the gpio port.

7. How to get the gpio port? You can check the relevant files of the corresponding version in the kernel, or you can calculate it yourself. For example, the gpio of GPIOA1 is 1, and the gpio of GPIOB2 is 34.
8. The general function interface of the gpio port is defined in the gpiolib.c file, and the declaration is in gpio.h.

Forwarding address: http://blog.csdn.net/u010350904/article/details/50738144

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325806480&siteId=291194637