Prusa MINI Firmware overview
persistent_store_api.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  *
4  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5  * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6  * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7  * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23 #pragma once
24 
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 #include "../../libs/crc16.h"
29 
31 public:
32  static bool access_start();
33  static bool access_finish();
34  static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc);
35  static bool read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing=true);
36  static size_t capacity();
37 
38  static inline bool write_data(const int pos, const uint8_t* value, const size_t size=sizeof(uint8_t)) {
39  int data_pos = pos;
40  uint16_t crc = 0;
41  return write_data(data_pos, value, size, &crc);
42  }
43 
44  static inline bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); }
45 
46  static inline bool read_data(const int pos, uint8_t* value, const size_t size=1) {
47  int data_pos = pos;
48  uint16_t crc = 0;
49  return read_data(data_pos, value, size, &crc);
50  }
51 };
52 
PersistentStore
Definition: persistent_store_api.h:30
crc
png_uint_32 crc
Definition: png.c:2247
PersistentStore::write_data
static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc)
persistent_store_api.h
PersistentStore::access_finish
static bool access_finish()
PersistentStore::access_start
static bool access_start()
PersistentStore::read_data
static bool read_data(const int pos, uint8_t *value, const size_t size=1)
Definition: persistent_store_api.h:46
uint8_t
const uint8_t[]
Definition: 404_html.c:3
PersistentStore::read_data
static bool read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing=true)
PersistentStore::capacity
static size_t capacity()
persistentStore
PersistentStore persistentStore
Definition: persistent_store_api.cpp:28
persistentStore
PersistentStore persistentStore
Definition: persistent_store_api.cpp:28
PersistentStore::write_data
static bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t))
Definition: persistent_store_api.h:38
PersistentStore::write_data
static bool write_data(const int pos, const uint8_t value)
Definition: persistent_store_api.h:44
size
static png_bytep size_t size
Definition: pngwrite.c:2170