IPC@CHIP® RTOS-LNX – API Documentation

Header image

Main page


◆ gpioReadBankInputs()

int gpioReadBankInputs ( unsigned int  bank,
unsigned int *  value,
unsigned int  mask 
)

Read a whole bank of GPIO inputs by defining a bank number and a GPIO mask.

Parameters
bankBank number, starting at zero.
bank = 0: bit0 of value and mask corresponds to PIO0, bit31 corresponds to PIO31.
bank = 1: bit0 of value and mask corresponds to PIO32, bit31 corresponds to PIO63.
...
valuePointer to a variable that will hold the read value
maskBitmask that defines which GPIOs in the bank are to be read
Returns
0 - success
-2 - wrong PIO in mask or wrong bank number
-3 - could not access register
-4 - value pointer invalid
Example:
#include "clib.h"
int main (void)
{
// Same bank for both inputs and outputs
int bank = 2;
// Set the value of the inputs to 0, will be read later
unsigned int value_inputs = 0x0;
// Set the value of both outputs to 1
unsigned int value_outputs = 0x2000000 + 0x4000000;
// Set the masks for the inputs and outputs to GPIOs 87, 88 and
// 89, 90 accordingly
unsigned int mask_inputs = 0x1000000 + 0x800000;
unsigned int mask_outputs = 0x2000000 + 0x4000000;
// No error checking in this example
// Enable and set GPIOs 87 and 88 as inputs
gpioEnable(87, 1);
gpioEnable(88, 1);
gpioSetMode(87, 1);
gpioSetMode(88, 1);
// Enable and set GPIOs 89 and 90 as outputs
gpioEnable(89, 1);
gpioEnable(90, 1);
gpioSetMode(89, 4);
gpioSetMode(90, 4);
// Read the inputs
gpioReadBankInputs (bank, &value_inputs, mask_inputs);
// Write to the outputs
gpioWriteBankOutputs (bank, value_outputs, mask_outputs);
// Read back from the outputs
gpioReadBankOutputs (bank, &value_outputs, mask_outputs);
// Print result
printf("Inputs value: %X\n", value_inputs);
printf("Output value: %X\n", value_outputs);
return 0;
}
Since
V1.14
See also
gpioEnable(), gpioSetMode(), gpioReadBankOutputs(), gpioWriteBankOutputs()





Top of page | Main page

Copyright © 2018 Beck IPC GmbH
Generated on Fri Jun 8 2018 12:48:20 by Doxygen 1.8.13