home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / develop / galer / galer_deutsch / source / galersrcd.lha / GALerTest.c < prev    next >
C/C++ Source or Header  |  1993-03-27  |  12KB  |  536 lines

  1. /****************************************************************/
  2. /*                                */
  3. /* Testprogramm für GAL-Brenner                    */
  4. /*                                */
  5. /* Soft- and Hardware  copyright (c)1991            */
  6. /*     by Christian Habermann                    */
  7. /*        Asamstr. 17                        */
  8. /*        8050 Freising (W-Germany)                */
  9. /*                                */
  10. /*  cc -z4000 GALerTest.c                    */
  11. /*  as -n -c -d port.asm                    */
  12. /*  ln GALerTest.o port.o -lc                    */
  13. /*                                */
  14. /****************************************************************/
  15.  
  16.  
  17.  
  18. #include <exec/memory.h>
  19. #include <exec/ports.h>
  20. #include <exec/types.h>
  21. #include <intuition/intuition.h>
  22. #include <functions.h>
  23.  
  24. #include "GALer.h"
  25.  
  26.  
  27. #define     YPOS    30
  28.  
  29.  
  30. void Clear();
  31. void Print();
  32. void WaitForAction();
  33.  
  34.  
  35.  
  36. struct    MsgPort        *timeport;
  37. struct    timerequest    *timereq;
  38. struct    IntuitionBase    *IntuitionBase;
  39. struct    GfxBase        *GfxBase;
  40. struct    IntuiMessage    *message;
  41. struct    Window        *window;
  42. struct    RastPort    *rp;
  43. struct    TextFont    *txtfont;
  44. struct    TextAttr    txtattr;
  45.  
  46.  
  47. SHORT BorderVectors1a[] = { 0,15,73,15,73,0 };
  48. SHORT BorderVectors1b[] = { 0,15,0,0,73,0 };
  49.  
  50. struct Border Border1b    = { -1,-1,2,0,JAM1,3,BorderVectors1b,NULL };
  51. struct Border Border1a    = { -1,-1,1,0,JAM1,3,BorderVectors1a,&Border1b };
  52.  
  53.  
  54.  
  55. struct IntuiText GadIText3 = { 1,0,JAM2,4,4,&txtattr,
  56.                    (UBYTE *)"  ENDE  ",NULL };
  57.  
  58. struct IntuiText GadIText2 = { 1,0,JAM2,8,4,&txtattr,
  59.                    (UBYTE *)"Abbruch",NULL };
  60.  
  61. struct IntuiText GadIText1 = { 1,0,JAM2,12,4,&txtattr,
  62.                    (UBYTE *)"Weiter ",NULL };
  63.  
  64.  
  65.  
  66. struct Gadget CancelGad = { NULL, 530, 180, 72, 14,
  67.                 NULL,
  68.                 RELVERIFY,
  69.                 BOOLGADGET+REQGADGET,
  70.                 (APTR)&Border1a,NULL,
  71.                 &GadIText2,NULL,NULL,1,NULL };
  72.  
  73. struct Gadget ContGad   = { &CancelGad, 40, 180, 72, 14,
  74.                 NULL,
  75.                 RELVERIFY,
  76.                 BOOLGADGET+REQGADGET,
  77.                 (APTR)&Border1a,NULL,
  78.                 &GadIText1,NULL,NULL,0,NULL };
  79.  
  80.  
  81.  
  82.  
  83. struct NewWindow MyWin =  { 0,0,640,200,
  84.                 0,1,
  85.                 CLOSEWINDOW|GADGETUP,
  86.                 ACTIVATE|WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH,
  87.                 &ContGad,NULL,
  88.                 (UBYTE *)"GALerTest  (c) 1993 by Christian Habermann",
  89.                 NULL,NULL,
  90.                 0,0,0,0,
  91.                 WBENCHSCREEN
  92.               };
  93.  
  94.  
  95.  
  96.  
  97. int    prog_volt = 0;        /*Dummy für das Modul "Port"*/
  98. int    ytxt = YPOS;
  99.  
  100. main()
  101. {
  102. int errorIC6, errorIC7;
  103. int n;
  104.  
  105.  
  106.  openstuff();
  107.  
  108.  if (GetTimer()) {                /*Timer holen*/
  109.    puts("kann Timer nicht finden\n");
  110.    exit(FALSE);    
  111.   }
  112.  
  113.  
  114.  rp = window -> RPort;
  115.  
  116.  SetAPen(rp, 1L);
  117.  SetFont(rp, txtfont);            /*Font für Textausgabe*/
  118.  
  119.  
  120.  
  121.  
  122.  InitParPort();                /*Datenrichtungsregister der CIAs*/
  123.  
  124.  InitGALer();
  125.  
  126.  Print("Testprogramm für die Hardware-Version 1.2 des GAL-Brenners");
  127.  Print("(Versionsnummer der Hardware siehe Schaltplan).");
  128.  Print("");
  129.  Print("Bitte messen Sie alle angegebenen Spannungen an der Textool-Fassung nach.");
  130.  Print("In dieser Fassung darf sich jetzt noch KEIN GAL befinden!!!");
  131.  Print("Sobald irgendwo ein Fehler auftritt, brechen Sie bitte das Programm");
  132.  Print("durch Anklicken von 'Abbruch' ab und beheben zuerst diesen Fehler.");
  133.  Print("");
  134.  Print("Bitte 'Weiter' anklicken, um den Test zu starten.");
  135.  WaitForAction(0);
  136.  
  137.  Clear();
  138.  Print("Jetzt darf an keinem Pin der Textool-Fassung eine Spannung anliegen.");
  139.  Print("Außerdem soll die LED aus sein.");
  140.  Print("");
  141.  Print("Bitte 'Weiter' anklicken!");
  142.  EnableOutput();
  143.  WriteByte(0x00,IC3);
  144.  WriteByte(0x00,IC4);
  145.  WriteByte(0x00,IC5);
  146.  WaitForAction(0);
  147.  
  148.  Clear();
  149.  Print("Jetzt soll die LED leuchten.");
  150.  Print("");
  151.  Print("Bitte 'Weiter' anklicken!");
  152.  LED(ON);
  153.  WaitForAction(0);
  154.  
  155.  Clear();
  156.  Print("Jetzt soll die LED wieder aus sein.");
  157.  Print("");
  158.  Print("Bitte 'Weiter' anklicken!");
  159.  LED(OFF);
  160.  WaitForAction(0);
  161.  
  162.  Clear();
  163.  Print("An Pin 24 sollten jetzt ca. +5V anliegen.");
  164.  Print("");
  165.  Print("Bitte 'Weiter' anklicken!");
  166.  SetGAL(GAL20V8);
  167.  EnableVcc();
  168.  WaitForAction(0);
  169.  
  170.  Clear();
  171.  Print("An Pin 22 sollten jetzt ebenfalls ca. +5V anliegen.");
  172.  Print("");
  173.  Print("Bitte 'Weiter' anklicken!");
  174.  DisableVcc();
  175.  SetGAL(GAL16V8);
  176.  EnableVcc();
  177.  WaitForAction(0);
  178.  
  179.  Clear();
  180.  Print("Jetzt sollte an allen Pins ca. +5V anliegen, außer an Pin 12.");
  181.  Print("");
  182.  Print("Bitte 'Weiter' anklicken!");
  183.  InitGALer();
  184.  EnableOutput();
  185.  WriteByte(0xff,IC3);
  186.  WriteByte(0xff,IC4);
  187.  WriteByte(0xff,IC5);
  188.  WaitForAction(0);
  189.  
  190.  Clear();
  191.  Print("Jetzt sollte ab Pin 1 abwechselnd +5V,0V,+5V,0V usw. anliegen (ohne Pin 12).");
  192.  Print("");
  193.  Print("Bitte 'Weiter' anklicken!");
  194.  SetGAL(GAL20V8);
  195.  EnableVcc();
  196.  WriteByte(0x55,IC3);
  197.  WriteByte(0x55,IC4);
  198.  WriteByte(0x55,IC5);
  199.  WaitForAction(0);
  200.  
  201.  Clear();
  202.  Print("Jetzt invertiert (ohne Pin 12).");
  203.  Print("");
  204.  Print("Bitte 'Weiter' anklicken!");
  205.  DisableVcc();
  206.  WriteByte(0xaa,IC3);
  207.  WriteByte(0xaa,IC4);
  208.  WriteByte(0xaa,IC5);
  209.  WaitForAction(0);
  210.  
  211.  DisableVcc();
  212.  InitGALer();
  213.  EnableOutput();
  214.  VeditOn();
  215.  
  216.  Clear();
  217.  Print("***************************************************************************");
  218.  Print("In den nachfolgenden Punkten werden die verschiedenen Programmierspannungen");
  219.  Print("eingestellt. Sollte das nicht funktionieren, dann ist wahrscheinlich in der");
  220.  Print("Umgebung von IC 9, IC 10, T3, T4 ein Fehler.");
  221.  
  222.  Print("");
  223.  Print("Messen Sie jetzt am Pin 2 der Textool-Fassung die Spannung und stellen");
  224.  Print("Sie diese mit dem Poti R40 genau auf 16.5 Volt ein.");
  225.  Print("Bitte 'Weiter' anklicken!");
  226.  SetVolt(0);
  227.  SetGAL(GAL20V8);
  228.  EnableVEdit();
  229.  WaitForAction(0);
  230.  
  231.  Print("");
  232.  Print("Messen Sie jetzt am Pin 2 der Textool-Fassung die Spannung und stellen");
  233.  Print("Sie diese mit dem Poti R41 genau auf 15.75 Volt ein.");
  234.  Print("Bitte 'Weiter' anklicken!");
  235.  SetVolt(1);
  236.  WaitForAction(0);
  237.  
  238.  Print("");
  239.  Print("Messen Sie jetzt am Pin 2 der Textool-Fassung die Spannung und stellen");
  240.  Print("Sie diese mit dem Poti R42 genau auf 14.50 Volt ein.");
  241.  Print("Bitte 'Weiter' anklicken!");
  242.  SetVolt(2);
  243.  WaitForAction(0);
  244.  Print("");
  245.  
  246.  Print("Messen Sie jetzt am Pin 2 der Textool-Fassung die Spannung und stellen");
  247.  Print("Sie diese mit dem Poti R43 genau auf 14.00 Volt ein.");
  248.  Print("Bitte 'Weiter' anklicken!");
  249.  SetVolt(3);
  250.  WaitForAction(0);
  251.  Print("");
  252.  
  253.  Print("Messen Sie jetzt am Pin 2 der Textool-Fassung die Spannung und stellen");
  254.  Print("Sie diese mit dem Poti R44 genau auf 12.00 Volt ein.");
  255.  Print("Bitte 'Weiter' anklicken!");
  256.  SetVolt(4);
  257.  WaitForAction(0);
  258.  
  259.  Print("");
  260.  Print("So, die Spannungen sind jetzt alle eingestellt.");
  261.  Print("Bitte 'Weiter' anklicken!");
  262.  Print("***************************************************************************");
  263.  WaitForAction(0);
  264.  Clear();
  265.  
  266.  Print("Am Pin 2 sollten die 12.00 Volt wieder weg sein und dafür am Pin 4");
  267.  Print("anliegen. Wenn das nicht funktioniert, dann ist wahrscheinlich in der");
  268.  Print("Umgebung von T1, T2 ein Fehler.");
  269.  Print("");
  270.  Print("Bitte 'Weiter' anklicken!");
  271.  DisableVEdit();
  272.  SetGAL(GAL16V8);
  273.  EnableVEdit();
  274.  WaitForAction(0);
  275.  Clear();
  276.  
  277.  
  278.  
  279.  
  280.             /*ab hier wird überprüft, ob das Auslesen der*/
  281.             /*Ausgangspegel des GALs funktioniert (IC6a, IC7)*/
  282.  Print("überpüfe das Auslesen der Ausgangspegel von Pin 14-22 der");
  283.  Print("Textool-Fassung...");
  284.  SetGAL(GAL20V8);
  285.  InitGALer();
  286.  EnableVcc();
  287.  EnableOutput();
  288.             /*IC6a testen*/
  289.  errorIC6 = errorIC7 = 0;
  290.  WriteByte(0x40,IC3);
  291.  if (!ReadByte(IC6))
  292.    errorIC6 = 1;
  293.  
  294.  WriteByte(0x00,IC3);
  295.  if (ReadByte(IC6))
  296.    errorIC6 = 1;
  297.             /*IC7 testen*/
  298.  WriteByte(0x00,IC5);
  299.  if (ReadByte(IC7))
  300.    errorIC7 = 1;
  301.  
  302.  WriteByte(0x2A,IC3);
  303.  WriteByte(0x20,IC5);
  304.  if (ReadByte(IC7) != 0xAA)
  305.    errorIC7 = 1;
  306.  
  307.  WriteByte(0x15,IC3);
  308.  WriteByte(0x10,IC5);
  309.  if (ReadByte(IC7) != 0x55)
  310.    errorIC7 = 1;
  311.  
  312.  DisableVcc();
  313.  DisableOutput(); 
  314.  
  315.  if (errorIC6 || errorIC7) {
  316.    Print(" FEHLER!!!");
  317.    Print("  Wenn sich bis jetzt 'GALer' fehlerfrei verhalten hat,");
  318.    Print("  dann überprüfen Sie bitte folgenden Bereich der Schaltung:");
  319.    Print("  BUSY-Leitung des Parallel-Ports, R27, Pins 1,2 von IC8, IC6a und");
  320.    Print("  IC6b, IC7 und R13. Irgendwo in diesem Bereich ist ein Fehler.");
  321.  
  322.    Print("  Fehlerbeschreibung:");
  323.    if (errorIC6 && !errorIC7) {
  324.      Print("  Kann Pin 22 der Textool-Fassung nicht über die BUSY-Leitung des");
  325.      Print("  Parallel-Ports auslesen.");
  326.    }
  327.  
  328.    if (!errorIC6 && errorIC7) {
  329.      Print("  Kann Pins 14-21 der Textool-Fassung nicht über die BUSY-Leitung des");
  330.      Print("  Parallel-Ports auslesen.");
  331.    }
  332.  
  333.    if  (errorIC6 && errorIC7) {
  334.      Print("  Kann Pins 14-21 und Pin 22 der Textool-Fassung nicht über die");
  335.      Print("  BUSY-Leitung des Parallel-Ports auslesen.");
  336.    }
  337.  
  338.    Print("");
  339.    Print("  Falls bereits bei einem vorherigen Testpunkt eine Spannung nicht");
  340.    Print("  gestimmt hat, dann versuchen Sie bitte zuerst den obigen Fehler zu");
  341.    Print("  beseitigen.");
  342.  }
  343.  else {
  344.    Print(" alles o.k.");
  345.    Print("");
  346.    Print("Wenn alle Spannung korrekt waren und Sie alle Programmierspannungen");
  347.    Print("(12, 14, 14.5, 15.75 und 16.5 Volt) eingestellt haben, dann");
  348.    Print("funktioniert die Hardware sehr wahrscheinlich fehlerfrei.");
  349.    Print("Letzte Gewißheit bekommen Sie, indem Sie probeweise einige GALs");
  350.    Print("programmieren und anschließend austesten.");
  351.  }
  352.  
  353.  CancelGad.GadgetText = &GadIText3;
  354.  OffGadget(&ContGad, window, NULL);
  355.  RefreshGList(&ContGad, window, NULL);
  356.  
  357.  WaitForAction(0);
  358.  
  359.  
  360.  RestoreParPort();
  361.  
  362.  FreeTimer();
  363.  
  364.  closestuff();
  365. }
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372. GetTimer()                /*Timer holen*/
  373. {
  374.  
  375.  timeport = CreatePort(0L,0L);
  376.  if (timeport == NULL)
  377.    return(-1);
  378.  
  379.  timereq=(struct timerequest *)AllocMem(
  380.             (long)sizeof(struct timerequest),MEMF_PUBLIC);
  381.  if (timereq == NULL) {
  382.    DeletePort(timeport);
  383.    return(-1);
  384.   }
  385.  
  386.  timereq->tr_node.io_Message.mn_Node.ln_Type=NT_MESSAGE;
  387.  timereq->tr_node.io_Message.mn_Node.ln_Pri=0;
  388.  timereq->tr_node.io_Message.mn_ReplyPort=timeport;
  389.  
  390.  if (OpenDevice(TIMERNAME,UNIT_MICROHZ,timereq,0L)) {
  391.    FreeMem(&timereq,(long)sizeof(struct timerequest));
  392.    DeletePort(timeport);
  393.    return(-1);
  394.   }
  395.  
  396.  return(0);
  397. }
  398.  
  399.  
  400.  
  401. void FreeTimer()            /*Timer wieder freigeben*/
  402. {
  403.  CloseDevice(timereq);
  404.  FreeMem(timereq,(long)sizeof(struct timerequest));
  405.  DeletePort(timeport);
  406. }
  407.  
  408.  
  409.  
  410. /*micro: microsec. to wait
  411.   secs: seconds to wait
  412. */
  413. void WaitForTimer(micro)
  414. ULONG micro;
  415. {
  416.  timereq->tr_node.io_Command=TR_ADDREQUEST;
  417.  timereq->tr_time.tv_secs=0;
  418.  timereq->tr_time.tv_micro=micro;
  419.  DoIO(timereq);
  420. }
  421.  
  422.  
  423.  
  424.  
  425. void Clear()
  426. {
  427.  ytxt = YPOS;
  428.  SetAPen(rp, 0L);
  429.  RectFill(rp, 10L, 22L, 630L, 170L);
  430.  SetAPen(rp, 1L);
  431. }
  432.  
  433.  
  434.  
  435. void Print(text)
  436. UBYTE    *text;
  437. {
  438.  
  439.  if (ytxt < 160)
  440.    ytxt += 10;
  441.  else
  442.    ScrollRaster(rp,0L,10L,10L,22L,630L,170L);
  443.  
  444.  Move(rp,20L,(long)ytxt);
  445.  Text(rp,text,(long)strlen(text));
  446. }
  447.  
  448.  
  449.  
  450.  
  451. /* wartet auf das Anklicken eines Gadgets
  452. */
  453. void WaitForAction()
  454. {
  455. ULONG    class;
  456. USHORT    code,gadID;
  457.  
  458.  for(;;) {
  459.    Wait(1L<<window->UserPort->mp_SigBit);
  460.    if (message=(struct IntuiMessage *)GetMsg(window->UserPort)) {
  461.      class = message -> Class;
  462.      code  = message -> Code;
  463.      if (class == GADGETUP)
  464.        gadID=((struct Gadget *)message->IAddress)->GadgetID;
  465.      ReplyMsg(message);
  466.  
  467.      switch(class) {
  468.     case CLOSEWINDOW: closestuff();        /*Programm fluchtartig*/
  469.               FreeTimer();        /*verlassen*/
  470.               RestoreParPort();
  471.               exit(0);
  472.               break;
  473.  
  474.     case GADGETUP:    if (!gadID)
  475.                 return;                
  476.               else {        /*Abbruch angeklickt*/
  477.                 closestuff();
  478.                 FreeTimer();
  479.                 RestoreParPort();
  480.                 exit (0);
  481.               }
  482.               break;
  483.      }
  484.    }
  485.  }
  486. }
  487.  
  488.  
  489.  
  490.  
  491.  
  492. closestuff()
  493. {
  494.   if (window)  CloseWindow(window);
  495.   if (GfxBase) CloseLibrary(GfxBase);
  496.   if (IntuitionBase) CloseLibrary (IntuitionBase);
  497. }
  498.  
  499.  
  500. openstuff()
  501. {
  502.  if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L)) == NULL) {
  503.    puts ("kann intuition.library nicht öffnen");
  504.    exit(FALSE);
  505.  }
  506.  
  507.  if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L)) == NULL) {
  508.    puts ("kann graphics.library nicht öffnen");
  509.    closestuff();
  510.    exit(FALSE);
  511.  }
  512.  
  513.  
  514.  txtattr.ta_Name  = (STRPTR)"topaz.font";        /*Font holen*/
  515.  txtattr.ta_YSize = 8;
  516.  txtattr.ta_Style = 0;
  517.  txtattr.ta_Flags = 0;
  518.  
  519.  if (!(txtfont = (struct TextFont *)OpenFont(&txtattr))) {
  520.    puts("kann topaz.font 8 nicht finden");
  521.    closestuff();
  522.    exit(FALSE);
  523.  }
  524.  
  525.  
  526.  if ((window = (struct Window *)OpenWindow(&MyWin)) == NULL) {
  527.    puts ("kann Fenster nicht öffnen");
  528.    closestuff();
  529.    exit(FALSE);
  530.  }
  531. }
  532.  
  533.  
  534.  
  535.  
  536.