Select one of the symbols to view example projects that use it.
 
Outline
#include "hal/spi_flash_hal.h"
memspi_host_config_t
memspi_host_inst_t
memspi_host_init_pointers(memspi_host_inst_t *, const memspi_host_config_t *);
memspi_host_read_id_hs(spi_flash_host_inst_t *, uint32_t *);
memspi_host_read_status_hs(spi_flash_host_inst_t *, uint8_t *);
memspi_host_flush_cache(spi_flash_host_inst_t *, uint32_t, uint32_t);
memspi_host_erase_chip(spi_flash_host_inst_t *);
memspi_host_erase_sector(spi_flash_host_inst_t *, uint32_t);
memspi_host_erase_block(spi_flash_host_inst_t *, uint32_t);
memspi_host_program_page(spi_flash_host_inst_t *, const void *, uint32_t, uint32_t);
memspi_host_set_write_protect(spi_flash_host_inst_t *, bool);
memspi_host_read(spi_flash_host_inst_t *, void *, uint32_t, uint32_t);
memspi_host_read_data_slicer(spi_flash_host_inst_t *, uint32_t, uint32_t, uint32_t *, uint32_t);
memspi_host_write_data_slicer(spi_flash_host_inst_t *, uint32_t, uint32_t, uint32_t *, uint32_t);
Files
loading (4/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/spi_flash/include/memspi_host_driver.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #pragma once #include "hal/spi_flash_hal.h" /** Default configuration for the memspi (high speed version) */ #define ESP_FLASH_DEFAULT_HOST_DRIVER() (spi_flash_host_driver_t) { \ .dev_config = spi_flash_hal_device_config, \ .common_command = spi_flash_hal_common_command, \ .read_id = memspi_host_read_id_hs, \ .erase_chip = spi_flash_hal_erase_chip, \ .erase_sector = spi_flash_hal_erase_sector, \ .erase_block = spi_flash_hal_erase_block, \ .read_status = memspi_host_read_status_hs, \ .set_write_protect = spi_flash_hal_set_write_protect, \ .supports_direct_write = spi_flash_hal_supports_direct_write, \ .supports_direct_read = spi_flash_hal_supports_direct_read, \ .program_page = spi_flash_hal_program_page, \ .write_data_slicer = memspi_host_write_data_slicer, \ .read = spi_flash_hal_read, \ .read_data_slicer = memspi_host_read_data_slicer, \ .host_status = spi_flash_hal_check_status, \ .configure_host_io_mode = spi_flash_hal_configure_host_io_mode, \ .poll_cmd_done = spi_flash_hal_poll_cmd_done, \ .flush_cache = memspi_host_flush_cache, \ .check_suspend = NULL, \ .resume = spi_flash_hal_resume, \ .suspend = spi_flash_hal_suspend,\ .sus_setup = spi_flash_hal_setup_read_suspend,\ }{...} ... /// configuration for the memspi host typedef spi_flash_hal_config_t memspi_host_config_t; /// context for the memspi host typedef spi_flash_hal_context_t memspi_host_inst_t; /** * Initialize the memory SPI host. * * @param host Pointer to the host structure. * @param cfg Pointer to configuration structure * * @return always return ESP_OK *//* ... */ esp_err_t memspi_host_init_pointers(memspi_host_inst_t *host, const memspi_host_config_t *cfg); /******************************************************************************* * NOTICE * Rest part of this file are part of the HAL layer * The HAL is not public api, don't use in application code. * See readme.md in hal/include/hal/readme.md ******************************************************************************//* ... */ /** * @brief Read the Status Register read from RDSR (05h). * * High speed implementation of RDID through memspi interface relying on the * ``common_command``. * * @param host The driver context. * @param id Output of the read ID from the slave. * * @return * - ESP_OK: if success * - ESP_ERR_FLASH_NO_RESPONSE: if no response from chip * - or other cases from ``spi_hal_common_command`` *//* ... */ esp_err_t memspi_host_read_id_hs(spi_flash_host_inst_t *host, uint32_t *id); /** * High speed implementation of RDSR through memspi interface relying on the * ``common_command``. * * @param host The driver context. * @param id Output of the read ID from the slave. * * @return * - ESP_OK: if success * - or other cases from ``spi_hal_common_command`` *//* ... */ esp_err_t memspi_host_read_status_hs(spi_flash_host_inst_t *host, uint8_t *out_sr); /** * Flush the cache (if needed) after the contents are modified. * * @param host The driver context. * @param addr Start address of the modified region * @param size Size of the region modified. * * @return always ESP_OK. *//* ... */ esp_err_t memspi_host_flush_cache(spi_flash_host_inst_t *host, uint32_t addr, uint32_t size); /** * Erase contents of entire chip. * * @param host The driver context. *//* ... */ void memspi_host_erase_chip(spi_flash_host_inst_t *host); /** * Erase a sector starting from a given address. For 24bit address only. * * @param host The driver context. * @param start_address Starting address of the sector. *//* ... */ void memspi_host_erase_sector(spi_flash_host_inst_t *host, uint32_t start_address); /** * Erase a block starting from a given address. For 24bit address only. * * @param host The driver context. * @param start_address Starting address of the block. *//* ... */ void memspi_host_erase_block(spi_flash_host_inst_t *host, uint32_t start_address); /** * Program a page with contents of a buffer. For 24bit address only. * * @param host The driver context. * @param buffer Buffer which contains the data to be flashed. * @param address Starting address of where to flash the data. * @param length The number of bytes to flash. *//* ... */ void memspi_host_program_page(spi_flash_host_inst_t *host, const void *buffer, uint32_t address, uint32_t length); /** * Set ability to write to chip. * * @param host The driver context. * @param wp Enable or disable write protect (true - enable, false - disable). *//* ... */ esp_err_t memspi_host_set_write_protect(spi_flash_host_inst_t *host, bool wp); /** * Read data to buffer. * * @param host The driver context. * @param buffer Buffer which contains the data to be read. * @param address Starting address of where to read the data. * @param length The number of bytes to read. *//* ... */ esp_err_t memspi_host_read(spi_flash_host_inst_t *host, void *buffer, uint32_t address, uint32_t read_len); /** * @brief Slicer for read data used in non-encrypted regions. This slicer does nothing but * limit the length to the maximum size the host supports. * * @param address Flash address to read * @param len Length to read * @param align_address Output of the address to read, should be equal to the input `address` * @param page_size Physical SPI flash page size * * @return Length that can actually be read in one `read` call in `spi_flash_host_driver_t`. *//* ... */ int memspi_host_read_data_slicer(spi_flash_host_inst_t *host, uint32_t address, uint32_t len, uint32_t *align_address, uint32_t page_size); /** * @brief Slicer for write data used in non-encrypted regions. This slicer limit the length to the * maximum size the host supports, and truncate if the write data lie accross the page boundary * (256 bytes) * * @param address Flash address to write * @param len Length to write * @param align_address Output of the address to write, should be equal to the input `address` * @param page_size Physical SPI flash page size * * @return Length that can actually be written in one `program_page` call in `spi_flash_host_driver_t`. *//* ... */ int memspi_host_write_data_slicer(spi_flash_host_inst_t *host, uint32_t address, uint32_t len, uint32_t *align_address, uint32_t page_size);
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.