I am not sure that I understand your question correctly. A GPIO can be both input and output. How it is to be configured depends, of course, on the external circuit (i.e. the circuit on the PCB board). So if you want to read the state at the pin (input), you need to use the “digitalRead” function. If you want to output a signal (output), you need to use the “digitalWrite” function. Both functions configure the signal direction of the GPIO appropriately beforehand. As the first transfer parameter, both require the number of the GPIO to be used starting with 0 for the first GPIO of the rapidM2M M22x module.
It is recommended to define a constant or define with a speaking name for each GPIO used at the beginning of the code, and then use it each time you call “digitalWrite” or “digitalRead”. This makes the code easier to read and if the hardware in which the rapidM2M M22x module is installed changes, the code can be quickly adapted by a single change at the beginning of the code.
/* Pin configuration */
PIN_LED1_R = 1, // RGB LED 1: Red (GPIO1 is used)
PIN_LED1_G = 2, // RGB LED 1: Green (GPIO2 is used)
PIN_LED1_B = 3, // RGB LED 1: Blue (GPIO3 is used)
PIN_LED2 = 0, // LED 2: Green (GPIO0 is used)
PIN_LED3 = 4, // LED 3: Green (GPIO4 is used)
LED_ENABLE = RM2M_GPIO_HIGH, // By setting the GPIO to "high" the LED is turned on
LED_DISABLE = RM2M_GPIO_LOW, // By setting the GPIO to "low" the LED is turned off
You can find examples of this in the “M2 BASE STARTER BASIC EXAMPLES COLLECTION” in the Samples area of the rapidM2M Studio