Hello! We are using the TI's DaVinci DM6446 DVEVM. We just want to use
GPIO54 i.e GPIOV33_0 as output. We tried code given below, but not working.
Can you tell us how to program any pin of GPIO?
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <unistd.h>
#include <stropts.h>
#include <errno.h>
extern int errno;
uint32_t *memregs32_dir;
uint32_t *memregs32_set;
unsigned short *memregs16;
int memfd;
#define DIR23 0x01c67038
#define SET_DATA23 0x01c67040
void *trymmap (void *start, size_t length, int prot, int flags, int fd,
off_t offset)
{
char *p;
int aa;
printf ("mmap(%X, %X, %X, %X, %X, %X) ... ", (uint32_t)start,
length, prot, flags, fd, (unsigned int)offset);
p = mmap (start, length, prot, flags, fd, offset);
if(p == -1) {
printf("-1 returned\n");
}
else if (p == (char *)0xFFFFFFFF)
{
aa = errno;
printf ("failed. errno = %d\n", aa);
}
else {
printf ("OK! (%X)\n", (unsigned int)p);
}
return p;
}
unsigned char initphys (void)
{
memfd = open("/dev/mem", O_RDWR);
if (memfd == -1)
{
printf ("Open failed\n");
return 0;
}
printf ("/dev/mem opened successfully - fd = %d\n", memfd);
size_t length = 4;
memregs32_dir = trymmap((void*)DIR23, 1, PROT_READ|PROT_WRITE,
MAP_SHARED, memfd, 0);
//memregs32_dir = trymmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED,
memfd, (void*)DIR23);
if (memregs32_dir == (uint32_t *)0xFFFFFFFF) return 0;
memregs32_set = trymmap((void*)SET_DATA23, 1, PROT_READ|PROT_WRITE,
MAP_SHARED, memfd, 0);
//memregs32_set = trymmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED,
memfd, (void*)SET_DATA23);
if (memregs32_set == (uint32_t *)0xFFFFFFFF) return 0;
//memregs16 = (unsigned short *)memregs32;
return 1;
}
void closephys (void)
{
close (memfd);
}
int main(void)
{
int i;
if (!initphys()) return 0;
*memregs32_dir = 0x00000000;
//*memregs32_set = 0;
//*memregs32_set = 0x00400000; //0x00000000;
*memregs32_set = 0x00400000;
printf("DIR: %d\n", *memregs32_dir);
printf("SET: %d\n", *memregs32_set);
closephys();
printf("test complete\n");
return 0;
}
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source