]> hackdaworld.org Git - my-code/arm.git/commitdiff
first pseudo flash filesystem code (not working yet)
authorhackbard <hackbard@staubsauger.localdomain>
Sun, 9 Sep 2007 01:12:45 +0000 (03:12 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sun, 9 Sep 2007 01:12:45 +0000 (03:12 +0200)
betty/Makefile
betty/betty.c
betty/betty.h
betty/display.c
betty/display.h
betty/flash.c
betty/flash.h
betty/pffs.c [new file with mode: 0644]
betty/pffs.h [new file with mode: 0644]

index 3883fce1bb1af38766ceca1117e0e3928ebe0019..b7a261611f1e6ddebb2df61db62871b8e52339a1 100644 (file)
@@ -19,7 +19,7 @@ HOST_TARGET = lpcload fwdump
 CROSS_TARGET = fwbc.hex fwflash.hex betty.hex
 
 # betty deps
-BETTY_DEPS = system.o uart.o buttons.o spi.o display.o flash.o
+BETTY_DEPS = system.o uart.o buttons.o spi.o display.o flash.o pffs.o
 
 # all projects
 all: $(HOST_TARGET) $(CROSS_TARGET)
index 45e6ae741c513c46f30f8337363e74a43f1e9be9..859860a03e4ce8e9347afe3c69fb26c95c36bac8 100644 (file)
@@ -31,7 +31,7 @@ int main() {
        uart0_init();
 
        /* display init */
-       bl_init();
+       display_bl_init();
 
        /* button init */
        button_init(&button);
@@ -51,7 +51,7 @@ int main() {
        uart0_send_string(announce);
 
        /* toggle backlight */
-       bl_toggle();
+       display_bl_toggle();
 
        //addr=0x82000000;
        flash_sector_erase(BANK2,0);
@@ -64,7 +64,7 @@ int main() {
                if(button_get_event(&button)) {
                        uart0_send_string(announce);
                        if(button.key[0]==BUTTON_POWER) {
-                               bl_toggle();
+                               display_bl_toggle();
                                flash_write_buf(addr,(u16 *)announce,42);
                                addr+=64;
                        }
index 33e64d5f522d4254afaa6f4d61cf00df7ce24aa9..761f74d76756acc7542c3a64d36f280e35f3a4f5 100644 (file)
@@ -25,6 +25,7 @@
 #include "spi.h"
 #include "display.h"
 #include "flash.h"
+#include "pffs.h"
 
 /*
  * defines
index 07fb923f5b95d3b99596f42b32b0908d8ecfe33d..210cd17766cb92358a9736f7228ac29f0f166492 100644 (file)
@@ -16,13 +16,13 @@ void display_init(void) {
        BCFG1=0x00000c42;
 }
 
-void bl_init(void) {
+void display_bl_init(void) {
 
        PINSEL0&=~(1<<9|(1<<8));
        IODIR0|=(1<<4);
 }
 
-void bl_toggle(void) {
+void display_bl_toggle(void) {
 
        if(IOPIN0&(1<<4))
                IOCLR0=(1<<4);
@@ -30,12 +30,12 @@ void bl_toggle(void) {
                IOSET0=(1<<4);
 }
 
-void bl_on(void) {
+void display_bl_on(void) {
 
        IOCLR0=(1<<4);
 }
 
-void bl_off(void) {
+void display_bl_off(void) {
 
        IOSET0=(1<<4);
 }
index cad2e7646cf770e7768d4dd3818df54cc7b07a34..afaa399a22a1faf1660e70ccde91801bdb54de0d 100644 (file)
@@ -12,9 +12,9 @@
 #include "types.h"
 
 /* function prototypes */
-void bl_init(void);
-void bl_toggle(void);
-void bl_on(void);
-void bl_off(void);
+void display_bl_init(void);
+void display_bl_toggle(void);
+void display_bl_on(void);
+void display_bl_off(void);
 
 #endif
index 8d9c02a92e0685b2f878b3b7b6b341fe01a30f75..64488e22baba0688782fdcdfcb017224ffe63e20 100644 (file)
@@ -10,7 +10,8 @@
 /*
  * sector addresses
  */
-static unsigned long sector_address[19]={
+
+unsigned long sector_address[19]={
        0x00000,0x02000,0x03000,0x04000,0x08000,
        0x10000,0x18000,
        0x20000,0x28000,
@@ -96,6 +97,24 @@ void flash_sector_erase(u8 bank,u8 sector) {
        return;
 }
 
+int flash_sec_erase(u32 addr) {
+
+       u32 a18_12;
+       u32 base;
+
+       a18_12=addr&0x00000fffff;
+       base=addr&0xff000000;
+       
+       *((volatile u16 *)(base|(0x555<<1)))=0xaa;
+       *((volatile u16 *)(base|(0x2aa<<1)))=0x55;
+       *((volatile u16 *)(base|(0x555<<1)))=0x80;
+       *((volatile u16 *)(base|(0x555<<1)))=0xaa;
+       *((volatile u16 *)(base|(0x2aa<<1)))=0x55;
+       *((volatile u16 *)(base|(a18_12<<1)))=0x30;
+
+       return 0;
+}
+
 void flash_chip_erase(u8 bank) {
 
        u8 status;
index 8683b93c87182ad2d021b2eb3b2223124a1cdece..1bb1b2edfaccd28f1d1d04df1fafe75ce089ec94 100644 (file)
@@ -36,6 +36,7 @@
 void flash_init(void);
 void flash_reset(u8 bank);
 void flash_sector_erase(u8 flash,u8 sector);
+int flash_sec_erase(u32 addr);
 void flash_chip_erase(u8 bank);
 void flash_unlock_bypass(u8 bank);
 void flash_unlock_bypass_reset(u8 bank);
diff --git a/betty/pffs.c b/betty/pffs.c
new file mode 100644 (file)
index 0000000..995e108
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * pffs.c - pseudo flash filesystem
+ *
+ * author: hackbard@hackdaworld.org
+ *
+ */
+
+#include "pffs.h"
+
+/*
+ * functions
+ */
+
+int pffs_flash_register(t_pffs *pffs,u32 base_addr,u8 sec_num,u32 *sec_addr,
+                        u8 dmin,u8 dmax,u8 index1,u8 index2,
+                        int (*fw)(u32 addr,u16 *buf,int len),
+                       int (*fr)(u32 addr,u16 *buf,int len),
+                       int (*fe)(u32 addr)) {
+
+       pffs->base_addr=base_addr;
+       pffs->sec_num=sec_num;
+       pffs->sec_addr=sec_addr;
+       pffs->fw=fw;
+       pffs->fr=fr;
+       pffs->fe=fe;
+
+       pffs->state|=PFFS_REGISTERED;
+
+       return 0;
+}
+
+int pffs_init(t_pffs *pffs) {
+
+       if(!(pffs->state&PFFS_REGISTERED))
+               return -1;
+
+       return 0;
+}
+
diff --git a/betty/pffs.h b/betty/pffs.h
new file mode 100644 (file)
index 0000000..92b4821
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * pfs.h - pseudo flash filesystem header file
+ *
+ * author: hackbard@hackdaworld.org
+ *
+ */
+
+#ifndef PFFS_H
+#define PFFS_H
+
+#include "lpc2xxx.h"
+#include "types.h"
+
+/* defines */
+
+#define PFFS_REGISTERED                (1<<0)
+
+/* type definitions */
+
+typedef struct s_pffs {
+       /* flash specs */
+       u32 base_addr;
+       u8 sec_num;
+       u32 *sec_addr;
+       /* flash write, read and sector erase function pointers */
+       int (*fw)(u32 addr,u16 *buf,int len);
+       int (*fr)(u32 addr,u16 *buf,int len);
+       int (*fe)(u32 addr);
+       /* pffs internal variables */
+       u8 state;
+       u8 sec_num_data_min;
+       u8 sec_num_data_max;
+       u8 sec_num_index[2];
+       u32 data_ptr;
+       u32 index_ptr;
+} t_pffs;
+
+/* function prototypes */
+
+#endif