#include <hal/gpio_ll.h>
//Mask with GPIOs 0, 2 and 4
//If we invert this mask with "~" we will have 0b01010
//and we now have GPIOs 1 and 3 selected
unsigned long mask = 0b000000000111111111;
unsigned int value = 0x1;

uint32_t t0;
uint32_t t1;
uint32_t delta_t;
bool shiftDirection = 0;
void setup()
{
    Serial.begin(115200);
    //GPIO configuration
    gpio_config_t io_conf;
 
    // We put it as OUTPUT
    io_conf.mode = GPIO_MODE_OUTPUT;
 
    //Definition of the gpios that are part of this configuration
    //From right to left, those with 1 are part of the configuration
    //In this case GPIOs 0, 1, 2, 3 and 4
    io_conf.pin_bit_mask = 0b111111000000110100;
 
    //Apply the configuration
    gpio_config(&io_conf);
}
void loop()
{
    
    //Invert the mask bits
    //Those that were selected are deselected and vice versa
    //bitWrite(mask,15,bitRead(value,0));
    t0 = micros();

    mask = ((value & 0x01) << 15)|((value & 2)<<1)|((value & 4) << 2)|((value & 8) << 13)|
           ((value & 0x10) << 13)|((value & 0x20))|((value & 0x40) << 8)|((value & 0x80) << 5)|((value & 0x100) << 5);
    
    //Serial.println(mask,BIN);
    //Bit mask with the pins that will be "set" as active
    GPIO.out_w1ts = mask;
    //Bit mask with the pins that will be deactivated (clear)
    GPIO.out_w1tc = ~mask;
    delayMicroseconds(10);
    t1 = micros();
    delta_t = t1 - t0;
    printf( "Delta = %u\n", delta_t ); // this prints around 51 on my system.
 
    //Delay 1 second
    delay(400);
    if(shiftDirection == 0 ){
      if(value < 256) value= value <<1;
      else{
        shiftDirection = 1;
        value = value >> 1;
      }
    }
    else{
      if(value > 1) value = value >> 1;
      else{
        shiftDirection = 0;
        value = value << 1;
      }
    }
    
}