home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ANews 2
/
AnewsCD2.iso
/
Materiels
/
AteoConcepts
/
DOC_DEV
/
Exemple
/
Example.c
next >
Wrap
C/C++ Source or Header
|
1999-10-13
|
4KB
|
134 lines
/*
**
** Atéo Concepts SARL
**
** Street Adr Internet Adr
** ---------------------------------
** Le Plessis web: http://www.ateo-concepts.com
** 44220 COUERON email: info@ateo-concepts.com
** FRANCE
**
** Phone: +33 2.40.85.30.85
** Fax : +33 2.40.38.33.21
**
** -------------------------------------------------------------------------------
** Example.c
**
** This is an example of how to acces std Isa hardware on the AteoBus
**
** Let say we have an hardware card (ISA IO Space)that have two 8 bits registers at
** 0x102 and 0x104 with 8bits acces only (Register 1 and Register 2) and two others
** registers at 0x110 and 0x111 with 8 or 16 bits acces (2 x 8bit acces or
** 1 x 16bit acces)
**
** Like this:
**
** ISA IO Base 0x000 +------------+
** | |
** +------------+
** 0x102 | Register 1 | 8bits only
** | Empty |
** 0x104 | Register 2 | 8bits only
** . .
** . .
**
** 0x110 | Register A | 8bits or 16bits
** 0x111 | Register B |
** | |
** . .
** . .
**
** If you have question or comment regarding this example, please mail to
** arlequin@ateo-concepts.com
**
**
**
** Of course, if you have no hardware like this one connected on your AtéoBus,
** this software will just do nothing....
**
*/
/* AmigaOS includes */
#include "proto/exec.h"
#include "proto/dos.h"
/* AtéoBus includes */
#include "hardware/ateobus.h"
#include "pragmas/ateobus_pragmas.h"
#include "clib/ateobus_protos.h"
/* general includes */
#include <stdio.h>
/* define for the hardware card (see top of the file for more info about the hardware) */
#define REGISTER_1 0x102
#define REGISTER_2 0x104
#define REGISTER_A 0x110
#define REGISTER_B 0x111
long int main( void )
{
unsigned long int IsaIOBase;
unsigned char *Register1;
unsigned char *Register2;
unsigned short int *RegisterA;
unsigned char *RegisterB;
AteoBase = OpenLibrary("ateobus.library",2); /* Open the ateobus.library V2+ */
if (AteoBase)
{
/* OpenLib Ok */
printf("Library Opened Sucessfully.\n");
/* Get the base of the ISA IO Space */
IsaIOBase = (unsigned long)AC_GetSpaceBase( ISA_SPACE | IO_SPACE);
{
unsigned long int Adr;
/* Calculate the adr for all register */
Adr = IsaIOBase + REGISTER_1;
Register1 = (unsigned char *)Adr;
Adr = IsaIOBase + REGISTER_2;
Register2 = (unsigned char *)Adr;
Adr = IsaIOBase + REGISTER_A;
RegisterA = (unsigned short int *)Adr;
Adr = IsaIOBase + REGISTER_B;
RegisterB = (unsigned char *)Adr;
/* print the adr for all register */
printf(" @ Register1: %8X\n", Register1 );
printf(" @ Register2: %8X\n", Register2 );
printf(" @ RegisterA: %8X\n", RegisterA );
printf(" @ RegisterB: %8X\n", RegisterB );
}
/* Read Register1 */
printf(" Register1 = %x\n", *Register1 );
/* Read RegisterB */
printf(" RegisterB = %x\n", *Register2 );
/* Write 0x0672 to RegisterA (16bits mode) */
/* This will write 0x06 to location 0x110 and 0x72 to location 0x111 */
*RegisterA = 0x0672;
/* Read the result */
printf(" RegisterA = %x\n RegisterB = %x\n", *(unsigned char *)RegisterA, *RegisterB );
/* Close the library */
CloseLibrary(AteoBase);
}
else
{
/* trouble with OpenLibrary */
printf("I need ateobus.library V2.0+\n");
}
}