Now working.  Just operator error.  Plugged into the wrong header.

I will share what I have:

overlay file  Modified from BB-GPIOHELP-00A0.dts for just P9.12.

*

* Copyright (C) 2013 Pantelis Antoniou <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;

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

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

        /* state the resources this cape uses */
        exclusive-use =
                /* the pin header uses */
                "P9.12",        /* gpio */
                /* the hardware IP uses */
                "gpio1_28";

        fragment@0 {
                target = <&am33xx_pinmux>;
                __overlay__ {
                        gpio_helper_pins: pinmux_gpio_helper_pins {
                                pinctrl-single,pins = <
                                        0x078 0x07      /* P9.12 GPIO1_28:  
MODE7 | OUTPUT */
                                >;
                        };
                };      
        };

        fragment@2 {
                target = <&ocp>;
                __overlay__ {

                        gpio_helper {
                                compatible = "gpio-of-helper";
                                status = "okay";
                                pinctrl-names = "default";
                                pinctrl-0 = <&gpio_helper_pins>;

                                /* declare your gpios */
                                test_led {
                                        gpio-name = "test_led";
                                        gpio = <&gpio2 12 0x00>;        /* 
gpio2 is gpio1 */
                                        output;
                                };

                        };
                };
        };
};


===========================================
next the uEnv.txt file:

optargs=quiet drm.debug=7 capemgr.enable_partno=BB-GPIOP912


===========================================

next the c program:  added the sleep(1)& printf in between toggles.
this program was written by:  Chirag Nagpal


#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h> 
#include "beaglebone_gpio.h"

int main(int argc, char *argv[]) {
    volatile void *gpio_addr = NULL;
    volatile unsigned int *gpio_oe_addr = NULL;
    volatile unsigned int *gpio_setdataout_addr = NULL;
    volatile unsigned int *gpio_cleardataout_addr = NULL;
    unsigned int reg;
  
  int fd = open("/dev/mem", O_RDWR);

    printf("Mapping %X - %X (size: %X)\n", GPIO1_START_ADDR, 
GPIO1_END_ADDR, GPIO1_SIZE);

    gpio_addr = mmap(0, GPIO1_SIZE, PROT_READ | PROT_WRITE, 
MAP_SHARED, fd, GPIO1_START_ADDR);

    gpio_oe_addr = gpio_addr + GPIO_OE;
    gpio_setdataout_addr = gpio_addr + GPIO_SETDATAOUT;
    gpio_cleardataout_addr = gpio_addr + GPIO_CLEARDATAOUT;

    if(gpio_addr == MAP_FAILED) {
        printf("Unable to map GPIO\n");
        exit(1);
    }
    printf("GPIO mapped to %p\n", gpio_addr);
    printf("GPIO OE mapped to %p\n", gpio_oe_addr);
    printf("GPIO SETDATAOUTADDR mapped to %p\n", 
gpio_setdataout_addr);
    printf("GPIO CLEARDATAOUT mapped to %p\n", 
gpio_cleardataout_addr);

    reg = *gpio_oe_addr;
    printf("GPIO1 configuration: %X\n", reg);
    reg = reg & (0xFFFFFFFF - PIN);
    *gpio_oe_addr = reg;
    printf("GPIO1 configuration: %X\n", reg);

    printf("Start toggling PIN \n");
    while(1) {
        
        *gpio_setdataout_addr= PIN;
        printf("on\n");
        sleep(1);
        *gpio_cleardataout_addr = PIN;
        printf("off\n");
        sleep(1);
      }

    close(fd);
    return 0;
}



On Monday, June 16, 2014 8:36:35 PM UTC+8, [email protected] wrote:
>
> I cannot get this mmap to work.  I think you left out a few steps.  For 
> example what is the overlay you used for the DT?
>
>
>
> On Friday, December 6, 2013 7:48:18 AM UTC+8, [email protected] wrote:
>>
>> check this out:
>> http://chiragnagpal.github.io/examples.html
>> I have explained how to use /dev/mmap in beaglebone black
>>
>

-- 
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/d/optout.

Reply via email to