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

Function gpio_get

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

* 读取指定gpio引脚的值 * @gpio gpio引脚,取值范围[0,127] * * 例: 读取gpio50引脚上的值 * gpio_level_t level; * level = gpio_get(50); */

Source from the content-addressed store, hash-verified

179 * level = gpio_get(50);
180 */
181unsigned int gpio_get(unsigned int gpio)
182{
183 volatile unsigned int *gpio_inx = NULL; // GPIO_INx寄存器
184 unsigned int port = GPIO_GET_PORT(gpio);
185 unsigned int pin = GPIO_GET_PIN(gpio);
186
187 // 获取寄存器地址
188 switch (port)
189 {
190 case 0:
191 gpio_inx = (volatile unsigned int *)LS1C_GPIO_IN0;
192 break;
193
194 case 1:
195 gpio_inx = (volatile unsigned int *)LS1C_GPIO_IN1;
196 break;
197
198 case 2:
199 gpio_inx = (volatile unsigned int *)LS1C_GPIO_IN2;
200 break;
201
202 case 3:
203 gpio_inx = (volatile unsigned int *)LS1C_GPIO_IN3;
204 break;
205
206 default: // 正常的流程不应该走到这里,直接返回
207 return 0;
208 }
209
210 // 读取
211 return reg_get_bit(gpio_inx, pin);
212}
213
214
215/**

Callers 7

pico_pin_readFunction · 0.50
DEV_Digital_ReadFunction · 0.50
ls1c_pin_readFunction · 0.50
ls1c_touch_irqhandlerFunction · 0.50
ls1c_get_sdaFunction · 0.50
ls1c_get_sclFunction · 0.50
gpio_get_valueFunction · 0.50

Calls 1

reg_get_bitFunction · 0.70

Tested by

no test coverage detected