RasPi GPIO driver

sarraciro sarraciro at yahoo.it
Sun Oct 20 22:19:05 UTC 2013


Hi Alan,
yes I've tested it too and work properly... 
for compile using your rki-project makefile (as starting point) I had to
add the POSIX support in the makefile...(RTEMS_HAS_POSIX_API = yes after
paths for RTEMS tools and RTEMS BSP).
But ... it use posix support ... There is another way?? like ChibiOS ???

I've read an article about minimum constrains to compile C code in bare
metal OS ...
I think the solution is something like this:

/* mmio.h - access to MMIO registers */
 
#ifndef MMIO_H
#define MMIO_H
 
#include <stdint.h>
 
// write to MMIO register
static inline void mmio_write(uint32_t reg, uint32_t data) {
    uint32_t *ptr = (uint32_t*)reg;
    asm volatile("str %[data], [%[reg]]"
	     : : [reg]"r"(ptr), [data]"r"(data));
}
 
// read from MMIO register
static inline uint32_t mmio_read(uint32_t reg) {
    uint32_t *ptr = (uint32_t*)reg;
    uint32_t data;
    asm volatile("ldr %[data], [%[reg]]"
		 : [data]"=r"(data) : [reg]"r"(ptr));
    return data;
}
 
#endif // #ifndef MMIO_H

anyone can confirm or disagree with this?
The ": :" or ":" are not C operators true?? sounds like C++?

--
RC (popovich)


Il giorno dom, 20/10/2013 alle 18.05 -0400, Alan Cudmore ha scritto:
> There is an RTEMS Rpi GPIO driver here:
> https://github.com/pficheux/raspberry_pi/tree/master/RTEMS/gpio_driver
> I have tested this, and it works.
> 
> Simon, I will definitely check out your driver when you submit it.
> 
> Alan
> 
> On 10/20/2013 5:57 PM, sarraciro wrote:
> > Thank you Simon for your prompt reply... sure that I'm interested!
> > I'll wait for the patch! but also I'm trying to learn (understand!?!)
> > how to write  a simple driver for RTEMS... for other future use of a
> > custom drivers.
> > regards
> >
> > --
> > RC
> >   
> > Il giorno dom, 20/10/2013 alle 21.32 +0000, williamssimonp at gmail.com ha
> > scritto:
> >> I am testing one as we speak, if you’re interested.  Should be ready
> >> to submit the patch about mid-week.
> >>   
> >> Regards
> >>   
> >> Simon
> >>   
> >> Sent from Windows Mail
> >>   
> >> From: sarraciro
> >> Sent: ‎Sunday‎, ‎20‎ ‎October‎ ‎2013 ‎22‎:‎28
> >> To: rtems-users at rtems.org
> >>   
> >> Hi all,
> >> I'm trying to write a simple driver to use raspberry pi gpio.
> >> I've found some examples for the POSIX approach (& I tried it with
> >> success) but I'm more interesting to pure C solution.
> >> I read the RTEMS's documentation but it's too general (for my
> >> know-how) ... and  I've read the BCM2835 datasheet for register
> >> addresses ...  I understood the relevance to use the pointers for
> >> access
> >> to the memory...but I'm stucking until now I don't understand how to
> >> move on...
> >> Any suggestions or lectures for understand how to complete the task?
> >> thank you
> >> rc
> >>
> >> _______________________________________________
> >> rtems-users mailing list
> >> rtems-users at rtems.org
> >> http://www.rtems.org/mailman/listinfo/rtems-users
> >>
> >
> >
> > _______________________________________________
> > rtems-users mailing list
> > rtems-users at rtems.org
> > http://www.rtems.org/mailman/listinfo/rtems-users
> 






More information about the users mailing list