42 #ifndef CFS_COFFEE_ARCH_H
43 #define CFS_COFFEE_ARCH_H
45 #include "contiki-conf.h"
50 #if COFFEE_FILES==1 //1=eeprom for static file system
51 #define COFFEE_AVR_EEPROM 1
52 #define COFFEE_STATIC 1
53 #elif COFFEE_FILES==2 //2=eeprom for full file system
54 #define COFFEE_AVR_EEPROM 1
55 #elif COFFEE_FILES==3 //3=program flash for static file system
56 #define COFFEE_AVR_FLASH 1
57 #define COFFEE_STATIC 1
58 #else //4=program flash with full file system
59 #define COFFEE_AVR_FLASH 1
62 #ifdef COFFEE_AVR_EEPROM
66 #if COFFEE_ADDRESS==DEFAULT //Make can pass starting address with COFFEE_ADDRESS=0xnnnnnnnn
68 #ifdef CFS_EEPROM_CONF_OFFSET //Else use the platform default
69 #define COFFEE_ADDRESS CFS_EEPROM_CONF_OFFSET
70 #else //Use zero if no default defined
71 #define COFFEE_ADDRESS 0
76 #define COFFEE_PAGE_SIZE 16UL
77 #define COFFEE_START COFFEE_ADDRESS
78 #define COFFEE_SIZE ((3 * 1024U) - COFFEE_START)
80 #define COFFEE_SECTOR_SIZE (COFFEE_PAGE_SIZE*4)
81 #define COFFEE_NAME_LENGTH 16
83 #define COFFEE_MAX_OPEN_FILES 4
84 #define COFFEE_FD_SET_SIZE 8
85 #define COFFEE_LOG_TABLE_LIMIT 16
86 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE * 4)
87 #define COFFEE_LOG_SIZE 128
89 typedef int16_t coffee_page_t;
90 typedef uint16_t coffee_offset_t;
92 #define COFFEE_ERASE(sector) avr_eeprom_erase(sector)
93 void avr_eeprom_erase(uint16_t sector);
95 #define COFFEE_WRITE(buf, size, offset) \
96 eeprom_write(COFFEE_START + (offset), (unsigned char *)(buf), (size))
98 #define COFFEE_READ(buf, size, offset) \
99 eeprom_read (COFFEE_START + (offset), (unsigned char *)(buf), (size))
103 #ifdef COFFEE_AVR_FLASH
110 #define COFFEE_PAGE_SIZE (2*SPM_PAGESIZE)
111 #ifndef COFFEE_ADDRESS //Make can pass starting address with COFFEE_ADDRESS=0xnnnnnnnn, default is 64KB for webserver
112 #define COFFEE_ADDRESS 0x10000
114 #define COFFEE_PAGES (512-(COFFEE_ADDRESS/COFFEE_PAGE_SIZE)-32)
115 #define COFFEE_START (COFFEE_ADDRESS & ~(COFFEE_PAGE_SIZE-1))
117 #define COFFEE_SIZE (COFFEE_PAGES*COFFEE_PAGE_SIZE)
120 #define COFFEE_SECTOR_SIZE (COFFEE_PAGE_SIZE*1)
121 #define COFFEE_NAME_LENGTH 16
125 #define FLASH_WORD_READS 1
127 #define FLASH_COMPLEMENT_DATA 1
131 #define COFFEE_MAX_OPEN_FILES 4
132 #define COFFEE_FD_SET_SIZE 8
133 #define COFFEE_LOG_TABLE_LIMIT 16
134 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE*1)
135 #define COFFEE_MICRO_LOGS 0
136 #define COFFEE_LOG_SIZE 128
144 #define coffee_page_t uint8_t
145 #define CFS_CONF_OFFSET_TYPE uint16_t
148 #define COFFEE_WRITE(buf, size, offset) \
149 avr_flash_write(offset, (uint8_t *) buf, size)
151 #define COFFEE_READ(buf, size, offset) \
152 avr_flash_read(offset, (uint8_t *) buf, size)
154 #define COFFEE_ERASE(sector) avr_flash_erase(sector)
156 void avr_flash_erase(coffee_page_t sector);
157 void avr_flash_read (CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
158 void avr_flash_write(CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
160 #define avr_httpd_fs_cpy(dest,addr,size) avr_flash_read((CFS_CONF_OFFSET_TYPE) addr, (uint8_t *)dest, (CFS_CONF_OFFSET_TYPE) size)
161 char avr_httpd_fs_getchar(
char *addr);
162 char * avr_httpd_fs_strchr (
char *ram,
int character);
163 int avr_httpd_fs_strcmp (
char *addr,
char *ram);
167 int coffee_file_test(
void);