[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Use of GPIOG driver on g8-g23



Hello list,

 

Thought this should be very easy but somehow I can't get it to work. I must have missed something obvious and elementary.

Despite being a complete beginner in both Linux environment and the ETRAX chip I have managed to install, connect to, build test applications, build the test LCD-driver, use the CGI support in the Boa server and flash the devboard82 with all my stuff without problems. Or maybe I should correct that to whenever I had a problem the simple answer was to find in previous posting in this list.

 

But now I seem to have problem with this simple GPIOG driver. I want to control and set the bits on g8 through g23 (lp0 and lp1 data bits) individually but I can't measure any changes on any of the pins with my scope. I don't get any errors upon opening or writing to the port (gpio driver ioctl's). I've tried setting directions, disabled other ports etc, but still no change. I even looped the same output many times to see if there was some life on the pins. The etrax100parlcd driver works fine though (changed it to 2x16char instead of 4x20char LCD) and writes out whatever I want on my LCD even though parport support is enabled (I want to have support enabled for as may ports as possible, see below). None of the previous posts in this list gave me hint of why I can't get it to work with the GPIOG driver. Probably because it is something obvious I have missed =(

 

My suspicions...

1. I have some wrong settings in menuconfig (I'm not so familiar with all that stuff).

2. Pin 26 on x23 (LPT1). Should I do something with that pin and if so exactly what?

3. Sometimes I get pin 7 on x23 (LPT1, D2) set to high (3.3V) but I don't know why and how it happens...(!?)

4. What else have I missed or not aware of (I'm not a software guy really)?

 

Any suggestions greatly appreciated (what to check, test, change... settings...).

 

My test program as follows:

(Parts taken from previous postings and have been changed and experimented with a lot)

 

#include <fcntl.h>

#include <unistd.h>

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <asm/etraxgpio.h>

#include <sys/ioctl.h>

 

int main()

{

   unsigned long data, mask;

   int fd;

   char choice = 'y';

 

   while (choice == 'y')

   {

      /* Open port */

      fd = open("/dev/gpiog", O_RDWR);

      if(fd == -1)

      {

         printf("Cannot open gpiog port");

      }

      else

      {  

         data = mask = 0xFFFF << 8; /* lp0 and lp1 data */

         

         /* Set gpiog g8 to g23 to output */

         ioctl(fd, _IO(ETRAXGPIO_IOCTYPE, IO_SETGET_OUTPUT), &mask);

         if ((mask & data) != data)

            printf("Check kernel config (gpiog output).\n");

 

         data = 0x5555 << 8; /* Experiment with this data to get different outputs */

 

         /* Send data through port */

         if (ioctl(fd, _IO(ETRAXGPIO_IOCTYPE, IO_SETBITS), data) < 0)

         {

            printf("Error ioctl, set bits\n");

         }

         else

         {

            printf("%x written to gpiog port\n", data);

         }

 

         printf("Continue [y/n]? ");

         scanf("%s", &choice);

         /* Close port */

         close(fd);

      }

 

   }

 

return 1;

 

}

 

 

For anyone interested: What I'm trying to accomplish and why...

 

Application:

Simple universal test box for different peripherals with different interfaces (parallel IEEE1284, asynch serial, synch serial (SPI), I2C, 8-bit parallel MPU interface...etc).

 

Use:

Settings are made via a web-interface - anyone can connect to the test box with a computer via ethernet. The user chooses from lists or type in (form + cgi) what to send to the connected peripheral and sends it via the selected interface - hence no driver will be used simultaneous with another. That should work or am I wrong here? Some peripherals may have same electrical communicating interface but different initialization string and order of data received (software interface), so it won't be appropriate to write separate drivers for each peripheral (will be too many). Instead I want to use the general and standard drivers already built in and control the data communication in user mode software. The different peripherals properties will be read in from a conf file => easy (kind of) to add support for a new peripheral without having to compile anything and flash the board.

Later on I might try, somehow, to make the test box support multiple peripheral tests.

 

 

Regards

/Jon