There is an example given in Device::BCM2835

# Low level register access Device::BCM2835::peri_read(&Device::BCM2835::BCM2835_GPIO_BASE + &De +vice::BCM2835::BCM2835_GPFSEL1); Device::BCM2835::peri_write(&Device::BCM2835::BCM2835_GPIO_BASE + &D +evice::BCM2835::BCM2835_GPFSEL2, 0xdeadbeef) Device::BCM2835::peri_set_bits(&Device::BCM2835::BCM2835_GPIO_BASE + + &Device::BCM2835::BCM2835_GPFSEL3, 0xdeadbeef, 0x1f);

Note the GPIO_BASE. If these constants do not work either, you can resort to a little debugging. Insert print statements in both C and perl versions and verify that the constants are the same.

Your for loop may be simplified as:

Device::BCM2835::gpio_fsel($_, &Device::BCM2835::BCM2835_GPIO_FSEL_OUT +P) for @pins;

Another approach, that might prove superior, is to go with Inline::C. You can embed C code in your perl to do the heavy lifting. Pack your i/o sequences (address/value pairs) in vectors on the perl side, to be passed to your C function as necessary.


In reply to Re: Device::BCM2835, hardware access on a pi, SIGSEGV by Anonymous Monk
in thread Device::BCM2835, hardware access on a pi, SIGSEGV by Peterpion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.