All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklaus Giger <niklaus.giger@domain.hid>
To: xenomai@xenomai.org
Subject: Re: [Xenomai-help] rt_misc_get_io_region()
Date: Tue, 12 Dec 2006 20:16:19 +0100	[thread overview]
Message-ID: <200612122016.19683.niklaus.giger@domain.hid> (raw)
In-Reply-To: <457E5C81.3060006@domain.hid>

Am Dienstag, 12. Dezember 2006 08:38 schrieb Niklaus Burren:
> We want to write a Xenomai application that can access the
> GPIO pins of our ARM-Prozessor (PXA-270). To get the memory
> region I found the function rt_misc_get_io_region(). Unfortunately
> there is no discription of this function in the API documentation.
> Does this function work like request_mem_region()?
>
> After the call of the rt_misc_get_io_region() fuction it is also
> necessary to call the ioremap() function?
>
> Please can you give me a little example, how you can map and access
> memory in Xenomai?
I don't think that mapping memory very different for RT tasks. 

Here are the snippets from my code which I used (today!) to turn on and off 
LEDs connected to the GPIO-pins of my PPC405 based board.

#include <sys/mman.h>

#define MAP_SIZE 4096UL
void  *mapDirectIoRegister(char *addr, int nSize)
{
    void *map_base;
    off_t target = ((unsigned int) addr) & ~MAP_MASK;
    int fd;

    if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
        printf("/dev/mem could not be opened.\n");
        exit(1);
    }

  // Map one page
    map_base = mmap((void *)target, nSize, PROT_READ | PROT_WRITE, MAP_SHARED,
		 fd, target);
   <.. error handling>
   return map_base;
}
static uint32 *ledRegister;

<init proc>
    ledRegister = (uint32 *)mapDirectIoRegister((char *)GPIO_OR, 4);
    ledRegister[1] = 0x7ffe0000; /* Three State Control  (GPIO_TCR) */

void   sysLedSet(uint8 value)
{
    ledRegister[0] =  ((uint32) value)) << 23;
}

>
> I think that is a topic that is interessting for a lot of people.
>
> Regards
>
> Niklaus Burren
Best regards from another Swiss Chlaus.

-- 
Niklaus Giger
Wieshoschet 6
CH-8753 Mollis


      reply	other threads:[~2006-12-12 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-12  7:38 [Xenomai-help] rt_misc_get_io_region() Niklaus Burren
2006-12-12 19:16 ` Niklaus Giger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200612122016.19683.niklaus.giger@domain.hid \
    --to=niklaus.giger@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.