Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
cfs-coffee-arch.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013, ADVANSEE - http://www.advansee.com/
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
*
14
* 3. Neither the name of the copyright holder nor the names of its
15
* contributors may be used to endorse or promote products derived
16
* from this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29
* OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/**
32
* \addtogroup cc2538
33
* @{
34
*
35
* \defgroup cc2538-cfs-coffee-arch cc2538 Coffee port module
36
*
37
* Module for the cc2538 Coffee port
38
* @{
39
*
40
* \file
41
* Header file for the cc2538 Coffee port module
42
*/
43
#ifndef CFS_COFFEE_ARCH_H_
44
#define CFS_COFFEE_ARCH_H_
45
46
#include "contiki.h"
47
#include "
cfs/cfs-coffee.h
"
48
#include "
dev/cc2538-dev.h
"
49
#include "
dev/flash.h
"
50
51
#include <stdint.h>
52
53
#ifdef COFFEE_CONF_CUSTOM_PORT
54
#include COFFEE_CONF_CUSTOM_PORT
55
#else
56
/*---------------------------------------------------------------------------*/
57
/** \name Coffee port constants
58
* @{
59
*/
60
/** Logical sector size */
61
#ifdef COFFEE_CONF_SECTOR_SIZE
62
#define COFFEE_SECTOR_SIZE COFFEE_CONF_SECTOR_SIZE
63
#else
64
#define COFFEE_SECTOR_SIZE FLASH_PAGE_SIZE
65
#endif
66
/** Logical page size */
67
#ifdef COFFEE_CONF_PAGE_SIZE
68
#define COFFEE_PAGE_SIZE COFFEE_CONF_PAGE_SIZE
69
#else
70
#define COFFEE_PAGE_SIZE (COFFEE_SECTOR_SIZE / 8)
71
#endif
72
/** Start offset of the file system */
73
#ifdef COFFEE_CONF_START
74
#define COFFEE_START COFFEE_CONF_START
75
#else
76
#define COFFEE_START CC2538_DEV_FLASH_ADDR
77
#endif
78
/** Total size in bytes of the file system */
79
#ifdef COFFEE_CONF_SIZE
80
#define COFFEE_SIZE COFFEE_CONF_SIZE
81
#else
82
#define COFFEE_SIZE 0
83
#endif
84
/** Maximal filename length */
85
#ifdef COFFEE_CONF_NAME_LENGTH
86
#define COFFEE_NAME_LENGTH COFFEE_CONF_NAME_LENGTH
87
#else
88
#define COFFEE_NAME_LENGTH 40
89
#endif
90
/** Number of file cache entries */
91
#ifdef COFFEE_CONF_MAX_OPEN_FILES
92
#define COFFEE_MAX_OPEN_FILES COFFEE_CONF_MAX_OPEN_FILES
93
#else
94
#define COFFEE_MAX_OPEN_FILES 5
95
#endif
96
/** Number of file descriptor entries */
97
#ifdef COFFEE_CONF_FD_SET_SIZE
98
#define COFFEE_FD_SET_SIZE COFFEE_CONF_FD_SET_SIZE
99
#else
100
#define COFFEE_FD_SET_SIZE 5
101
#endif
102
/** Maximal amount of log table entries read in one batch */
103
#ifdef COFFEE_CONF_LOG_TABLE_LIMIT
104
#define COFFEE_LOG_TABLE_LIMIT COFFEE_CONF_LOG_TABLE_LIMIT
105
#else
106
#define COFFEE_LOG_TABLE_LIMIT 16
107
#endif
108
/** Default reserved file size */
109
#ifdef COFFEE_CONF_DYN_SIZE
110
#define COFFEE_DYN_SIZE COFFEE_CONF_DYN_SIZE
111
#else
112
#define COFFEE_DYN_SIZE (COFFEE_SECTOR_SIZE - 50)
113
#endif
114
/** Default micro-log size */
115
#ifdef COFFEE_CONF_LOG_SIZE
116
#define COFFEE_LOG_SIZE COFFEE_CONF_LOG_SIZE
117
#else
118
#define COFFEE_LOG_SIZE (4 * COFFEE_PAGE_SIZE)
119
#endif
120
/** Whether Coffee will use micro logs */
121
#ifdef COFFEE_CONF_MICRO_LOGS
122
#define COFFEE_MICRO_LOGS COFFEE_CONF_MICRO_LOGS
123
#else
124
#define COFFEE_MICRO_LOGS 0
125
#endif
126
/** Whether files are expected to be appended to only */
127
#ifdef COFFEE_CONF_APPEND_ONLY
128
#define COFFEE_APPEND_ONLY COFFEE_CONF_APPEND_ONLY
129
#else
130
#define COFFEE_APPEND_ONLY 1
131
#endif
132
/** @} */
133
/*---------------------------------------------------------------------------*/
134
/** \name Coffee port macros
135
* @{
136
*/
137
/** Erase */
138
#define COFFEE_ERASE(sector) \
139
cfs_coffee_arch_erase(sector)
140
/** Write */
141
#define COFFEE_WRITE(buf, size, offset) \
142
cfs_coffee_arch_write((buf), (size), (offset))
143
/** Read */
144
#define COFFEE_READ(buf, size, offset) \
145
cfs_coffee_arch_read((buf), (size), (offset))
146
/** @} */
147
/*---------------------------------------------------------------------------*/
148
/** \name Coffee port types
149
* @{
150
*/
151
typedef
int16_t
coffee_page_t
;
/**< Page */
152
/** @} */
153
/*---------------------------------------------------------------------------*/
154
/** \name Coffee port functions
155
* @{
156
*/
157
158
/** \brief Erases a device sector
159
* \param sector Sector to erase
160
*/
161
void
cfs_coffee_arch_erase
(uint16_t sector);
162
163
/** \brief Writes a buffer to the device
164
* \param buf Pointer to the buffer
165
* \param size Byte size of the buffer
166
* \param offset Device offset to write to
167
*/
168
void
cfs_coffee_arch_write
(
const
void
*buf,
unsigned
int
size,
169
cfs_offset_t
offset);
170
171
/** \brief Reads from the device to a buffer
172
* \param buf Pointer to the buffer
173
* \param size Byte size of the buffer
174
* \param offset Device offset to read from
175
*/
176
void
cfs_coffee_arch_read
(
void
*buf,
unsigned
int
size,
cfs_offset_t
offset);
177
178
/** @} */
179
180
#endif
/* COFFEE_CONF_CUSTOM_PORT */
181
#endif
/* CFS_COFFEE_ARCH_H_ */
182
183
/**
184
* @}
185
* @}
186
*/
cc2538-dev.h
Header file for the cc2538 devices definitions.
flash.h
Header file for the flash memory definitions.
cfs-coffee.h
Header for the Coffee file system.
coffee_page_t
int16_t coffee_page_t
Page.
Definition
cfs-coffee-arch.h:151
cfs_coffee_arch_write
void cfs_coffee_arch_write(const void *buf, unsigned int size, cfs_offset_t offset)
Writes a buffer to the device.
Definition
cfs-coffee-arch.c:86
cfs_coffee_arch_read
void cfs_coffee_arch_read(void *buf, unsigned int size, cfs_offset_t offset)
Reads from the device to a buffer.
Definition
cfs-coffee-arch.c:131
cfs_coffee_arch_erase
void cfs_coffee_arch_erase(uint16_t sector)
Erases a device sector.
Definition
cfs-coffee-arch.c:76
cfs_offset_t
int cfs_offset_t
CFS directory entry name length.
Definition
cfs.h:65
arch
cpu
cc2538
cfs-coffee-arch.h
Generated on
for Contiki-NG by
1.17.0