rendered paste body#include<stdint.h>#include<stdio.h>#include<math.h>#include<stdlib.h>#include<windows.h>#include "funktion_frequenz.h"#include "funktion_wave.h"typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);void ausgabe(unsigned int lptin);int main(void){ unsigned int eingabe; unsigned int conreg; unsigned int lsb; unsigned int msb; do { printf("\nHauptmenue\n\n"); printf("-1- Frequenz waehlen\n"); printf("-2- Signalform waehlen\n"); printf("-3- Start\n"); printf("-0- Exit\n"); printf("\nBitte Menue waehlen:\n"); scanf("%i", &eingabe); switch(eingabe) { case 1: printf("Bitte Freuquenz zwischen 0Hz und 10MHz eingeben:"); scanf("%i",&eingabe); printf("%iHz\n", eingabe); if(eingabe<=0) { while(eingabe<=0) { printf("Eingabe falsch!\n"); printf("Bitte Freuquenz zwischen 0Hz und 10MHz eingeben:"); scanf("%i", &eingabe); printf("%iHz\n", eingabe); } } if(eingabe>10000000) { while(eingabe>10000000) { printf("Eingabe falsch!\n"); printf("Bitte Freuquenz zwischen 0Hz und 10MHz eingeben:"); scanf("%i", &eingabe); printf("%iHz\n", eingabe); } } set_frequenz(eingabe, &lsb, &msb); break; case 2: printf("-1-Sinus\n-2-Dreieck\n-3-Rechteck\n"); printf("Bitte Singalform eingeben:"); scanf("%i",&eingabe); if(eingabe<=0) { while(eingabe<=0) { printf("Eingabe falsch!\n"); printf("Bitte Signalform eingeben:"); scanf("%i", &eingabe); } } if(eingabe>3) { while(eingabe>3) { printf("Eingabe falsch!\n"); printf("Bitte Signalform eingeben:"); scanf("%i", &eingabe); } } set_waveform(eingabe, &conreg); break; case 3: ausgabe(0x2100); // reset=1 , d13=1 full 28bit freq ausgabe(lsb); // lsb frequenzregister ausgabe(msb); // msb frequenzregister ausgabe(0xc000); // phasenregister=0 ausgabe(conreg); // reset=0, frequenzform break; case 0: exit; break; default: printf("falsche eingabe!"); } } while(eingabe!=0); return 0;}void ausgabe(unsigned int lptin){ HINSTANCE hLib; oupfuncPtr oup32; int lptport; // adresse lptport int i; // laufvariable int aus[15]; // array fr datenwort short lptaus; // lptdaten hLib = LoadLibrary("inpout32.dll"); oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32"); /***** Write the data register */ lptport=0x378; printf("test port write to 0x%X, datum=0x%2X\n" ,lptport ,lptaus); // beschreiben des arrays aus[0]=(lptin << 1) & 0x2; //lsche 1. und 3. bit, 1. arrayfeld schreiben aus[1]=lptin & 0x2; //lsche 1. und 3. bit, 2. arrayfeld schreiben for(i=2;i<=15;++i) //rest des arrays vollschreiben { aus[i]=(lptin >> i-1) & 0x2; // lsche 1. und 3. bit } // ausgabe an lptport // bit 0 und 3 fsyn=0 sclk=0: 0h; fsyn=0 sclk=1: 1h; fsyn=1 sclk=0: 4h; fsyn=1 sclk=1: 5h; aus[0]=aus[0] | 0x5; // stopp sclk=1 fsyn=1 lptaus=aus[0]; (oup32)(lptport,lptaus); printf("port write to 0x%X, datum=0x%2X\n" ,lptport ,lptaus); for(i=15;i>=0;--i) // start ausgabe lpt; high bit zuerst { aus[i]=aus[i] & 0x2; // lsche bit 1 u. 3 aus[i]=aus[i] | 0x1; // setzen sclk=1 fsyn=0 lptaus=aus[i]; (oup32)(lptport,lptaus); sleep(2); // sleep t4 zeit printf("port write to 0x%X, datum=0x%2X\n" ,lptport ,lptaus); aus[i]=aus[i] & 0x2; // lsche bit 1 u. 3 aus[i]=aus[i] | 0x0; // sclk=0 fsyn=0 lptaus=aus[i]; (oup32)(lptport,lptaus); sleep(2); // sleep t4 zeit printf("port write to 0x%X, datum=0x%2X\n" ,lptport ,lptaus); aus[i]=aus[i] & 0x2; // lsche bit 1 u. 3 aus[i]=aus[i] | 0x1; // setzen sclk=1 fsyn=0 lptaus=aus[i]; (oup32)(lptport,lptaus); sleep(1); // sleep muss kleiner sein als t4 (t8 zeit) printf("port write to 0x%X, datum=0x%2X\n" ,lptport ,lptaus); } aus[0]=aus[0] | 0x5; // stopp sclk=1 fsyn=1 ???funzt clock u. fsync??? lptaus=aus[0]; (oup32)(lptport,lptaus); printf("port write to 0x%X, datum=0x%2X\n" ,lptport ,lptaus);}