ts-7000
[Top] [All Lists]

[ts-7000] Re: How to access IO pins????

To:
Subject: [ts-7000] Re: How to access IO pins????
From: "gpimentel074" <>
Date: Tue, 26 Aug 2008 16:03:43 -0000
OK.

I made some tests after posted the message and now i'm able to change
the green led state by changing the E0 register on GPIO. :)
But i try to do the same thing with the DIO12 pin locate on B12
register on GPIO without success :(

Here is my code made now in C code

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

volatile unsigned int *PADR, *PADDR;
volatile unsigned int *PBDR, *PBDDR;
volatile unsigned int *PCDR, *PCDDR;
volatile unsigned int *PDDR, *PDDDR;
volatile unsigned int *PEDR, *PEDDR;
volatile unsigned int *PFDR, *PFDDR;
volatile unsigned int *PGDR, *PGDDR;
volatile unsigned int *PHDR, *PHDDR;
volatile unsigned int *GPIOADB, *GPIOBDB, *GPIOFDB;

void GPIO_SETUP(void)
{
   unsigned char *start;
   int fd = open("/dev/mem", O_RDWR);
   start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED,
fd, 0x80840000);

   //GPIO registers

   //Port Data Registers Address
     PADR = (unsigned int *)(start + 0x00); //Port A
     PBDR = (unsigned int *)(start + 0x04); //Port B
     PCDR = (unsigned int *)(start + 0x08); //Port C
     PDDR = (unsigned int *)(start + 0x0C); //Port D
     PEDR = (unsigned int *)(start + 0x20); //Port E
     PFDR = (unsigned int *)(start + 0x30); //Port F
     PGDR = (unsigned int *)(start + 0x38); //Port G
     PHDR = (unsigned int *)(start + 0x40); //Port H

   //Port Direction Registers Address
     PADDR = (unsigned int *)(start + 0x10); //Port A
     PBDDR = (unsigned int *)(start + 0x14); //Port B
     PCDDR = (unsigned int *)(start + 0x18); //Port C
     PDDDR = (unsigned int *)(start + 0x1C); //Port D
     PEDDR = (unsigned int *)(start + 0x24); //Port E
     PFDDR = (unsigned int *)(start + 0x34); //Port F
     PGDDR = (unsigned int *)(start + 0x3C); //Port G
     PHDDR = (unsigned int *)(start + 0x44); //Port H

   //Port Debounce Registers Address
     GPIOADB = (unsigned int *)(start + 0xA8); //Port A
     GPIOBDB = (unsigned int *)(start + 0xC4); //Port B
     GPIOFDB = (unsigned int *)(start + 0x64); //Port F
 
   //Setting Input/Output Pin Port (0-Input, 1-Output)
     //*PADDR = 0xFF; // Setting all pins as output
     *PBDDR = *PBDDR | 0xF0; // Setting DIO15, DIO14, DIO13, DIO12
pins as output only
     //*PCDDR = 0xFF; // Setting all pins as output
     //*PDDDR = 0xFF; // Setting all pins as output
       *PEDDR = 0xFF; // Setting all pins as output
     //*PFDDR = 0xFF; // Setting all pins as output
     //*PGDDR = 0xFF; // Setting all pins as output
     //*PHDDR = 0xFF; // Setting all pins as output

     //Setting Debounce Pin Port (0-Disable, 1-Enable)
       //*GPIOADB = 0x00; //Port A
       //*GPIOBDB = 0x00; //Port B
       //*GPIOFDB = 0x00; //Port C

     close(fd);
}

int main(void)
{
     int i;
     printf("Is gone start!\n");

     GPIO_SETUP();

     for(i=0;i<25;i++){
        if((*PEDR & 0x01)==0)
        {
           printf("State OFF\n");
           *PEDR = (*PEDR | 0x01); //Green Led ON
           *PBDR = (*PBDR | 0x10); //DIO12 equal to 3.3V or High Level
        }else{
           printf("State ON\n");
           *PEDR = (*PEDR & 0xFE); //Green Led OFF
           *PBDR = (*PBDR & 0xEF); //DIO12 equal to 0V or Low Level
        }
        sleep(1);
     }

     printf("It has finish!\n");
     return 0;
}




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU