altos: Make sure we drop the SPI mutex when aborting cc1120 recv
[fw/altos] / src / drivers / ao_bufio.c
index 10b32ceb41a9fba365826e31cadadc0d11721cb6..70e30b67fee98897f22dd473b114b72063d991dc 100644 (file)
 #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 +45,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 +273,7 @@ ao_bufio_flush(void)
        ao_bufio_unlock();
 }
 
+#if BUFIO_COMMANDS
 static void
 ao_bufio_test_read(void)
 {
@@ -290,15 +296,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
 }