int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int status = 0; if (strcmp(argv[1], "set") == 0) { u32 gpio_number = 0; u32 gpio_value = 0; if (argc != 4) { printf("error invalid usage\n"); return -1; } gpio_number = simple_strtoul(argv[2], NULL, 10); gpio_value = simple_strtoul(argv[3], NULL, 10); configure_pad_mode(gpio_number); configure_gpio_output(gpio_number); set_gpio_output(gpio_number, (gpio_value == 0) ? 0 : 1); }else if(strcmp(argv[1], "get") == 0){ u32 gpio_number = 0; if (argc != 3) { printf("error invalid usage\n"); return -1; } gpio_number = simple_strtoul(argv[2], NULL, 10); printf("Read GPIO Pin %d = 0x%x\n", gpio_number, get_gpio_value(gpio_number)); } return status; }
void start_test() { int i; for (i = 0; i < GPIO_NB; ++i) configure_gpio_output(&gpio_to_toggle[i], (enum gpio_bank) index_to_mapping[i][0], index_to_mapping[i][1], GPIO_PUSH_PULL); schedule_task(now, (task_handler) toggle_gpio, 0, 0, 0, 0); }