Code: Select all
gpio_config_t io_output_control;
io_output_control.pin_bit_mask = (1 << PIN_OUT_0) | (1 << PIN_OUT_1) | (1 << PIN_OUT_2) | (1 << PIN_OUT_3);
io_output_control.mode = GPIO_MODE_OUTPUT;
gpio_config(&io_output_control);
GPIO.out_w1ts = output_pin_bitmask_value;
GPIO.out_w1tc = ~output_pin_bitmask_value;
Code: Select all
gpio_config_t io_input_control;
io_input_control.pin_bit_mask = (1 << PIN_IN_0) | (1 << PIN_IN_1) | (1 << PIN_IN_2) | (1 << PIN_IN_3);
io_input_control.mode = GPIO_MODE_INPUT;
gpio_config(&io_input_control);
input_pin_bitmask_value = GPIO.in;
My final implementation would be like this, set some I/O state and read the input pin, in an infinite loop:
Code: Select all
loop() {
/* preparing output bit mask */
/* fast GPIO write & read operation */
GPIO.out_w1ts = output_pin_bitmask_value;
GPIO.out_w1tc = ~output_pin_bitmask_value;
input_pin_bitmask_value = GPIO.in;
/* some other operation */
}