RasPi GPIO driver
Pierre Ficheux
pierre.ficheux at openwide.fr
Mon Oct 21 05:30:54 UTC 2013
Hi,
The driver should work with classic API though I do prefer POSIX :)
You can also use macros (INP_GPIO, ...) in your code, that's what I did with the led (GPIO #16) before writing the driver.
regards
----- Mail original -----
> De: "Alan Cudmore" <alan.cudmore at gmail.com>
> À: "sarraciro" <sarraciro at yahoo.it>, rtems-users at rtems.org
> Envoyé: Lundi 21 Octobre 2013 00:43:56
> Objet: Re: RasPi GPIO driver
>
> We can certainly read and write GPIO pins without POSIX support. I
> think
> Pierre was trying to create a standard driver for GPIO that might be
> expanded into a generic GPIO interface for all BSPs.
>
> The code in Pierre's driver has the basic macros and defines to do
> the
> GPIO reads and writes. It could be used without the driver.
>
> But this is a good time to bring this up:
> What should the Raspberry Pi GPIO support look like in the BSP?
> 1. Simple direct reads and writes through macros or functions?
> 2. A driver such as Pierre's
> 3. Or a combination of both: Supply the driver and defines/macros and
> allow the user to decide what to use?
>
> Alan
>
>
>
> On 10/20/2013 6:19 PM, sarraciro wrote:
> > 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
> >
> >
> > _______________________________________________
> > 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
>
--
Pierre FICHEUX -/- CTO OW/OWI, France -\- pierre.ficheux at openwide.fr
http://ingenierie.openwide.fr
http://www.linuxembedded.fr
I would love to change the world, but they won't give me the source code
More information about the users
mailing list