rt_misc_get_io_region()
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 think that is a topic that is interessting for a lot of people.
Regards
Niklaus Burren
Am Dienstag, 12. Dezember 2006 08:38 schrieb Niklaus Burren:
Quoted 11 lines
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 likerequest_mem_region()?After the call of the
rt_misc_get_io_region()fuction it is also necessary to call theioremap()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;
}Quoted 6 lines
I think that is a topic that is interessting for a lot of people.
Regards
Niklaus Burren
Best regards from another Swiss Chlaus.
Signature · 3 lines
Niklaus Giger Wieshoschet 6 CH-8753 Mollis