1 // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 
15 #ifndef _Flash_Access_H_
16 #define _Flash_Access_H_
17 #include "esp_err.h"
18 
19 /**
20 * @brief Universal flash access interface class
21 *
22 */
23 class Flash_Access
24 {
25 public:
26     virtual size_t chip_size() = 0;
27 
28     virtual esp_err_t erase_sector(size_t sector) = 0;
29     virtual esp_err_t erase_range(size_t start_address, size_t size) = 0;
30 
31     virtual esp_err_t write(size_t dest_addr, const void *src, size_t size) = 0;
32     virtual esp_err_t read(size_t src_addr, void *dest, size_t size) = 0;
33 
34     virtual size_t sector_size() = 0;
35 
flush()36     virtual esp_err_t flush()
37     {
38         return ESP_OK;
39     };
40 
~Flash_Access()41     virtual ~Flash_Access() {};
42 };
43 
44 #endif // _Flash_Access_H_
45