Switching GPIO pin between input and output mode

Hi,

Could help me please?

What I need?

1) set GPIO pin as input with internal pulldown and set IRQ for Rising Edge.

In .overlay I add my pin like that:

userpin{
        compatible = "gpio-keys";
        nslpin: nsl_pin{
            gpios = <&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
			label = "No sleep line";
        };
    };

 Then in code I set pin as INPUT and enabled IRQ

if(gpio_pin_configure_dt(&nslPin, GPIO_INPUT) < 0) while(1);
if(gpio_pin_interrupt_configure_dt(&nslPin, GPIO_INT_EDGE_RISING) != 0) while(1);

2) In code I need sometimes to set this pin as output and set it to logical HIGH (3,3V)

So in code I disabled IRQ on this pin, set it like OUTPUT and set logical HIGH

if(gpio_pin_interrupt_configure_dt(&nslPin, GPIO_INT_DISABLE) != 0) while(1);
if(gpio_pin_configure_dt(&nslPin, GPIO_OUTPUT) < 0) while(1);	
gpio_pin_set_dt(&nslPin,1);

3) Later on I need to set it again as in step 1 (set GPIO pin as input with internal pulldown and set IRQ for Rising Edge.)
Unfortunatelly it does not work I can always see (in the scope) the pin is in logical HIGH - what is wrong with my code?
Thank you for any help. Jan.
Parents Reply Children
No Data
Related