This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I am not able to configure pins as an input pin using the Zephyr OS API

Hi Everyone,

Pardon me if i write some illogical stuff. Complete beginner to this microcontroller. 

I started using nrf52832 with Zephyr OS . I was trying to configure the pin as a input pin and blink the LED on the input from the Switch pin.

But unfortunately, I am not able to do it.  I am not able to configure the Switch pin as a input pin.

Here is code that i was using

#include <zephyr.h>
#include <device.h>
#include <gpio.h>
#include <board.h>

#include <zephyr.h>
#include <device.h>
#include <gpio.h>
#include <board.h>

#define SW3_PORT SW3_GPIO_NAME

#define SW3_PIN SW3_GPIO_PIN

#define LED_PORT    LED2_GPIO_PORT
#define LED0    17

int main(void)

{
	
	uint32_t *data=0;
	
	struct device *dev1;
	dev1 = device_get_binding(LED_PORT);
	gpio_pin_configure(dev1, LED0, GPIO_DIR_OUT);
	
	struct device *dev;
	dev = device_get_binding(SW3_PORT);
	gpio_pin_configure(dev, SW3_PIN, GPIO_DIR_IN);
	gpio_pin_write(dev, LED0, 1);
 	while(1)
	{
	
	gpio_pin_read(dev,SW3_PIN,data);
	
 	//k_sleep(200);
	gpio_pin_write(dev1, LED0, *data);
	/*
	if(data!=0)
	{
		gpio_pin_write(dev, LED0, 0);
		
	}
	else
	{
		gpio_pin_write(dev, LED0, 1);
	}
} 
*/

}
} 

Parents Reply Children
No Data
Related