1. gpio_request(unsigned gpio, const char *label):
為避免不同的driver同時設定同一根GPIO,所以先用gpio_request看看是否有人使用,事後要用gpio_free。
呼叫gpio_get_value和gpio_set_value獲取設置值
err = gpio_request(S5PV210_GPJ1(4), "GPJ1"); if (err) printk(KERN_ERR "#### failed to request GPJ1 for CAM_2V8\n"); ... ... ... gpio_free(S5PV210_GPJ1(4));
example
2. s3c2410_gpio_cfgpin(unsigned int pin, unsigned int to)
作用是規定I/O port的用途:
如果當function mode(10),output port(00),input(01)
s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
3. gpio_direction_output(unsigned gpio, int value)
設為output,並拉low (0), high (1)
gpio_direction_output(S5PV2XX_GPH0(7), 0); gpio_direction_output(S5PV2XX_GPH0(7), 1);
4. set_irq_type(unsigned int irq, unsigned int type)
第一個参數是中斷號。第二個参數是中斷類型,表示上升緣觸發、下降緣觸發、高電位觸發或者低電位觸發。
5. int gpio_is_valid(int number);
判斷一個I/O是否合法
6. gpio_export(30, true);
Exporting that particular pin (30) to sysfs entry then use this API
7. gpio_get_value(30);
Get value from GPIO pin
沒有留言:
張貼留言