Wasn't able to create a handle on Freedom Studio


(Adharsh s) #1

Hello !

I wasn’t able to create a handle using the following code:
Any help is appreciated. Thanks in advance

code:

#include <stdio.h>

#include <unistd.h>
#include <time.h>
#include <metal/gpio.h>

int main (void)
{

struct metal_gpio *gpio_device;


gpio_device = metal_gpio_get_device(5);
if (gpio_device == NULL){
		printf("NOT WORKING");     // output shows not working always ?
                                                                   // is there a syntax error ?
	}

 //13 is the pin
metal_gpio_disable_input(gpio_device, 13);
metal_gpio_enable_output(gpio_device, 13);
printf("metal_gpio_set_pin \n");

unsigned int d0 = 0;
while (1)
{
	metal_gpio_set_pin(gpio_device, 13, 1); //this line does absolutely nothing
	//sleep (1000);
	delay(10000); //10000 = 1 second
	metal_gpio_set_pin(gpio_device, 13, 0); //this line does absolutely nothing
	delay(1000);
	++d0;
	printf("debug: %u \n", d0);
}



return 0;

}