Contiki-NG
cfs-coffee-arch.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
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 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/*---------------------------------------------------------------------------*/
31/**
32 * \addtogroup gecko
33 * @{
34 *
35 * \addtogroup gecko-storage Storage drivers
36 * @{
37 *
38 * \addtogroup gecko-storage-cfs Storage CFS coffee driver
39 * @{
40 *
41 * \file
42 * storage driver for the gecko.
43 * \author
44 * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
45 *
46 */
47/*---------------------------------------------------------------------------*/
48#ifndef CFS_COFFEE_ARCH_H_
49#define CFS_COFFEE_ARCH_H_
50
51#include "contiki.h"
52#include "cfs/cfs-coffee.h"
53#include "em_device.h"
54#include "em_msc.h"
55
56#include <stdint.h>
57
58/*---------------------------------------------------------------------------*/
59/** \name Coffee port constants
60 * @{
61 */
62/* Coffee configuration parameters. */
63#define COFFEE_SECTOR_SIZE (FLASH_PAGE_SIZE)
64#define COFFEE_PAGE_SIZE (FLASH_PAGE_SIZE / 8)
65#ifdef COFFEE_CONF_SIZE
66#define COFFEE_SIZE COFFEE_CONF_SIZE
67#else
68#define COFFEE_SIZE 0
69#endif
70#define COFFEE_NAME_LENGTH (18)
71#define COFFEE_MAX_OPEN_FILES (6)
72#define COFFEE_FD_SET_SIZE (8)
73#define COFFEE_LOG_TABLE_LIMIT (256)
74#define COFFEE_DYN_SIZE (2 * 1024)
75#define COFFEE_LOG_SIZE (1024)
76#define COFFEE_MICRO_LOGS (1)
77#define COFFEE_APPEND_ONLY (0)
78/** @} */
79/*---------------------------------------------------------------------------*/
80/** \name Coffee port macros
81 * @{
82 */
83/** Erase */
84#define COFFEE_ERASE(sector) \
85 cfs_coffee_arch_erase(sector)
86/** Write */
87#define COFFEE_WRITE(buf, size, offset) \
88 cfs_coffee_arch_write((buf), (size), (offset))
89/** Read */
90#define COFFEE_READ(buf, size, offset) \
91 cfs_coffee_arch_read((buf), (size), (offset))
92/** @} */
93/*---------------------------------------------------------------------------*/
94/** \name Coffee port types
95 * @{
96 */
97typedef int16_t coffee_page_t; /**< Page */
98/** @} */
99/*---------------------------------------------------------------------------*/
100
101/** \brief Erases a device sector
102 * \param sector Sector to erase
103 */
104void cfs_coffee_arch_erase(uint16_t sector);
105
106/** \brief Writes a buffer to the device
107 * \param buf Pointer to the buffer
108 * \param size Byte size of the buffer
109 * \param offset Device offset to write to
110 */
111void cfs_coffee_arch_write(const void *buf, unsigned int size,
112 cfs_offset_t offset);
113
114/** \brief Reads from the device to a buffer
115 * \param buf Pointer to the buffer
116 * \param size Byte size of the buffer
117 * \param offset Device offset to read from
118 */
119void cfs_coffee_arch_read(void *buf, unsigned int size, cfs_offset_t offset);
120
121#endif /* CFS_COFFEE_ARCH_H_ */
122
123/**
124 * @}
125 * @}
126 * @}
127 */
Header for the Coffee file system.
int16_t coffee_page_t
Page.
void cfs_coffee_arch_write(const void *buf, unsigned int size, cfs_offset_t offset)
Writes a buffer to the device.
void cfs_coffee_arch_read(void *buf, unsigned int size, cfs_offset_t offset)
Reads from the device to a buffer.
void cfs_coffee_arch_erase(uint16_t sector)
Erases a device sector.
int cfs_offset_t
CFS directory entry name length.
Definition: cfs.h:65