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 #elif COFFEE_FILES==4 //4=program flash with full file system
59 #define COFFEE_AVR_FLASH 1
61 #define COFFEE_AVR_EXTERNAL 1
64 #ifdef COFFEE_AVR_EEPROM
68 #if COFFEE_ADDRESS==DEFAULT //Make can pass starting address with COFFEE_ADDRESS=0xnnnnnnnn
70 #ifdef CFS_EEPROM_CONF_OFFSET //Else use the platform default
71 #define COFFEE_ADDRESS CFS_EEPROM_CONF_OFFSET
72 #else //Use zero if no default defined
73 #define COFFEE_ADDRESS 0
78 #define COFFEE_PAGE_SIZE 16UL
79 #define COFFEE_START COFFEE_ADDRESS
80 #define COFFEE_SIZE ((3 * 1024U) - COFFEE_START)
82 #define COFFEE_SECTOR_SIZE (COFFEE_PAGE_SIZE*4)
83 #define COFFEE_NAME_LENGTH 16
85 #define COFFEE_MAX_OPEN_FILES 4
86 #define COFFEE_FD_SET_SIZE 8
87 #define COFFEE_LOG_TABLE_LIMIT 16
88 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE * 4)
89 #define COFFEE_LOG_SIZE 128
91 typedef int16_t coffee_page_t;
92 typedef uint16_t coffee_offset_t;
94 #define COFFEE_ERASE(sector) avr_eeprom_erase(sector)
95 void avr_eeprom_erase(uint16_t sector);
97 #define COFFEE_WRITE(buf, size, offset) \
98 eeprom_write(COFFEE_START + (offset), (unsigned char *)(buf), (size))
100 #define COFFEE_READ(buf, size, offset) \
101 eeprom_read (COFFEE_START + (offset), (unsigned char *)(buf), (size))
105 #ifdef COFFEE_AVR_FLASH
112 #define COFFEE_PAGE_SIZE (2*SPM_PAGESIZE)
113 #ifndef COFFEE_ADDRESS //Make can pass starting address with COFFEE_ADDRESS=0xnnnnnnnn, default is 64KB for webserver
114 #define COFFEE_ADDRESS 0x10000
116 #define COFFEE_PAGES (512-(COFFEE_ADDRESS/COFFEE_PAGE_SIZE)-32)
117 #define COFFEE_START (COFFEE_ADDRESS & ~(COFFEE_PAGE_SIZE-1))
119 #define COFFEE_SIZE (COFFEE_PAGES*COFFEE_PAGE_SIZE)
122 #define COFFEE_SECTOR_SIZE (COFFEE_PAGE_SIZE*1)
123 #define COFFEE_NAME_LENGTH 16
127 #define FLASH_WORD_READS 1
129 #define FLASH_COMPLEMENT_DATA 1
133 #define COFFEE_MAX_OPEN_FILES 4
134 #define COFFEE_FD_SET_SIZE 8
135 #define COFFEE_LOG_TABLE_LIMIT 16
136 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE*1)
137 #define COFFEE_MICRO_LOGS 0
138 #define COFFEE_LOG_SIZE 128
146 #define coffee_page_t uint8_t
147 #define CFS_CONF_OFFSET_TYPE uint16_t
150 #define COFFEE_WRITE(buf, size, offset) \
151 avr_flash_write(offset, (uint8_t *) buf, size)
153 #define COFFEE_READ(buf, size, offset) \
154 avr_flash_read(offset, (uint8_t *) buf, size)
156 #define COFFEE_ERASE(sector) avr_flash_erase(sector)
158 void avr_flash_erase(coffee_page_t sector);
159 void avr_flash_read (CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
160 void avr_flash_write(CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
162 #define avr_httpd_fs_cpy(dest,addr,size) avr_flash_read((CFS_CONF_OFFSET_TYPE) addr, (uint8_t *)dest, (CFS_CONF_OFFSET_TYPE) size)
163 char avr_httpd_fs_getchar(
char *addr);
164 char * avr_httpd_fs_strchr (
char *ram,
int character);
165 int avr_httpd_fs_strcmp (
char *addr,
char *ram);
171 #ifdef COFFEE_AVR_EXTERNAL
174 #define COFFEE_PAGE_SIZE 528UL
175 #ifndef COFFEE_ADDRESS
176 #define COFFEE_ADDRESS 0x0
178 #define COFFEE_PAGES 4096UL
179 #define COFFEE_START (COFFEE_ADDRESS)
180 #define COFFEE_SIZE 2162688UL
183 #define COFFEE_SECTOR_SIZE COFFEE_PAGE_SIZE
184 #define COFFEE_NAME_LENGTH 16
188 #define COFFEE_MAX_OPEN_FILES 6
189 #define COFFEE_FD_SET_SIZE 8
190 #define COFFEE_LOG_TABLE_LIMIT 16
191 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE*1)
192 #define COFFEE_MICRO_LOGS 0
193 #define COFFEE_LOG_SIZE 128
201 #define coffee_page_t uint16_t
202 #define CFS_CONF_OFFSET_TYPE uint32_t
204 #define COFFEE_WRITE(buf, size, offset) \
205 external_flash_write((CFS_CONF_OFFSET_TYPE) offset, (uint8_t *) buf, (CFS_CONF_OFFSET_TYPE) size)
207 #define COFFEE_READ(buf, size, offset) \
208 external_flash_read((CFS_CONF_OFFSET_TYPE) offset, (uint8_t *) buf, (CFS_CONF_OFFSET_TYPE) size)
210 #define COFFEE_ERASE(sector) \
211 external_flash_erase((coffee_page_t) sector)
213 void external_flash_write_page(coffee_page_t page, CFS_CONF_OFFSET_TYPE offset, uint8_t * buf, CFS_CONF_OFFSET_TYPE size);
215 void external_flash_write(CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
217 void external_flash_read(CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
219 void external_flash_erase(coffee_page_t sector);
223 int coffee_file_test(
void);