Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - GPIO on Xilinx Virtex4 board: (2 Items)
   
GPIO on Xilinx Virtex4 board  
Anyone has worked with GPIO on Xilinx board? I just try to read some push buttons and turn on some leds on ML405. But it
 does not work.
Here is my simple code:

//=========================================
void *leds_thread()
{
	uintptr_t led_p;
	uintptr_t bttn_p;	
	uint8_t	bttn_in;
	uint8_t led_out = 3;
	if(ThreadCtl(_NTO_TCTL_IO,0) == -1) printf("WRONG PERMISSION\n");
	led_p = mmap_device_io(0x01, LEDS_4BIT);
	if (led_p == MAP_DEVICE_FAILED)
    {
      printf ("Error %s trying to map LEDS memory\n", strerror(errno));
      return FALSE;
    } 

	bttn_p = mmap_device_io(0x01, 0x40040000);//BTTNS);
	if (bttn_p == MAP_DEVICE_FAILED)
    {
      printf ("Error %s trying to map BTTNS memory\n", strerror(errno));
      return FALSE;
    } 

	while (1)
	{
		// Turn on 2 lowest LEDs (Active high)	
		bttn_in = in8(bttn_p);
		out8(led_p, led_out);
		printf("bttn_in = %d\n", bttn_in);
		printf("led_out = %d\n\n", led_out);
		sleep(1);
	}
}


int main(int argc, char *argv[]) {
	
	printf("Creating GPIO control thread.\n");
	pthread_create(NULL,NULL,&leds_thread,NULL);
	printf("Thread was created.\n");
	
	pause();
	
	return EXIT_SUCCESS;
}
//=====================================

I got nothing, leds are not turned on, push buttons do NOT work.
Any ideas? Thank very much.

Hung
Re: GPIO on Xilinx Virtex4 board  
Thanks all, I got it running now. I need to set data direction first.