Configuring for General Purpose
Basically you can configure a GPIO port either for input or for output, the topic provides examples on the configuration.
Configuring for Output
The following code block provides an example of configuring GPIO11 as an output port.
port = 11; n = port >> 2; shift = ((port & 0x3) << 3); //direction = output modl(regs->doen+n, GPIO_DOEN_MASK<<shift, 0<<shift); //pull up modl(regs->dout+n, GPIO_DOUT_MASK<<shift, 1<<shift); //pull down modl(regs->dout+n, GPIO_DOUT_MASK<<shift, 0<<shift);
Configuring for Input
The following code block provides an example of configuring GPIO12 as an input port.
port = 12; n = port >> 2; shift = ((port & 0x3) << 3); // direction = input modl(regs->doen+n, GPIO_DOEN_MASK<<shift, 1<<shift); // connect 3.3V to pull up, or GND to pull down. value = (regs->din[port>>5] >> (port & 0x1F)) & 0x1;