MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pin_set_purpose

Function pin_set_purpose

bsp/loongson/ls1bdev/libraries/ls1b_pin.c:26–42  ·  view source on GitHub ↗

* 把指定pin设置为指定用途(普通gpio,非gpio) * @gpio gpio引脚编号 * @purpose 用途 */

Source from the content-addressed store, hash-verified

24 * @purpose 用途
25 */
26void pin_set_purpose(unsigned int gpio, pin_purpose_t purpose)
27{
28 volatile unsigned int *gpio_cfgx; // GPIO_CFGx寄存器
29 unsigned int pin = GPIO_GET_PIN(gpio);
30
31 gpio_cfgx = gpio_get_cfg_reg(gpio);
32 if (PIN_PURPOSE_GPIO == purpose) // 引脚用作普通gpio
33 {
34 reg_set_one_bit(gpio_cfgx, pin);
35 }
36 else // 引脚用作其它功能(非gpio)
37 {
38 reg_clr_one_bit(gpio_cfgx, pin);
39 }
40
41 return ;
42}
43
44
45

Callers 2

gpio_initFunction · 0.70
rt_hw_uart_initFunction · 0.50

Calls 3

gpio_get_cfg_regFunction · 0.70
reg_set_one_bitFunction · 0.70
reg_clr_one_bitFunction · 0.70

Tested by

no test coverage detected