first cut at turnon scripts for EasyTimer v2
[fw/altos] / src / drivers / ao_bufio.c
index 10b32ceb41a9fba365826e31cadadc0d11721cb6..f212da53b36088491f6c91bf1f5d8287d57f9bd6 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 #include "ao.h"
 #endif
 
+/* Include bufio commands */
+#ifndef AO_FAT_TEST
+#define BUFIO_COMMANDS 0
+#endif
+
 #include "ao_sdcard.h"
 #include "ao_bufio.h"
 
-#define AO_NUM_BUF             4
+#define AO_NUM_BUF             16
 #define AO_BUFSIZ              512
 
 struct ao_bufio {
@@ -40,7 +46,7 @@ static uint8_t                ao_bufio_mutex;
 #if 0
 #define DBG(...) printf(__VA_ARGS__)
 #else
-#define DBG(...)
+#define DBG(...) (void) 0
 #endif
 
 static inline void
@@ -268,6 +274,7 @@ ao_bufio_flush(void)
        ao_bufio_unlock();
 }
 
+#if BUFIO_COMMANDS
 static void
 ao_bufio_test_read(void)
 {
@@ -290,15 +297,26 @@ static const struct ao_cmds ao_bufio_cmds[] = {
        { ao_bufio_test_read,   "q\0Test bufio read" },
        { 0, NULL },
 };
+#endif
 
 void
-ao_bufio_init(void)
+ao_bufio_setup(void)
 {
        int b;
 
-       for (b = 0; b < AO_NUM_BUF; b++)
+       for (b = 0; b < AO_NUM_BUF; b++) {
+               ao_bufio[b].dirty = 0;
+               ao_bufio[b].busy = 0;
                ao_bufio[b].block = 0xffffffff;
-       ao_sdcard_init();
+       }
+}
 
+void
+ao_bufio_init(void)
+{
+       ao_bufio_setup();
+       ao_sdcard_init();
+#if BUFIO_COMMANDS
        ao_cmd_register(&ao_bufio_cmds[0]);
+#endif
 }