cfs-coffee-arch.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef CFS_COFFEE_ARCH_H
00043 #define CFS_COFFEE_ARCH_H
00044
00045 #include "contiki-conf.h"
00046
00047
00048
00049
00050 #if COFFEE_FILES==1 //1=eeprom for static file system
00051 #define COFFEE_AVR_EEPROM 1
00052 #define COFFEE_STATIC 1
00053 #elif COFFEE_FILES==2 //2=eeprom for full file system
00054 #define COFFEE_AVR_EEPROM 1
00055 #elif COFFEE_FILES==3 //3=program flash for static file system
00056 #define COFFEE_AVR_FLASH 1
00057 #define COFFEE_STATIC 1
00058 #else //4=program flash with full file system
00059 #define COFFEE_AVR_FLASH 1
00060 #endif
00061
00062 #ifdef COFFEE_AVR_EEPROM
00063 #include "dev/eeprom.h"
00064
00065
00066 #if COFFEE_ADDRESS==DEFAULT //Make can pass starting address with COFFEE_ADDRESS=0xnnnnnnnn
00067 #undef COFFEE_ADDRESS
00068 #ifdef CFS_EEPROM_CONF_OFFSET //Else use the platform default
00069 #define COFFEE_ADDRESS CFS_EEPROM_CONF_OFFSET
00070 #else //Use zero if no default defined
00071 #define COFFEE_ADDRESS 0
00072 #endif
00073 #endif
00074
00075
00076 #define COFFEE_PAGE_SIZE 16UL
00077 #define COFFEE_START COFFEE_ADDRESS
00078 #define COFFEE_SIZE ((3 * 1024U) - COFFEE_START)
00079
00080 #define COFFEE_SECTOR_SIZE (COFFEE_PAGE_SIZE*4)
00081 #define COFFEE_NAME_LENGTH 16
00082
00083 #define COFFEE_MAX_OPEN_FILES 4
00084 #define COFFEE_FD_SET_SIZE 8
00085 #define COFFEE_LOG_TABLE_LIMIT 16
00086 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE * 4)
00087 #define COFFEE_LOG_SIZE 128
00088
00089 typedef int16_t coffee_page_t;
00090 typedef uint16_t coffee_offset_t;
00091
00092 #define COFFEE_ERASE(sector) avr_eeprom_erase(sector)
00093 void avr_eeprom_erase(uint16_t sector);
00094
00095 #define COFFEE_WRITE(buf, size, offset) \
00096 eeprom_write(COFFEE_START + (offset), (unsigned char *)(buf), (size))
00097
00098 #define COFFEE_READ(buf, size, offset) \
00099 eeprom_read (COFFEE_START + (offset), (unsigned char *)(buf), (size))
00100
00101 #endif
00102
00103 #ifdef COFFEE_AVR_FLASH
00104
00105
00106
00107
00108
00109
00110 #define COFFEE_PAGE_SIZE (2*SPM_PAGESIZE)
00111 #ifndef COFFEE_ADDRESS //Make can pass starting address with COFFEE_ADDRESS=0xnnnnnnnn, default is 64KB for webserver
00112 #define COFFEE_ADDRESS 0x10000
00113 #endif
00114 #define COFFEE_PAGES (512-(COFFEE_ADDRESS/COFFEE_PAGE_SIZE)-32)
00115 #define COFFEE_START (COFFEE_ADDRESS & ~(COFFEE_PAGE_SIZE-1))
00116
00117 #define COFFEE_SIZE (COFFEE_PAGES*COFFEE_PAGE_SIZE)
00118
00119
00120 #define COFFEE_SECTOR_SIZE (COFFEE_PAGE_SIZE*1)
00121 #define COFFEE_NAME_LENGTH 16
00122
00123
00124
00125 #define FLASH_WORD_READS 1
00126
00127 #define FLASH_COMPLEMENT_DATA 0
00128
00129
00130
00131 #define COFFEE_MAX_OPEN_FILES 4
00132 #define COFFEE_FD_SET_SIZE 8
00133 #define COFFEE_LOG_TABLE_LIMIT 16
00134 #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE*1)
00135 #define COFFEE_MICRO_LOGS 0
00136 #define COFFEE_LOG_SIZE 128
00137
00138
00139
00140
00141
00142
00143
00144 #define coffee_page_t uint8_t
00145 #define CFS_CONF_OFFSET_TYPE uint16_t
00146
00147
00148 #define COFFEE_WRITE(buf, size, offset) \
00149 avr_flash_write(offset, (uint8_t *) buf, size)
00150
00151 #define COFFEE_READ(buf, size, offset) \
00152 avr_flash_read(offset, (uint8_t *) buf, size)
00153
00154 #define COFFEE_ERASE(sector) avr_flash_erase(sector)
00155
00156 void avr_flash_erase(coffee_page_t sector);
00157 void avr_flash_read (CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
00158 void avr_flash_write(CFS_CONF_OFFSET_TYPE addr, uint8_t *buf, CFS_CONF_OFFSET_TYPE size);
00159
00160 #define avr_httpd_fs_cpy(dest,addr,size) avr_flash_read((CFS_CONF_OFFSET_TYPE) addr, (uint8_t *)dest, (CFS_CONF_OFFSET_TYPE) size)
00161 char avr_httpd_fs_getchar(char *addr);
00162 char * avr_httpd_fs_strchr (char *ram, int character);
00163 int avr_httpd_fs_strcmp (char *addr,char *ram);
00164
00165
00166 #endif
00167
00168 #endif