Update cloud build defines (#14080)
[betaflight.git] / src / main / config / config_streamer.h
blob930dcbe50be1c6ac658f09e95636483f00d6e46c
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdint.h>
24 #include <stdbool.h>
26 // Streams data out to the EEPROM, padding to the write size as
27 // needed, and updating the checksum as it goes.
29 #if defined(CONFIG_IN_EXTERNAL_FLASH) || defined(CONFIG_IN_MEMORY_MAPPED_FLASH)
30 #define CONFIG_STREAMER_BUFFER_SIZE 8 // Must not be greater than the smallest flash page size of all compiled-in flash devices.
31 typedef uint32_t config_streamer_buffer_align_type_t;
32 #elif defined(CONFIG_IN_RAM) || defined(CONFIG_IN_SDCARD)
33 #define CONFIG_STREAMER_BUFFER_SIZE 32
34 typedef uint64_t config_streamer_buffer_align_type_t;
35 #elif defined(STM32H743xx) || defined(STM32H750xx) || defined(STM32H723xx) || defined(STM32H725xx)
36 #define CONFIG_STREAMER_BUFFER_SIZE 32 // Flash word = 256-bits
37 typedef uint64_t config_streamer_buffer_align_type_t;
38 #elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ)
39 #define CONFIG_STREAMER_BUFFER_SIZE 16 // Flash word = 128-bits
40 typedef uint64_t config_streamer_buffer_align_type_t;
41 #elif defined(STM32G4)
42 #define CONFIG_STREAMER_BUFFER_SIZE 8 // Flash word = 64-bits
43 typedef uint64_t config_streamer_buffer_align_type_t;
44 #elif defined(APM32F4)
45 #define CONFIG_STREAMER_BUFFER_SIZE 4 // Flash word = 32-bits
46 typedef uint32_t config_streamer_buffer_align_type_t;
47 #else
48 #define CONFIG_STREAMER_BUFFER_SIZE 4
49 typedef uint32_t config_streamer_buffer_align_type_t;
50 #endif
52 typedef struct config_streamer_s {
53 uintptr_t address;
54 int size;
55 union {
56 uint8_t b[CONFIG_STREAMER_BUFFER_SIZE];
57 config_streamer_buffer_align_type_t w;
58 } buffer;
59 int at;
60 int err;
61 bool unlocked;
62 } config_streamer_t;
64 void config_streamer_init(config_streamer_t *c);
66 void config_streamer_start(config_streamer_t *c, uintptr_t base, int size);
67 int config_streamer_write(config_streamer_t *c, const uint8_t *p, uint32_t size);
68 int config_streamer_flush(config_streamer_t *c);
70 int config_streamer_finish(config_streamer_t *c);
71 int config_streamer_status(config_streamer_t *c);