EVE 1.0
cfs-coffee-arch.h
1 #ifndef CFS_COFFEE_ARCH_H_INCLUDED
2 #define CFS_COFFEE_ARCH_H_INCLUDED
3 
4 #include <stdint.h>
5 #include "contiki-conf.h"
6 
7 /* TODO: Make it configurable */
8 #include "dev/spi-memory.h"
9 #include "dev/eve-module.h"
10 #include "board.h" // XXX: DT!! FIXME: Dependency to the project: flash size
11 
12 /* Page size in bytes */
13 #define COFFEE_PAGE_SIZE (EXT_FLASH_PAGE_SIZE)
14 
15 /* Sector size in bytes */
16 #define COFFEE_SECTOR_SIZE (EXT_FLASH_BLOCK_SIZE)
17 
18 /* Index of the first sector of the FS image on flash */
19 #ifndef COFFEE_START_SECTOR
20  #define COFFEE_START_SECTOR (0)
21 #endif
22 
23 /* Offset in bytes to the first byte of the FS image on flash */
24 #define COFFEE_START (COFFEE_START_SECTOR * COFFEE_SECTOR_SIZE)
25 
26 /* FS image size in bytes */
27 #ifndef COFFEE_SIZE
28  #define COFFEE_SIZE (EXT_FLASH_SIZE - COFFEE_START)
29 #endif
30 
31 /* Length of the file name field */
32 #ifndef COFFEE_NAME_LENGTH
33  #define COFFEE_NAME_LENGTH (32)
34 #endif
35 
36 /* These are used internally by the coffee file system */
37 #ifndef COFFEE_MAX_OPEN_FILES
38  #define COFFEE_MAX_OPEN_FILES (4)
39 #endif
40 
41 #ifndef COFFEE_FD_SET_SIZE
42  #define COFFEE_FD_SET_SIZE (8)
43 #endif
44 
45 #ifndef COFFEE_DYN_SIZE
46  #define COFFEE_DYN_SIZE (COFFEE_PAGE_SIZE * 4)
47 #endif
48 
49 #ifndef COFFEE_LOG_TABLE_LIMIT
50  #define COFFEE_LOG_TABLE_LIMIT (256)
51 #endif
52 
53 #ifndef COFFEE_LOG_SIZE
54  #define COFFEE_LOG_SIZE (8192)
55 #endif
56 
57 /* Up to 16 MBytes for 256 byte pages */
58 #define coffee_page_t uint16_t
59 
60 #define COFFEE_WRITE(buf, size, offset) \
61  flash_write(COFFEE_START + offset, buf, size)
62 
63 #define COFFEE_READ(buf, size, offset) \
64  flash_read(COFFEE_START + offset, buf, size)
65 
66 #define COFFEE_ERASE(sector) \
67  flash_erase(COFFEE_START_SECTOR + sector)
68 
69 /* Async format status */
70 enum coffee_async_format_status_t
71 {
72  COFFEE_ASYNC_FORMAT_IDLE,
73  COFFEE_ASYNC_FORMAT_ONGOING,
74 };
75 
76 void flash_read(uint32_t address, void *data, uint32_t length);
77 
78 void flash_write(uint32_t address, const void *data, uint32_t length);
79 
80 #define flash_erase(sector) \
81  SpiMemoryEraseBlock(&ExtFlash, sector)
82 
83 void coffee_async_format(void);
84 
85 void coffee_async_format_cancel(void);
86 
87 enum coffee_async_format_status_t coffee_async_format_status(void);
88 
89 int coffee_file_test(void);
90 
91 #endif /* CFS_COFFEE_ARCH_H_INCLUDED */
EVE module stub.
uint8_t data[USBNET_RX_BUF_SIZE]
Definition: usbnet.h:140
Driver for SPI-based memories.