Ex:
int setGpioA(u32 pin, u32 value);
int unknown_GPIO(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) //argc 參數個數
{
if((strcmp(argv[1], "on") == 0) || (strcmp(argv[1], "ON") == 0))
{
setGpioA(10, 0);
}
else if((strcmp(argv[1], "off") == 0) || (strcmp(argv[1], "OFF") == 0))
{
setGpioA(10, 1);
}
return 0;
}
int setGpioA(u32 pin, u32 value)
{
volatile unsigned int reg = 0x01 << pin;
if(value == 1)
{
*((volatile unsigned int *)0x74000000) |= reg; //取暫存器位址之值
printf("ndlndsnlk 0x74000000 %X\n" , reg);
}
else
{
*((volatile unsigned int *)0x74000000) &= ~reg;
}
return 0;
}
U_BOOT_CMD(
unknown, 2, 4, unknown_GPIO,
"Unknown GPIO \n",
""
"input on/off \n"
);