想在Uboot中添加GPIO输入检测,都需要修改哪里
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在board/ti/am335x/board.c文件中添加
#define GPIO_1_15 GPIO_TO_PIN(1, 15)//add
int board_late_init(void)
{
u32 reg_val;
...
gpio_request(GPIO_1_15, "key");//add
gpio_direction_input(GPIO_1_15);//add
mdelay(300);//add
reg_val = gpio_get_value(GPIO_1_15);//add
}
在board/ti/am335x/mux.c中添加
static struct module_pin_mux gpio1_15_pin_mux[] = {
{OFFSET(gpmc_ad15), (MODE(7) | PULLUP_EN)},
{-1},
};//add
void enable_board_pin_mux(void)
{
if(board_is_bone()) {
...
configure_module_pin_mux(spi0_pin_mux);
configure_module_pin_mux(gpio1_15_pin_mux);//add
}
在uboot命令行使用以下指令测试看一下。
=> gpio
gpio - query and control gpio pins
Usage:
gpio <input|set|clear|toggle> <pin>
- input/set/clear/toggle/benchmark the specified pin
gpio status [-a] [<bank> | <pin>] - show [all/claimed] GPIOs