Get rid of BERTOS_FAT leftovers
[rmslog.git] / rmslog / main.c
index d4bb6a0a5641796d2cb6fb0e14278ac58d53dd64..206f421c9a887e33c32aa8ee951e003ee0624a7c 100644 (file)
@@ -10,6 +10,7 @@
  * console messages.
  */
 
+// Configuration
 #define FILE_NAME          "log.txt"
 #define FILE_OVERWRITE     1
 #define FILE_PREALLOC_SIZE 102400
 #include <cpu/irq.h>
 #include <cpu/power.h>
 
-#ifdef BERTOS_FAT
-       #include <drv/sd.h>
-       #include <fs/fat.h>
-#else
-       #include <FAT16/fat.h>
-       #include <FAT16/partition.h>
-       #include <FAT16/sd_raw.h>
-#endif
+#include <FAT16/fat.h>
+#include <FAT16/partition.h>
+#include <FAT16/sd_raw.h>
 
 #include <drv/ser.h>
 #include <drv/timer.h>
 #include <string.h>
 
 
+// Our serial port
 static Serial ser;
 
-#ifdef BERTOS_FAT
-       static Serial spi;
-       static FATFS fs;
-       static FatFile file;
-       static Sd sd;
-#else
-       struct fat_fs_struct        *fs;
-       struct partition_struct     *partition;
-       struct fat_dir_struct       *dd;
-       struct fat_dir_entry_struct dir_entry;
-       struct fat_file_struct      *fd;
-#endif
-
-
-#ifndef BERTOS_FAT
+// FAT global state
+struct fat_fs_struct        *fs;
+struct partition_struct     *partition;
+struct fat_dir_struct       *dd;
+struct fat_dir_entry_struct dir_entry;
+struct fat_file_struct      *fd;
+
+
 static void fat_init(void)
 {
        partition = partition_open(
@@ -89,7 +79,7 @@ static void fat_init(void)
                ASSERT(0); for(;;) {}
        }
 
-    //Open root directory
+    // Open root directory
     fat_get_dir_entry_of_path(fs, "/", &dir_entry);
     if (!(dd = fat_open_dir(fs, &dir_entry)))
        {
@@ -121,7 +111,6 @@ static struct fat_file_struct *open_file_in_dir(struct fat_fs_struct* fs, struct
     return fat_open_file(fs, &file_entry);
 }
 
-#endif // !BERTOS_FAT
 
 static void init(void)
 {
@@ -149,18 +138,20 @@ static void init(void)
        // input stream to the SD card
        //ser_setbaudrate(&ser, 19200);
 
-       /* Initialize LED driver */
+       // Initialize LED driver
        LED_INIT();
 
+       /*
+        * This gives avrdude some time to start reflashing in case
+        * the bug caused the program to do continous serial output
+        */
        timer_delay(1000);
-       kfile_printf(&ser.fd, "Hello, world!\r\n");
 
        DDRB |= BV(PORTB0) | BV(PORTB2) | BV(PORTB3) | BV(PORTB5);
        if (!sd_raw_init())
        {
                ASSERT(0); for(;;) {}
        }
-#endif
 
        fat_init();
 }