Hi,
I used the following device tree overlay to configure "GPIO1_16" (which is 
P9-15) to Mode-7 (=GPIO):
//file name: BB-gpio-set-00A0.dts

/dts-v1/;
/plugin/;


/ {
        compatible = "ti,beaglebone", "ti,beaglebone-black";


        /* identification */
        part-number = "BB-LED";
        version = "00A0";


        /* state the resources this cape uses */
        exclusive-use =
                /* the pin header uses */
                "P9.15",        /* GPIO1_16 */
                /* the hardware ip uses */
                "GPIO1_16";


        fragment@0 {
                target = <&am33xx_pinmux>;
                __overlay__ {
                        bb_GPIO1_16_pins: pinmux_bb_GPIO1_16_pins {
                                pinctrl-single,pins = <
                                        0x40 0x07 /* P9.15 OUTPUT  */
                                >;
                        };
                };
        };
};


Then, I compiled it with dtc, copied the dtbo file to /lib/firmware/,
and performed *echo BB-gpio-set* *> slots*

Now, I ran the following Code to turn on GPIO1_16, but the code does not 
turn it ON.

*Why it that please?*


#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>


#define GPIO1_BASE      0x4804C000
#define GPIO1_END       0x4804CFFF
#define GPIO1_SIZE      GPIO1_END-GPIO1_BASE
#define GPIO_OE         0x0134
#define GPIO_DATAOUT    0x013C
#define GPIO_USERBUTTON 7
#define GPIO1_16       16 //GPIO1_16
#define GPIO_SETDATAOUT 0x194
#define GPIO_CLEARDATAOUT 0x190


int main(int argc, char** argv)
{
        volatile unsigned int *reg, *reg_base, *reg_clr;
        unsigned int value;
        int fd = open("/dev/mem", O_RDWR);


        /* LED0 Setup and Turn-on */

        //Set GPIO_OE to Output
        reg_base =(volatile unsigned int*) mmap(0,GPIO1_SIZE, PROT_READ 
|PROT_WRITE
, MAP_SHARED, fd, GPIO1_BASE);
        reg = (volatile unsigned int*)(reg_base + GPIO_OE);
        value = *(reg);
        value &= ~(1 << GPIO1_16);
        *(reg) = value;

        //set GPIO_SETDATAOUT to turn LED on
        reg = (volatile unsigned int*)(reg_base + GPIO_SETDATAOUT);
        value = *(reg);
        value |= (1 << GPIO1_16);
        *(reg) = value;


        return 0;
}


-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to