<div class="gmail_quote"><div class="gmail_quote"><div>
Hi,<br><br> I am using S3C2440+7" touchscreen, i need to toggle(0 or 1) the EINT pins in the GPIO connector ( say GPIO11 & GPIO12) and i have made an program to toggle the pins but i run my program the pins will be always high(1) by default and if i change the programs to GPIO connector (say GPIO29, 30, 31, 32 which has been connected to led's in the board) it will toggle and work fine, Below is my program<div>
<div></div><div class="h5"><br>
<br><b style="color: rgb(0, 0, 153);">#include <stdio.h><br>#include <stdlib.h><br>#include <fcntl.h><br>#include <sys/mman.h><br><br> <br>#define MAP_SIZE 4096UL /* the size of one page of virtual memory */<br>
#define MAP_MASK (MAP_SIZE - 1) /* mask used for the one page of virtual memory */<br><br>#define GPIOG_CON 0x56000060 /* physical address of the GPIO G control register */<br>#define GPIOG_DAT 0x56000064 /* physical address of the GPIO G data register */<br>
<br>int main(int argc, char **argv) {<br> int fd,count;<br> void *map_base, *virt_addr; <br> unsigned long read_result, writeval;<br><br> if(argc < 2) {<br> fprintf(stderr, "\nUsage:\t%s { seconds }\n"<br>
"\tseconds : number of seconds to blink\n\n",<br> argv[0]);<br> exit(1);<br> }<br><br> count = strtoul(argv[1], 0, 0);<br><br> /* open the memory device file descriptor */<br> if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)<br>
return -1;<br> <br> /* Map one page */<br> map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, GPIOG_CON & ~MAP_MASK);<br> if(map_base == (void *) -1)<br> return -1;<br> <br> /* set the virtual memory address to the GPIO G control register */<br>
virt_addr = map_base + (GPIOG_CON & MAP_MASK);<br><br> /* read the current value for GPIO G control register */<br> read_result = *((unsigned long *) virt_addr);<br><br> writeval = read_result;<br> // writeval &= ~0x03; /* mask off the first two bits */<br>
writeval |= 0x1400; /* set gpio G5 and G6 to output with value of 0x01 (output)*/ <br> printf("writing data finished\n");<br> <br> *((unsigned long *) virt_addr) = writeval;<br><br><br> /* change virtual memory address to GPIO G data register */<br>
virt_addr = map_base + (GPIOG_DAT & MAP_MASK);<br><br> for ( count ; count > 0 ; count--) { <br> printf("count=%d\n",count);<br> /* read the current value for GPIO G data register */<br> read_result = *((unsigned long *) virt_addr);<br>
writeval = read_result;<br> <br> if ( (read_result&(1<<5)) )<br> { writeval &= ~(1<<5); <br> writeval |=(1<<6);<br> }else<br> {<br> writeval &= ~(1<<6);<br>
writeval |= (1<<5); <br> }<br> <br> *((unsigned long *) virt_addr) = writeval;<br> sleep(1);<br><br> }<br><br><br> /* read the current value for GPIO G control register */<br>
read_result = *((unsigned long *) virt_addr);<br>
<br> <br> writeval = read_result;<br> writeval |= (1<<0); <br><br> <br> *((unsigned long *) virt_addr) = writeval;<br><br> /* unmap the virtual memory before exiting the program */<br> if(munmap(map_base, MAP_SIZE) == -1)<br>
return -1;<br> <br> close(fd);<br> return 0;<br><br>}</b><br><br></div></div>How to toggle the EINT pins in the GPIO connector any suggestions would be advantage.<br></div><br><br>
</div><br>Thanks & Regards,<br><font color="#888888">SANDEEP G R, <br><br></font></div><br>