Hell everybody,
I've got problem with driving GPIO pin P9_30 with BeagleBone Black, it is 
described as gpio3[16]. When I run my code, i don't have any effect. Can 
anybody tell me what can be wrong?
main.c:

> #include <stdio.h>
> #include <stdlib.h>
> #include <stdint.h>
> #include <sys/mman.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include "regs.h"
> typedef uint32_t u32_t;
> int main(void)
> {
> volatile u32_t *reg = NULL;
> volatile u32_t *gpio3 = NULL;
> volatile u32_t *pin = NULL;
> volatile u32_t *set = NULL;
> volatile u32_t *clear = NULL;
> volatile u32_t *oe = NULL;
> int fd = open("/dev/mem", O_RDWR | O_SYNC);
> if(-1 != fd)
> {
> printf("Opening file /dev/mem succeeded!\n");
> reg = mmap(NULL, CONTROL_MODULE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, 
> fd, CONTROL_MODULE_START);
> if(MAP_FAILED != reg)
> {
> printf("Mapping CONTROL MODULE succeeded!\nAddress: %p, Size: %d\n", reg, 
> CONTROL_MODULE_SIZE);
> pin = reg + GPIO3_16;
> *pin &= ~(1 << 6 | 1 << 5 | 1 << 3); // Fast rate, receiver disabled, 
> pull-up enabled
> *pin |= (1 << 4 | 1 << 2 | 1 << 1 | 1 << 0); // Pull-up selected, 
> gpio3[16] enabled
> printf("Pin: 0x%X\n", *pin);
> gpio3 = mmap(NULL, GPIO3_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 
> GPIO3_START);
> if(MAP_FAILED != gpio3)
> {
> printf("Mapping GPIO3 succeeded!\nAddress: %p, Size: %d\n", gpio3, 
> GPIO3_SIZE);
> set = gpio3 + GPIO_SETDATAOUT;
> clear = gpio3 + GPIO_CLEARDATAOUT;
> oe = gpio3 + GPIO_OE;// enabling pin as output
> *oe &= ~(1 << 16);
> printf("GPIO3_OE: 0x%X\n", *oe);
> *set = (1 << 16);//setting 1 to output
> }
> else
> {
> printf("Mapping GPIO3 failed!\n");
> }
> }
> else
> {
> printf("Mapping CONTROL MODULE failed!\n");
> }
> }
> else
> {
> printf("Opening file /dev/mem failed!\n");
> }
> return EXIT_SUCCESS;
> }

regs.h:

#ifndef REGS_H
#define REGS_H
#define CONTROL_MODULE_START (0x44E10000)
#define CONTROL_MODULE_END (0x44E11FFF)
#define CONTROL_MODULE_SIZE (CONTROL_MODULE_END - CONTROL_MODULE_START)
#define GPIO_OE (0x134)
#define GPIO_DATAOUT (0x13C)
#define GPIO_CLEARDATAOUT (0x190)
#define GPIO_SETDATAOUT (0x194)
#define GPIO3_START (0x481AE000)
#define GPIO3_END (0x481AEFFF)
#define GPIO3_SIZE (GPIO3_END - GPIO3_START)
#define GPIO3_16 (0x998)
#endif



-- 
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