printer pin toggling

hi,

I am trying to use a Parallel port in AIMB 580 board.In order to check its working i tried to toggle the data pin using the code,no change in pin was occurring.My code is returning a negative handler.How do i assign a memory address for the parallel.

Any help greatly appreciated.

i am attaching the code i am using

#include <stdio.h>
#include <unistd.h> /* for sleep() /
#include <stdint.h> /
for uintptr_t /
#include <hw/inout.h> /
for in*() and out*() functions /
#include <sys/neutrino.h> /
for ThreadCtl() /
#include <sys/mman.h> /
for mmap_device_io() */

/* The Neutrino IO port used here corresponds to a single register, which is

  • one byte long */
    #define PORT_LENGTH 1

/* The first parallel port usually starts at 0x378. Each parallel port is

  • three bytes wide. The first byte is the Data register, the second byte is
  • the Status register, the third byte is the Control register. /
    #define DATA_ADDRESS 0x378
    #define CTRL_ADDRESS 0x37a
    /
    bit 2 = printer initialisation (high to initialise)
  • bit 4 = hardware IRQ (high to enable) */
    #define INIT_BIT 0x04

#define LOW 0x00
#define HIGH 0xFF

#define MAX_COUNT 60

/* ______________________________________________________________________ */
int
main( )
{
int privity_err;
uintptr_t ctrl_handle;
uintptr_t data_handle;
int count;

/* Give this thread root permissions to access the hardware */
privity_err = ThreadCtl( _NTO_TCTL_IO, NULL );
if ( privity_err == -1 )
{
fprintf( stderr, “can’t get root permissions\n” );
return -1;
}

/* Get a handle to the parallel port’s Control register /
ctrl_handle = mmap_device_io( PORT_LENGTH, BASE_ADDRESS_LPT1 );
if(ctrl_handle=-1)
{
printf(“not mapped”);
}
/
Initialise the parallel port */
out8( ctrl_handle, INIT_BIT );

/* Get a handle to the parallel port’s Data register */
data_handle = mmap_device_io( PORT_LENGTH, BASE_ADDRESS_LPT1+0x04 );

for ( count = 0; count < MAX_COUNT; count++ )
{
/* Output a byte of lows to the data lines */
out8( data_handle, LOW );
printf( “Low\n” );
sleep( 1 );

  /* Output a byte of highs to the data lines */
  out8( data_handle, HIGH );
  printf( "High\n" );
  sleep( 1 );

}

return 0;
}

When this happens what is errno: printf(“not mapped: error %d\n”, errno);

Also no where in your code do we see this value: BASE_ADDRESS_LPT1

Tim

Sir,

Thanks for the reply,actually printer was getting detected but i was probing the pin in wrong way,due to which i was not able to see wither pins were toggling or not.

Thanks,
Amit