Skip to content

Instantly share code, notes, and snippets.

@ekoeppen
Created March 4, 2011 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekoeppen/854390 to your computer and use it in GitHub Desktop.
Save ekoeppen/854390 to your computer and use it in GitHub Desktop.
Newton Voyager Platform Driver Interface
#include <NewtonGestalt.h>
#include <NewtonScript.h>
#include <BufferList.h>
#include <BufferSegment.h>
class TGPIOInterface
{
public:
NewtonErr ReadGPIOData (UByte, ULong *);
};
class TBIOInterface
{
public:
NewtonErr ReadDIOPins (UByte pin, ULong *data);
NewtonErr WriteDIODir (UByte pin, UByte dir, UByte *data);
NewtonErr WriteDIOPins (UByte pin, UByte value, UByte *data);
};
class TVoyagerPlatform
{
public:
char filler_0000[0x0010];
TGPIOInterface *fGPIOInterface;
TBIOInterface *fBIOInterface;
char filler_0014[0x00f0];
NewtonErr SerialPort3LineDriverConfig (UByte, UByte);
};
extern TVoyagerPlatform *GetPlatformDriver(void);
extern "C" Ref Test (RefArg rcvr)
{
TVoyagerPlatform *p;
NewtonErr r;
ULong value;
UByte data;
int i;
TUGestalt gestalt;
TGestaltSystemInfo info;
gestalt.Gestalt (kGestalt_SystemInfo, &info, sizeof (info));
printf ("%08x %08x %08x\n", info.fROMStage, info.fMachineType, info.fROMVersion);
p = GetPlatformDriver ();
value = 0;
data = 0;
r = p->fBIOInterface->WriteDIODir (0x22, 1, &data);
printf ("%d 0x%02x\n", r, data);
r = p->fBIOInterface->WriteDIOPins (0x22, 1, &data);
printf ("%d 0x%02x\n", r, data);
printf ("Voyager: %08x\n", p);
for (i = 0; i < 16; i++) {
if (i % 4 == 0) printf ("\n");
value = 0;
r = p->fGPIOInterface->ReadGPIOData (i, &value);
printf ("(0x%02x 0x%04x) ", i, value);
}
printf ("\n");
for (i = 32; i < 48; i++) {
if (i % 4 == 0) printf ("\n");
value = 0;
r = p->fBIOInterface->ReadDIOPins (i, &value);
printf ("(0x%02x 0x%04x) ", i, value);
}
printf ("\n");
return NILREF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment