I am having troubles using the GPIO port on a SA1100.  Included is a snippet
of code that tries to set the GPIO port to output, then set everything high,
followed by low.  This simple little test is throwing a segmentation fault
every time I try to write to the registers.

Thanks in advance for any input,
Sisinio


#include <stdio.h>

#define GPIO_GPLR    0x90040000
#define GPIO_GPDR    0x90040004
#define GPIO_GPSR    0x90040008
#define GPIO_GPCR    0x9004000C
#define GPIO_GRER    0x90040010
#define GPIO_GFER    0x90040014
#define GPIO_GEDR    0x90040018
#define GPIO_GAFR    0x9004001C

typedef unsigned long ULONG;


int main( int argc, char* argv[] )
{
  ULONG* ptr;

  // set to output
  fprintf( stdout, "setting GPDR\n" );
  ptr = (ULONG*)GPIO_GPDR;
  *ptr = 0xFFFF;

  // set high
  fprintf( stdout, "set to 1s\n" );
  ptr = (ULONG*)GPIO_GPSR;
  *ptr = 0xFFFF;

  // sleep
  for ( int i = 0 ; i < 10000000 ; ++i );

  // set low
  fprintf( stdout, "set to 0s\n" );
  ptr = (ULONG*)GPIO_GPCR;
  *ptr = 0xFFFF;

  return 0;
}



_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
Please visit the above address for information on this list.

Reply via email to