diff --git a/Software/Development/OperatingSystem/Linux/Kernel/API/Linux_Kernel_GPIO_API.md b/Software/Development/OperatingSystem/Linux/Kernel/API/Linux_Kernel_GPIO_API.md index d3d358d..9f37de0 100644 --- a/Software/Development/OperatingSystem/Linux/Kernel/API/Linux_Kernel_GPIO_API.md +++ b/Software/Development/OperatingSystem/Linux/Kernel/API/Linux_Kernel_GPIO_API.md @@ -1,60 +1,6 @@ # Linux Kernel GPIO API -## gpiod_direction_output 函数 - -**头文件:** - -```cpp -#include -``` - -**函数原型:** - -```cpp -int gpiod_direction_output(struct gpio_desc *desc, int value); -``` - -**说明:** - -Set the direction of the passed GPIO to output, such as gpiod_set_value() can be called safely on it. The initial value of the output must be specified as the logical value of the GPIO, i.e. taking its ACTIVE_LOW status into account。 - -**参数:** - -desc:GPIO to set to output; - -value:initial output value of the GPIO。 - -**返回值:** - -Return 0 in case of success, else an error code。 - -## gpiod_direction_input 函数 - -**头文件:** - -```cpp -#include -``` - -**函数原型:** - -```cpp -int gpiod_direction_input(struct gpio_desc *desc); -``` - -**说明:** - -Set the direction of the passed GPIO to input, such as gpiod_get_value() can be called safely on it。 - -**参数:** - -desc:GPIO to set to input。 - -**返回值:** - -Return 0 in case of success, else an error code。 - -## gpiod_get_index 函数 +## 1. gpiod_get_index 函数 **头文件:** @@ -89,7 +35,7 @@ flags:optional GPIO initialization flags。 Return a valid GPIO descriptor, -ENOENT if no GPIO has been assigned to the requested function and/or index, or another IS_ERR() code if an error occurred while trying to acquire the GPIO。 -## gpiod_get 函数 +## 2. gpiod_get 函数 **头文件:** @@ -120,7 +66,7 @@ flags:optional GPIO initialization flags。 Return the GPIO descriptor corresponding to the function con_id of device dev, -ENOENT if no GPIO has been assigned to the requested function, or another IS_ERR() code if an error occurred while trying to acquire the GPIO。 -## gpiod_get_index_optional 函数 +## 3. gpiod_get_index_optional 函数 **头文件:** @@ -154,3 +100,85 @@ flags:optional GPIO initialization flags。 **返回值:** This is equivalent to gpiod_get_index(), except that when no GPIO with the specified index was assigned to the requested function it will return NULL。 + +## 4. gpiod_direction_output 函数 + +**头文件:** + +```cpp +#include +``` + +**函数原型:** + +```cpp +int gpiod_direction_output(struct gpio_desc *desc, int value); +``` + +**说明:** + +Set the direction of the passed GPIO to output, such as gpiod_set_value() can be called safely on it. The initial value of the output must be specified as the logical value of the GPIO, i.e. taking its ACTIVE_LOW status into account。 + +**参数:** + +desc:GPIO to set to output; + +value:initial output value of the GPIO。 + +**返回值:** + +Return 0 in case of success, else an error code。 + +## 5. gpiod_direction_input 函数 + +**头文件:** + +```cpp +#include +``` + +**函数原型:** + +```cpp +int gpiod_direction_input(struct gpio_desc *desc); +``` + +**说明:** + +Set the direction of the passed GPIO to input, such as gpiod_get_value() can be called safely on it。 + +**参数:** + +desc:GPIO to set to input。 + +**返回值:** + +Return 0 in case of success, else an error code。 + +## 6. gpiod_set_value_cansleep 函数 + +**头文件:** + +```cpp +#include +``` + +**函数原型:** + +```cpp +void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); +``` + +**说明:** + +Set the logical value of the GPIO, i.e. taking its ACTIVE_LOW status into account. This function is to be called from contexts that can sleep。 + +**参数:** + +desc:gpio whose value will be assigned; + +value:value to assign。 + +**返回值:** + +无