Morse Micro IoT SDK  2.12.3
mmhal_flash.h
1/*
2 * Copyright 2021-2023 Morse Micro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
17#pragma once
18
19#include <stdbool.h>
20#include <stddef.h>
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C"
25{
26#endif
27
32#define MMHAL_FLASH_ERASE_VALUE 0xFF
33
35struct lfs_config;
36
43#ifndef MMHAL_FLASH_ADDR_T
44#define MMHAL_FLASH_ADDR_T uint32_t
45#endif
46
49
60{
71
74
82};
83
85#define MMHAL_FLASH_PARTITION_CONFIG_DEFAULT { 0, 0, false }
86
102
119
132
143
154int mmhal_flash_read(mmhal_flash_addr_t read_address, uint8_t *buf, size_t size);
155
171int mmhal_flash_write(mmhal_flash_addr_t write_address, const uint8_t *data, size_t size);
172
188const struct lfs_config *mmhal_get_littlefs_config(void);
189
190#ifdef __cplusplus
191}
192#endif
193
const struct mmhal_flash_partition_config * mmhal_get_factory_mmconfig_partition(void)
Get optional factory default MMCONFIG flash partition configuration.
int mmhal_flash_write(mmhal_flash_addr_t write_address, const uint8_t *data, size_t size)
Write a block of data to the specified Flash address.
int mmhal_flash_read(mmhal_flash_addr_t read_address, uint8_t *buf, size_t size)
Read a block of data from the specified Flash address into the buffer.
#define MMHAL_FLASH_ADDR_T
Underlying integer type for mmhal_flash_addr_t.
Definition: mmhal_flash.h:44
MMHAL_FLASH_ADDR_T mmhal_flash_addr_t
Address type used by the mmhal flash API.
Definition: mmhal_flash.h:48
uint32_t mmhal_flash_getblocksize(mmhal_flash_addr_t block_address)
Returns the size of the flash block at the specified address.
const struct lfs_config * mmhal_get_littlefs_config(void)
Get LittleFS configuration.
const struct mmhal_flash_partition_config * mmhal_get_mmconfig_partition(void)
Get MMCONFIG flash partition configuration.
int mmhal_flash_erase(mmhal_flash_addr_t block_address)
Erases a specified block of flash.
static unsigned char buf[1024]
Statically allocated buffer for MQTT.
Definition: mqttdemo.c:153
Flash partition configuration structure.
Definition: mmhal_flash.h:60
uint32_t partition_size
The size of the partition (in bytes).
Definition: mmhal_flash.h:73
mmhal_flash_addr_t partition_start
The start address of the partition.
Definition: mmhal_flash.h:70
bool not_memory_mapped
If false, then the partition address range (partition_start to partition_start + partition_size) must...
Definition: mmhal_flash.h:81