first pseudo flash filesystem code (not working yet)
[my-code/arm.git] / betty / betty.c
index f2ce2e5..859860a 100644 (file)
@@ -5,9 +5,71 @@
  *
  */
 
+/* includes */
+#include "betty.h"
+
+/*
+ * functions
+ */
+
+#define cc1100_init    spi1_init(8,SPI_MASTER,8)
+
+/*
+ * main function
+ */
+
 int main() {
 
+       char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
+       t_button button;
+       u32 addr;
+
+       /* system init */
+       pll_init();
+
+       /* uart init */
+       uart0_init();
+
+       /* display init */
+       display_bl_init();
+
+       /* button init */
+       button_init(&button);
+       button_set_retries(&button,100);
+
+       /* flash init */
+       flash_init();
+
+       /*
+        * start it ...
+        */
+
+       /* pause - seems to not work if running from flash! (?) */
+       pause(0xffffff);
+
+       /* announce */
+       uart0_send_string(announce);
+
+       /* toggle backlight */
+       display_bl_toggle();
+
+       //addr=0x82000000;
+       flash_sector_erase(BANK2,0);
+       addr=FLASH_BANK2;
+
+       while(1) {
+               pause(0x0fffff);
 
+               /* button test! */
+               if(button_get_event(&button)) {
+                       uart0_send_string(announce);
+                       if(button.key[0]==BUTTON_POWER) {
+                               display_bl_toggle();
+                               flash_write_buf(addr,(u16 *)announce,42);
+                               addr+=64;
+                       }
+               }
+       }
 
        return 0;
 }