1

Dependencies:   MODSERIAL USBDevice USBMSD_SD V09_01h

Dependents:   V09_01h

Files at this revision

API Documentation at this revision

Comitter:
rs27
Date:
Sat Jan 03 15:27:00 2015 +0000
Parent:
0:44b579c983e0
Child:
2:3f8208c014d2
Commit message:
123;

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
com_0.lib Show annotated file Show diff for this revision Revisions of this file
info.txt Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
menu.lib Show annotated file Show diff for this revision Revisions of this file
mon.lib Show annotated file Show diff for this revision Revisions of this file
myTextLCD.lib Show annotated file Show diff for this revision Revisions of this file
timer0.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#180e968a751e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/mbed/code/SDFileSystem/#81301febc5d3
--- a/USBDevice.lib	Fri Mar 01 13:29:13 2013 +0000
+++ b/USBDevice.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
+http://mbed.org/users/mbed_official/code/USBDevice/#0c6524151939
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/com_0.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+com_0#3eabf0cac42a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/info.txt	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,72 @@
+Das Zusammenspiel zwischen dem USB Bus, der SD Karte und der Seriellen Schnittstelle 
+hat nicht richtig funktioniert. 
+
+Sobald die SD Karte mit MODSERIAL verwendet wird, geht die SD Karte nicht mehr. Mit 
+der Umstellung auf BufferedSerial hat die SD Karte wieder funktioniert
+
+SDFileSystem Revison 17 März 2014, screamer
+
+Ein weiteres Problem ist das Auslesen der Zeit für eine Datei. Wird die Zeit ausgelesen
+hängt sich die SD Karte auf. Das Auslesen der Zeit ist somit im mon.cpp auskommentiert.
+
+SD Formatieren >> FAT16 und FAT32 gehen mit dem SD File System. Mit USB geht nur FAT16 und Standart Formatierung
+sind dann 32k Sektoren.
+
+
+//-----------------------------------------------------------------------------
+// monitor Aufruf dir
+//
+// weiter Infos siehe auch
+// http://elm-chan.org/fsw/ff/00index_e.html
+//
+// Start node to be scanned (also used as work area)
+FRESULT FATFileSystem::list_files (const char *name)
+{
+    FRESULT res;
+    FILINFO fno;
+    FATFS_DIR dir;
+    int i;
+    char *fn;
+ 
+// some code
+    printf("\nscan_files Line 152");
+#if _USE_LFN
+    static char lfn[_MAX_LFN + 1];
+    fno.lfname = lfn;
+    fno.lfsize = sizeof lfn;
+#endif
+    
+    printf("\nscan_files Line 159");
+    
+    res = f_opendir(&dir, name);                           // Open the directory
+    printf("\nscan_files Line 162");
+    if (res == FR_OK) {
+        i = strlen(name);
+        for (;;) {
+            res = f_readdir(&dir, &fno);                   // Read a directory item 
+            if (res != FR_OK || fno.fname[0] == 0) break;  // Break on error or end of dir 
+            if (fno.fname[0] == '.') continue;             // Ignore dot entry
+#if _USE_LFN
+            fn = *fno.lfname ? fno.lfname : fno.fname;
+#else
+            fn = fno.fname;
+#endif
+            if (fno.fattrib & AM_DIR) {                    // It is a directory 
+         //       sprintf(&name[i], "/%s", fn);
+         //       res = scan_files(name);
+         //       if (res != FR_OK) break;
+         //       path[i] = 0;
+            } else {                                       // It is a file. 
+                printf("%s/%s\n", name, fn);
+            }
+        }
+    }
+    return res;
+    
+----------------------------------------------------------------------------------------------------------------------------
+28.10.2014
+Nach eine Reset und danach kommen ab und zu Zeichen auf der seriellen Schnittselle an. Derzeit ist unklar woher die kommen. 
+Das hat sich geklärt. Die Zeichen kommen durch mangelhafte RS2323 Treiber. Nach dem Tausch des Treibers war das Problem behoben.
+
+Die verwendeten Treiber hatten ein Problem mit der Erzeugung der +- 15V. Die Spannung ist in der Beschaltung zeitweise eingebrochen
+und hat damit ein Übersprechen auf die Empfangsleitung erzeugt. Unklar ist jedoch, warum sich diese Treiberbausteine so verhalten.
--- a/main.cpp	Fri Mar 01 13:29:13 2013 +0000
+++ b/main.cpp	Sat Jan 03 15:27:00 2015 +0000
@@ -1,8 +1,162 @@
 #include "mbed.h"
 #include "USBMSD_SD.h"
- 
-USBMSD_SD sd(PTD2, PTD3, PTD1, PTD0);
+#include "SDFileSystem.h"
+#include "MODSERIAL.h"
+#include "mon.h"
+#include "com.h"
+#include "menu.h"
+#include "myTextLCD.h"
+#include "timer0.h"
+
+#define LED_OFF 1
+#define LED_ON  0
+#define COM_LINE_LEN 128              // maximale Länge der Eingabezeile  
+#define TEL_SIZE 10
+
+#define TIMER0_NUM_COUNTDOWNTIMERS  25
+   
+// LCD's für Anzeige
+DigitalOut led1(PTB18);
+DigitalOut led2(PTB19);
+DigitalOut led3(PTB17);
+
+// Taster für die Eingabe
+DigitalIn S1(PTC7);
+DigitalIn S2(PTC8);
+DigitalIn S3(PTC9);
+DigitalIn S4(PTC10);
+DigitalIn S5(PTC11);
+
+timer0 down_timer;          // Timer für Zeitsteuerung
+
+MODSERIAL pc(USBTX,USBRX); 
+
+SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); 
+
+menu menu_var;
+
+//MODSERIAK uart1(PTC4, PTC3, 512); // tx, rx
+MODSERIAL uart1(PTC4, PTC3); // tx, rx
+
+TextLCD lcd(PTE24, PTE25, PTE20, PTE21, PTE22, PTE23); // rs, e, d4-d7
+PwmOut lcd_kontrast(PTA5); // Kontrast wird über PWM gesteuert
+DigitalOut lcd_bl(PTE29);  // Hintergrundbeleuchtung
+
+monitor mon;
+
+uint8_t tasten, tasten_old;
+
+//-----------------------------------------------------------------------------
+// main
+//
+//
+int main() 
+{
+    tasten = 0; 
+    tasten_old = 0; 
+    
+    S1.mode(PullUp);
+    S2.mode(PullUp);
+    S3.mode(PullUp);
+    S4.mode(PullUp);
+    S5.mode(PullUp);
+       
+    // pc.printf("\ntimer0::set_t = %s", buffer); 
+    
+    lcd_bl = 6;         // Hintergrundbeleuchtung LCD Anzeige einschalten
+
+    // die Zeiten müssen so kurz sein, da die LCD Anzeige sonst flackert
+    lcd_kontrast.period_us(100);          // 100µs Periode
+    lcd_kontrast.pulsewidth_us(30);       // 30 µs Pulszeit    
  
-int main() {
-    while(1);
+    // pc ist die USB Schnittstelle des Debuggers
+    pc.baud(56700);    
+    pc.printf("\nSD_USB_FS V09.01g");   
+    pc.printf("\n V08 was compiled on %s  %s \n", __DATE__,__TIME__);
+       
+    // auf USB Mode umschalten
+    S5.mode(PullUp);
+    
+    if (S5 == 0)
+    {
+        //          0123456789012345
+        lcd.printf(" -- USB Mode -- ");
+        lcd.writeLCD();
+        
+        USBMSD_SD msd(PTD2, PTD3, PTD1, PTD0);
+        while(1);
+    }
+      
+    //          0123456789012345
+    lcd.printf(" - nomal Mode - ");  
+    lcd.writeLCD();
+    pc.printf("\nnormal SD mode\n");
+
+    // uart1 ist die Schnittstelle zur microSPS    
+    uart1.baud(115200);
+    com_init();
+        
+    down_timer.SetCountdownTimer(0,1,50);  // Timer für Tasten
+    down_timer.SetCountdownTimer(1,1,500); // Timer für LED
+    down_timer.SetCountdownTimer(2,1,1000);// Timer für die Ausgabe der Daten
+ 
+    while(1)
+    {
+        mon.monPC();
+        com_line();
+        
+        //--------------------------------------------------------------------------
+        // LED für Statusanzeige              
+       
+        if (down_timer.GetTimerStatus(1) == 0)
+        {
+            down_timer.SetCountdownTimer(1,1,500);    // alle 500ms                                          
+            led1 = !led1;           // blaue oder gründe LED
+            //led2 = !led2;
+        }    
+        
+        //--------------------------------------------------------------------------
+        // Die Tasten alle 10ms abfragen und Telegramm senden falls Tasten gedrückt            
+
+        if (down_timer.GetTimerStatus(0) == 0)
+        {
+            down_timer.SetCountdownTimer(0,1,10);  // alle 10ms
+            // Tasten abfragen
+            if (S1 == 0) tasten |= 0x01; else tasten &= ~0x01;
+            if (S2 == 0) tasten |= 0x02; else tasten &= ~0x02;
+            if (S3 == 0) tasten |= 0x04; else tasten &= ~0x04;
+            if (S4 == 0) tasten |= 0x08; else tasten &= ~0x08;
+            if (S5 == 0) tasten |= 0x10; else tasten &= ~0x10;
+            
+            //---------------------------------------------------------------------------
+            // Tastatur auswerten und Ergebnis senden
+            if (tasten != tasten_old)
+            {
+              uart1.putc(0xE5);
+              uart1.putc(0x02);
+              uart1.putc(0x05);         // Telegramm für Tasten 
+              uart1.putc(0x01);         // Anzahl der Nutzdaten
+              uart1.putc(tasten);       // Tasteninformation
+              uart1.putc(0x00);         // Abschlusszeichen
+              
+              tasten_old = tasten; 
+              pc.printf("\nTaste %02x",tasten);
+            }
+        } 
+        
+        //--------------------------------------------------------------------------
+        // Uhrzeit abfragen            
+        
+        if (down_timer.GetTimerStatus(2) == 0)
+        {
+            down_timer.SetCountdownTimer(2,2,60);    // alle 60s                                          
+            
+            uart1.putc(0xE5);         // Startzeichen
+            uart1.putc(0x02);         // Startzeichen
+            uart1.putc(0x06);         // Telegramm für Zeitabfrage 
+            uart1.putc(0x00);         // Anzahl der Nutzdaten
+            uart1.putc(0x00);         // Abschlusszeichen
+        }
+                
+    } // while[1]
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#46fbf889ec9e
--- a/mbed.bld	Fri Mar 01 13:29:13 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/menu.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+menu#4bb4785f235c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mon.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+mon#401f3ae5ab50
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/myTextLCD.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#87fdf4a45de7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/timer0.lib	Sat Jan 03 15:27:00 2015 +0000
@@ -0,0 +1,1 @@
+timer0#8d3e2b74d1d5