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

Function gpio_init

bsp/loongson/ls1cdev/libraries/ls1c_gpio.c:99–119  ·  view source on GitHub ↗

* gpio初始化 * @gpio gpio引脚,取值范围[0, 127] * @mode gpio的工作模式(输入、输出) * * 例: 将gpio50初始化为输出 * gpio_init(50, gpio_mode_output); */

Source from the content-addressed store, hash-verified

97 * gpio_init(50, gpio_mode_output);
98 */
99void gpio_init(unsigned int gpio, gpio_mode_t mode)
100{
101 volatile unsigned int *gpio_enx = NULL; // GPIO_ENx寄存器
102 unsigned int pin = GPIO_GET_PIN(gpio);
103
104 // 将pin设为普通GPIO
105 pin_set_purpose(gpio, PIN_PURPOSE_GPIO);
106
107 // 设置gpio工作模式(输入、输出)
108 gpio_enx = gpio_get_en_reg(gpio);
109 if (gpio_mode_output == mode) // 输出
110 {
111 reg_clr_one_bit(gpio_enx, pin);
112 }
113 else // 输入
114 {
115 reg_set_one_bit(gpio_enx, pin);
116 }
117
118 return ;
119}
120
121
122/*

Callers 15

pico_pin_modeFunction · 0.50
pico_spi_initFunction · 0.50
DEV_GPIO_ModeFunction · 0.50
switchToSPIFunction · 0.50
at32_pin_modeFunction · 0.50
at32_pin_irq_enableFunction · 0.50
rt_hw_spi_device_attachFunction · 0.50
phy_resetFunction · 0.50
phy_clock_configFunction · 0.50
at32_msp_usart_initFunction · 0.50
at32_msp_spi_initFunction · 0.50
at32_msp_i2c_initFunction · 0.50

Calls 4

pin_set_purposeFunction · 0.70
gpio_get_en_regFunction · 0.70
reg_clr_one_bitFunction · 0.70
reg_set_one_bitFunction · 0.70

Tested by

no test coverage detected