'Programm ist Bestandteil des IQP-500 Eva-Boards. 'Programm entwickelt von Niels Keller - Keine Garantie/Gewährleistung auf Funktion 'Programm und Programmteile nur zum privatem Gebrauch. 'Bei gewerblicher Nutzung ist eine Zustimmung von Niels Keller unter mail@upuc.de schriftlich zu erfragen. 'Betriebsarten werden über Jumper CMD_01 und CMD_02 gesetzt - Jumper geschlossen=0; Jumper geöffnet=1 'Zur Bedeutung: 'CMD_01=0 und CMD_02=0: Bild klein, kein Blitz, direkte Übertragung 'CMD_01=1 und CMD_02=0: Bild groß, kein Blitz, direkte Übertragung 'CMD_01=0 und CMD_02=1: Bild klein, kein Blitz, EEPROM 'CMD_01=1 und CMD_02=1: Bild klein, kein Blitz, Troubleshooting mit Statusausgabe 'Weitere Einstellungen können durch die serielle Kommunikation mit dem PC übergeben werden $regfile = "m8def.dat" $baud = 19200 '$crystal = 16934400 'Abweichung bei 0,23% bei 115,2kBit $crystal = 11059200 Config Portb.0 = Output Cts Alias Portb.0 Config Portd.6 = Output Rts Alias Portd.6 Config Portc.0 = Output Led Alias Portc.0 Config Pinc.3 = Input Cmd_01 Alias Pinc.3 Config Pinc.2 = Input Cmd_02 Alias Pinc.2 Config Pinc.1 = Input Cmd_04 Alias Pinc.1 Config Pind.2 = Input Ausloeser Alias Pind.2 Config Serialin = Buffered , Size = 254 Enable Interrupts Disable Int0 Declare Sub E_write(byval Speicherzelle_pos As Word , Dat As Byte) Declare Sub E_read(byval Speicherzelle_pos As Word , E_dat As Byte) Declare Sub Aufnahme_machen() Declare Sub Betriebsart() 'Alles fuer den EEPROM Const E_ctlw = &B1010_0000 Const E_ctlr = &B1010_0001 Config Scl = Portc.5 Config Sda = Portc.4 Dim E_ah As Byte Dim E_al As Byte Dim E_dat As Byte Dim Dat As Byte Dim E_addr As Word Dim Hoechste_adresse As Word Dim Eingabe As Byte Open "comd.7:19200,8,n,1" For Output As #1 Dim T1 As String * 1 Dim Eingabechar As Byte Dim Eingabechar2 As Byte Dim Eingabechar3 As Byte Dim Abbruch As Long Dim Ausgeben As Byte Dim Aufnahme_machen As Byte Dim Ausgabeformat As Byte 'Ausgabeformat '1=Zeichen 8Bit '2=Hex Dim Nur_datenausgeben As Byte Dim Datenfreigabe As Byte Dim Eepromspeicherung As Byte Dim Blitzlicht As Byte Dim Grosses_bild As Byte Ausgabeformat = 2 'Betriebsart waehlen Call Betriebsart() 'Setzen der Steuerleitungen für die Kamera Cts = 0 Rts = 0 If Nur_datenausgeben = 0 Then Print #1 , "Programm gestartet. Hallo." End If 'Einstellen der Baudrate auf 19200bps Baud = 19200 Open "comb.1:19200,8,n,1" For Input As #2 Do 'Test Aufnahme_machen = 0 Portd.2 = 1 Waitms 20 Eingabechar3 = Inkey(#2) If Eingabechar3 > 1 Then If Nur_datenausgeben = 0 Then Print #1 , "Eingabe: " ; Eingabechar3 End If 'Hier kann eine Abfrage erfolgen, welche Befehle abgearbeitet werden sollen - Funktion nur auf Anfrage Aufnahme_machen = 1 End If If Ausloeser = 0 Then If Nur_datenausgeben = 0 Then Print #1 , "Ausloeser betaetigt." End If Aufnahme_machen = 1 End If If Aufnahme_machen = 1 Then Close #2 E_addr = &H0010 Call Betriebsart() Call Aufnahme_machen() Open "comb.1:19200,8,n,1" For Input As #2 Aufnahme_machen = 0 End If Loop Sub E_write(byval E_addr As Word , Dat As Byte) E_ah = High(e_addr) E_al = Low(e_addr) I2cstart I2cwbyte E_ctlw I2cwbyte E_ah I2cwbyte E_al I2cwbyte Dat I2cstop Waitms 10 End Sub Sub E_read(byval E_addr As Word , E_dat As Byte) E_ah = High(e_addr) E_al = Low(e_addr) I2cstart I2cwbyte E_ctlw I2cwbyte E_ah I2cwbyte E_al I2cstart I2cwbyte E_ctlr I2crbyte E_dat , Nack I2cstop ' End Sub Sub Aufnahme_machen() 'Kamera aus Sleepmode wecken Cts = 1 Rts = 1 Led = 1 'Abwarten von AT&F Waitms 2500 Print "OK" 'ATE0 Waitms 500 Print "OK" 'Abwarten AT+CMEE=1 Waitms 500 Print "OK" 'Abwarten AT^SACD=1 Waitms 500 Print "OK" 'AT^SACD=2,"17" Waitms 500 Print "OK" 'AT^SACD=2,"17,00,2,IQP5 01.05" Waitms 500 Print "OK" 'AT^SACD=2,"17,04,2,3" Waitms 500 Print "OK" Waitms 500 If Blitzlicht = 0 Then Print "^SACD: 17,04,2,1" End If If Blitzlicht = 1 Then Print "^SACD: 17,03,2" Wait 15 End If 'AT^SACD=2,"17,04,OK" Waitms 2000 Print "OK" 'AT^SACD=2,"17,04,2,1" Waitms 2000 Print "OK" 'AT^SACD=2,"17,04,2,2,3057,34050" Waitms 5000 Print "OK" Waitms 2000 If Grosses_bild = 0 Then Print "^SACD: 17,01,2,1" End If If Grosses_bild = 1 Then Print "^SACD: 17,01,2,2" End If 'AT^SACD=2,"17,01,OK" Waitms 5000 Print "OK" If Nur_datenausgeben = 0 Then Print #1 , "Wechsele die Datenrate ..." End If Waitms 1000 Print "OK" Baud = 115200 Waitms 3000 'AT^SADT=1,115200 Print "CONNECT" Waitms 2000 Print "CONNECT" Waitms 2000 If Nur_datenausgeben = 0 Then Print #1 , "Beginne mit Datenausgabe ..." End If Abbruch = 0 Datenfreigabe = 0 If Eepromspeicherung = 0 Then Print #1 , "CAM_B" End If While Abbruch < 200000 Eingabechar2 = Ischarwaiting() While Eingabechar2 = 1 Eingabechar2 = Ischarwaiting() If Eingabechar2 = 1 Then Cts = 1 Eingabechar = Waitkey() If Eingabechar = 255 Then Datenfreigabe = 1 End If If Datenfreigabe = 1 Or Nur_datenausgeben = 0 Then If Eepromspeicherung = 0 Then If Ausgabeformat = 1 Then Print #1 , Chr(eingabechar); End If If Ausgabeformat = 2 Then Print #1 , Hex(eingabechar); Print #1 , " "; End If Else Dat = Eingabechar Call E_write(e_addr , Dat) Incr E_addr End If End If Abbruch = 0 End If Wend Cts = 0 Toggle Led Incr Abbruch Wend If Eepromspeicherung = 0 Then Print #1 , "CAM_E" End If If Eepromspeicherung = 1 Then Print #1 , "CAM_B" Hoechste_adresse = E_addr E_addr = &H0010 While E_addr < Hoechste_adresse Call E_read(e_addr , E_dat) Eingabe = E_dat If Ausgabeformat = 1 Then Print #1 , Chr(eingabe); End If If Ausgabeformat = 2 Then Print #1 , Hex(eingabe); Print #1 , " "; End If Incr E_addr Wend Print #1 , "CAM_E" End If Cts = 1 If Nur_datenausgeben = 0 Then Print #1 , "Daten wurden uebertragen" End If Led = 0 If Nur_datenausgeben = 0 Then Print #1 , "Kamera wird abgestellt" End If Rts = 0 If Nur_datenausgeben = 0 Then Print #1 , "Aufnahmemodus beendet" End If 'ab hier sind die Daten da End Sub Sub Betriebsart() 'Setzen der Inputs auf Ground Portc.1 = 1 Portc.2 = 1 Portc.3 = 1 print #1,"Pruefe Betriebsart" Waitms 20 If Cmd_01 = 0 And Cmd_02 = 0 Then Grosses_bild = 0 Eepromspeicherung = 0 Blitzlicht = 0 Nur_datenausgeben = 1 print #1,"Fall 1" End If If Cmd_01 = 1 And Cmd_02 = 0 Then Grosses_bild = 1 Eepromspeicherung = 0 Blitzlicht = 0 Nur_datenausgeben = 1 Print #1 , "Fall 2" End If If Cmd_01 = 0 And Cmd_02 = 1 Then Grosses_bild = 0 Eepromspeicherung = 1 Blitzlicht = 0 Nur_datenausgeben = 1 Print #1 , "Fall 3" End If If Cmd_01 = 1 And Cmd_02 = 1 Then Grosses_bild = 0 Eepromspeicherung = 0 Blitzlicht = 0 Nur_datenausgeben = 0 Print #1 , "Fall 4" End If End Sub