June 12, 2010

Embedded Linux Picture Frame!

Filed under: Embedded Linux — Tags: , , , , , , — admin @ 10:53 pm

Hi,

In this article, I will talk about how to control IO ports using Embedded Linux platforms.

The platform which is used in this project is a edb9302 compliant development board. It has 16 MB Intel strata flash and 32 MB SD RAM, gpio connection in order to communicate custom design interfaces, for information about the development board, can be looked at this link;

http://www.cirrus.com/en/products/pro/detail/P1066.html

Briefly in this project , i have connected a elt240320atp LCD screen to the embedded Linux development board with a parallel gpio interface.

An interface software is written, in order to create communication between the embedded Linux development board and the elt240320atp LCD screen.

Let’s take a look interface software.

The program is designed to communicate with lcd screen can be split into two parts, gpio controller and elt240320atp lcd screen controller.

All right, how to open GPIO interface without using a device driver in a Embedded Linux platform?
Answer, using /dev/mem device.

/dev/mem device is a king of character device is used to access to physical memory via generic file manipulation system calls, for example; open, read, write, seek, close, etc.

As can be seen in the code snipe,

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	iofd = open("/dev/mem", O_RDWR | O_SYNC);
	if (iofd == -1) {
		fprintf(stderr ,"\n%s\n", "Cannot open /dev/mem device!");
		return(errno);
	}
 
	ptrregisterbase = (unsigned char *) mmap(0, getpagesize(), PROT_READ|PROT_WRITE, \
					MAP_SHARED, iofd, 0x80840000 );
 
	ptrconfigbase   = (unsigned char *) mmap(0, getpagesize(), PROT_READ|PROT_WRITE, \
					MAP_SHARED, iofd, 0x80930000 );
 
	porta_dr  = ptrregisterbase+0x00;/*data register*/
	porta_ddr = ptrregisterbase+0x10;/*data direction register*/
 
	portb_dr  = ptrregisterbase+0x04;
	portb_ddr = ptrregisterbase+0x14;

In the code snipe above; main.c:line 64, /dev/mem device is opened as a character device. In case of cache mechanism of the MMU, O_SYNC is used in order not the MMU to cache the written data.

In the line 70 and 73, mmap function is used in order to map the file descriptor which is obtained by open function to the pointer to a integer.

EP9302-ELT240320ATP

figure.1: EP9302 - ELT240320ATP connection

As can be seen in the figure.1 sbc and lcd connected with each other.

ELT240320ATP

figure.2: ELT240320ATP, 320x240 TFT LCD

A picture is printed on the screen of the lcd, top left text is also printed as courier font.

Whole project code and pictures can be downloaded here.

Any kind of feedback or question is accepted gratefully.

Best Regards.

bolatdinc at gmail.com

Powered by WordPress