stergios@rocky.UUCP (04/15/87)
I'm trying to figure out how to access the parallel port directly through hardware, rather than the device handlers. I know that the parallel port is on the first 8520 (CIAA), and that the register on this chip dedicated to the parallel port is mapped in memory as a byte address at BEE101. (page F-2 of the A/W hardware manual). I am pretty sure (but not %100, hence the questions) I can send a byte to this location by; char *parpt; parpt = (char *)0xBEE101; /* set up a pointer to the || port */ *parpt = 0xFF; /* poke 0xff to the || port */ What I'm not certain about is making sure the 8520 will 1. accept this value cause the || register was not selected first, and 2. is the register seletced because the address BEE101 forces some address lines that are tied to the 8520 logic to select the || port register? I have been able to read from this address with no problem. However, when I write to and then read from it, it looks like the byte I sent it never got there. I have alreadyy set the data direction register on the 8520 pertianing to PRB so that it can accept writes. What am I missing? Is the 8520 a cbm product, and is it documented anywhere? I know that this is against all the rules for PUBLIC programming, i.e. talking directly to the hardware. But since I'm trying to access the || port from CLIPS and LISP so that I can "talk" to my robot sitting on the || port, it wont bother anyone, unless of course, you would like to purchase my robot 8^). Stergios Marinopoulos S&M Engineering -- % UUCP: !decwrl!rocky.stanford.edu!stergios % % ARPA: f.flex@othello.stanford.edu % % USnail: Crothers Memorial #690, Stanford, CA. 94305 % % Pa Bell: (415) 326-9051 %
phillip@cbmvax.UUCP (04/16/87)
in article <236@rocky.STANFORD.EDU>, stergios@rocky.STANFORD.EDU (Stergios Marinopoul) says: > > > I'm trying to figure out how to access the parallel port directly > through hardware, rather than the device handlers. I know that the --------***************[trimmed to make net people happy...] > > Stergios Marinopoulos > S&M Engineering We have resources for the parallel port (ciaa.resource and misc.resource). If it isn't too much trouble I would like to see you use them.:-> What follows is an example the uses the system resources to access the parallel port directly. -phil ============================================================================== Phillip Lindsay - Commodore Business Machines - Amiga Technical Support UUCP: {ihnp4|seismo|caip}!cbmvax!phillip - Phone: (215) 431-9180 No warranty is implied or otherwise given in the form of suggestion or example. Any opinions found here are of my making. ---cut---here------------------------------------------------------------------ #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # parout.c # getfreemisc.asm # This archive created: Thu Apr 16 07:52:57 1987 export PATH; PATH=/bin:$PATH echo shar: extracting "'parout.c'" '(3812 characters)' if test -f 'parout.c' then echo shar: will not over-write existing file "'parout.c'" else sed 's/^ X//' << \SHAR_EOF > 'parout.c' X/* parout.c - Parallel port resource example. X * X * Phillip Lindsay (c) Commodore-Amiga, Inc. X * Unlimited use granted as long as copyright notice remains intact. X * X */ X#include <exec/types.h> X#include <exec/nodes.h> X#include <exec/lists.h> X#include <exec/interrupts.h> X#include <hardware/custom.h> X#include <hardware/intbits.h> X#include <hardware/cia.h> X#include <resources/misc.h> X#include <resources/cia.h> /* this header has defines for hardware addresses */ X X#define CIAA_DDRPBOUT 0xff /* CIAA port B all "ouputs" */ X X#define MANX /* using MANX Aztec C */ X X#ifdef MANX X#include <functions.h> X#endif X Xextern CPTR GetMiscResource(); Xextern VOID FreeMiscResource(); Xextern ULONG CIAARoutine(); X Xstruct MiscResource *MiscResource=NULL; XCPTR CIAAResource=NULL; X Xchar *myname = "myparallel"; Xchar *teststr= "This is a test line being sent to a parallel device.\n"; X Xstruct Task *mytask; XLONG mysignal; XULONG mysigmask; X Xmain() X{ X struct Interrupt CIAAInterrupt; X register count=0; X X MiscResource = (struct MiscResource *) OpenResource(MISCNAME); X if(!MiscResource) exit(10); Xputs("after open misc.resource"); X X CIAAResource = (CPTR) OpenResource(CIAANAME); X if(!CIAAResource) exit(20); Xputs("after open ciaa.resource"); X X/* this is where we get our 8bits for parallel transfer */ X if(GetMiscResource(MiscResource,MR_PARALLELPORT,myname)) exit(30); Xputs("after GetMiscResource PARALLELPORT (CIAA Port B)"); X X/* this is where we get busy(bit 0), pout(bit 1), sel(bit 2) */ X if(GetMiscResource(MiscResource,MR_PARALLELBITS,myname)) X { X FreeMiscResource(MiscResource,MR_PARALLELPORT); X exit(40); X } Xputs("after GetMiscResource PARALLELBITS BUSY/POUT/SEL (CIAB Port A bits 0,1,2)"); X X if((mysignal = AllocSignal(-1L)) == -1L) X { X FreeMiscResource(MiscResource,MR_PARALLELPORT); X FreeMiscResource(MiscResource,MR_PARALLELBITS); X exit(50); X } Xputs("after AllocSignal()"); X X mysigmask = 1L << mysignal; X X /* now we own the parallel port, next handshake interrupt ACK */ X setmem(&CIAAInterrupt,(ULONG)sizeof(CIAAInterrupt),(ULONG)'\0'); Xputs("after setmem()"); X CIAAInterrupt.is_Data = (APTR) CIAAResource; X CIAAInterrupt.is_Code = (VOID(*)()) CIAARoutine; X CIAAInterrupt.is_Node.ln_Type = NT_INTERRUPT; X CIAAInterrupt.is_Node.ln_Name = myname; Xputs("after interrupt init"); X if(AddICRVector(CIAAResource,CIAICRB_FLG,&CIAAInterrupt)) X { X FreeMiscResource(MiscResource,MR_PARALLELPORT); X FreeMiscResource(MiscResource,MR_PARALLELBITS); X FreeSignal(mysignal); X exit(50); X } Xputs("after AddICRVector()"); X X /* disable ACK interrupt */ X AbleICR(CIAAResource,CIAICRF_FLG); Xputs("after AbleICR() disable flag interrupt"); X X /* set up direction for i/o ports used */ X ciaa.ciaddrb = CIAA_DDRPBOUT; /* make CIAA port B all "ouputs" */ X X /* make BUSY, SEL, POUT "inputs" on CIAA port A */ X ciab.ciaddra &= ( ~CIAF_PRTRBUSY | ~CIAF_PRTRPOUT | ~CIAF_PRTRSEL ); X X /* clear any pending interrupts */ X SetICR(CIAAResource,CIAICRF_FLG); Xputs("after SetICR() clear pending flag interrupts"); X X /* enable ACK interrupt */ X AbleICR(CIAAResource,CIAICRF_SETCLR|CIAICRF_FLG); Xputs("after AbleICR() enable flag interrupt"); X X while(teststr[count]) X { X if(ciab.ciapra & CIAF_PRTRBUSY) /* make sure device is not busy */ X continue; X ciaa.ciaprb = teststr[count++]; /* write data to port */ X wait(mysigmask); /* wait for ack */ X } X X AbleICR(CIAAResource,CIAICRF_FLG); /* disable interrupt */ X /* remove interrupt */ X RemICRVector(CIAAResource,CIAICRB_FLG,&CIAAInterrupt); X /* free resources */ X FreeMiscResource(MiscResource,MR_PARALLELPORT); X FreeMiscResource(MiscResource,MR_PARALLELBITS); X FreeSignal(mysignal); X} X/* end of main() */ X X XULONG CIAARoutine() X{ X#ifdef MANX X geta4(); X#endif X Signal(mytask,mysigmask); X return(0L); X} X X/* eof */ X SHAR_EOF if test 3812 -ne "`wc -c < 'parout.c'`" then echo shar: error transmitting "'parout.c'" '(should have been 3812 characters)' fi fi # end of overwriting check echo shar: extracting "'getfreemisc.asm'" '(1013 characters)' if test -f 'getfreemisc.asm' then echo shar: will not over-write existing file "'getfreemisc.asm'" else sed 's/^ X//' << \SHAR_EOF > 'getfreemisc.asm' X****************************************************************************** X* getfreemisc.asm - interface routines for misc.resource X* X* Phillip Lindsay (c) 1987 Commodore-Amiga, Inc. X* Unlimited use granted as long as copyright notice remains intact. X* X****************************************************************************** X X INCLUDE 'exec/types.i' X INCLUDE 'exec/libraries.i' X INCLUDE 'resources/misc.i' X X XDEF _GetMiscResource X XDEF _FreeMiscResource X X_GetMiscResource: X movem.l a4/a6,-(sp) X move.l 20(sp),a1 ; name X move.l 16(sp),d0 ; unit X move.l 12(sp),a6 ; misc resource pointer X jsr MR_ALLOCMISCRESOURCE(a6) X movem.l (sp)+,a4/a6 X rts X X_FreeMiscResource: X movem.l a4/a6,-(sp) X move.l 12(sp),a6 ; misc resource pointer X move.l 16(sp),d0 ; unit X jsr MR_FREEMISCRESOURCE(a6) X movem.l (sp)+,a4/a6 X rts X X end X***************************************************************************** X* X* end of getfreemisc.asm X* X***************************************************************************** SHAR_EOF echo shar: a missing newline was added to "'getfreemisc.asm'" if test 1013 -ne "`wc -c < 'getfreemisc.asm'`" then echo shar: error transmitting "'getfreemisc.asm'" '(should have been 1013 characters)' fi fi # end of overwriting check # End of shell archive exit 0
grr@cbmvax.cbm.UUCP (George Robbins) (04/29/87)
In article <236@rocky.STANFORD.EDU> stergios@rocky.stanford.edu (Stergios Marinopoul) writes: > > I'm trying to figure out how to access the parallel port directly >through hardware, rather than the device handlers. I know that the >parallel port is on the first 8520 (CIAA), and that the register on this chip >dedicated to the parallel port is mapped in memory as a byte address at >BEE101. (page F-2 of the A/W hardware manual). According to all the hardware documentation around here that should be BFE101. Some of the ancient prototypes had different peripheral chips at different addresses. I'm sure you've figured this out by now, but I didn't have to tru-facts at hand before... -- George Robbins - now working for, uucp: {ihnp4|seismo|rutgers}!cbmvax!grr but no way officially representing arpa: cbmvax!grr@seismo.css.GOV Commodore, Engineering Department fone: 215-431-9255 (only by moonlite)