Note that there are some explanatory texts on larger screens.

plurals
  1. POHandle GPIO in User Space ARM9 Embedded Linux AM1808
    primarykey
    data
    text
    <p>I have to interface my GSM module with the AM1808 based on ARM9.</p> <p>I have assigned all the GPIO pins to the Da850.c as well as mux.h files. I successfully created a uImage and inserted that image in my flash.</p> <p>I need to handle some of that GPIO from User application.</p> <p>I know that we can handle the GPIO from the Kerel space but i need to handle from the user space.</p> <p>As for example I have assigned a GPIO for power key to GSM module. I need to change the pin means (HIGH or LOW) through application.</p> <p>Ok i have written a following code to access it from the User Space,</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;time.h&gt; #include &lt;signal.h&gt; #include &lt;fcntl.h&gt; #include &lt;sys/mman.h&gt; #include &lt;stdlib.h&gt; #include &lt;unistd.h&gt; #include "GSMpwr.h" #define BS_GSM_PWR_REGISTER 0x01E26014 #define BS_DCDS_MASK 0x00000004 int fd; // Memory device descriptor unsigned long *pPWR; unsigned short GetGSMpwr(void) { #if defined __HOST_ARM unsigned long dcd_value = *pPWR; return (pwr_value &gt;&gt; 7) &amp; 0x01; #endif } void InitializeGSMpwr(void) { #if defined __HOST_ARM int page_size = getpagesize(); unsigned int MAP_addr; unsigned int reg_addr; unsigned char *pTemp; // Pointer to GSMpwr register /* * Open memory and get pointer to GSMpwr register in the FPGA */ if((fd = open("/dev/mem", O_RDWR | O_SYNC)) &lt; 0) { printf("failed to open /dev/mem"); return; } else { MAP_addr = (BS_GSM_PWR_REGISTER &amp; ~(page_size - 1)); pTemp = (unsigned char *)mmap(NULL, page_size,(PROT_READ | PROT_WRITE),MAP_SHARED,fd,MAP_addr); if((pTemp == MAP_FAILED) || (pTemp == NULL)) { printf("failed to map /dev/mem"); return; } else { printf(“Memory Mapped at Address %p. \n”,pTemp); } virt_addr = map_base + (control &amp; MAP_MASK); reg_addr = (BS_GSM_PWR_REGISTER &amp; (page_size - 1)); pPWR = (unsigned long*)(pTemp + reg_addr); printf("GSM PWR PIN mapped in Application\n"); } </code></pre> <p>I can only read that pin through this code, Now i want to use that pin as an output and want to go high and low with the time interval of 3sec.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload