MeshX 0.4
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
Loading...
Searching...
No Matches
meshx_fal_interface.h
Go to the documentation of this file.
1/**
2 * Copyright © 2024 - 2025 MeshX
3 *
4 * @file meshx_fal_interface.h
5 * @brief Flash Abstraction Layer (FAL) Interface for MeshX.
6 *
7 * This header defines the interface for interacting with raw flash partitions.
8 *
9 * @author Pranjal Chanda
10 */
11
12#ifndef __MESHX_FAL_INTERFACE_H__
13#define __MESHX_FAL_INTERFACE_H__
14
15#include "meshx_err.h"
16#include <stdint.h>
17#include <stddef.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/**
24 * @struct meshx_fal_partition
25 * @brief Structure representing a flash partition.
26 */
27typedef struct {
28 char const *name; /**< Name of the partition */
29 uint32_t base_addr; /**< Base address of the partition (if applicable) */
30 uint32_t size; /**< Total size of the partition in bytes */
31 uint32_t sector_size; /**< Size of an erasable sector in bytes */
32 void *priv; /**< Platform-specific private data (e.g., partition handle) */
34
35/**
36 * @brief Read data from a flash partition.
37 *
38 * @param[in] part Pointer to the partition structure.
39 * @param[in] offset Offset from the start of the partition.
40 * @param[out] buf Pointer to the buffer to store read data.
41 * @param[in] len Number of bytes to read.
42 *
43 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
44 */
45meshx_err_t meshx_fal_read(const meshx_fal_partition_t *part, uint32_t offset, void *buf, size_t len);
46
47/**
48 * @brief Write data to a flash partition.
49 *
50 * @param[in] part Pointer to the partition structure.
51 * @param[in] offset Offset from the start of the partition.
52 * @param[in] buf Pointer to the buffer containing data to write.
53 * @param[in] len Number of bytes to write.
54 *
55 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
56 */
57meshx_err_t meshx_fal_write(const meshx_fal_partition_t *part, uint32_t offset, const void *buf, size_t len);
58
59/**
60 * @brief Erase a range of a flash partition.
61 *
62 * @param[in] part Pointer to the partition structure.
63 * @param[in] offset Offset from the start of the partition (must be sector aligned).
64 * @param[in] len Number of bytes to erase (must be sector aligned).
65 *
66 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
67 */
68meshx_err_t meshx_fal_erase(const meshx_fal_partition_t *part, uint32_t offset, size_t len);
69
70/**
71 * @brief Find a flash partition by name.
72 *
73 * @param[in] name Name of the partition to find.
74 * @param[out] part Pointer to the partition structure to populate.
75 *
76 * @return meshx_err_t MESHX_SUCCESS on success, or error code.
77 */
79
80#ifdef __cplusplus
81}
82#endif
83
84#endif /* __MESHX_FAL_INTERFACE_H__ */
MeshX Error Codes.
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
meshx_err_t meshx_fal_read(const meshx_fal_partition_t *part, uint32_t offset, void *buf, size_t len)
Read data from a flash partition.
meshx_err_t meshx_fal_erase(const meshx_fal_partition_t *part, uint32_t offset, size_t len)
Erase a range of a flash partition.
meshx_err_t meshx_fal_find_partition(const char *name, meshx_fal_partition_t *part)
Find a flash partition by name.
meshx_err_t meshx_fal_write(const meshx_fal_partition_t *part, uint32_t offset, const void *buf, size_t len)
Write data to a flash partition.
Definition meshx_fal_interface.h:27
uint32_t size
Definition meshx_fal_interface.h:30
uint32_t sector_size
Definition meshx_fal_interface.h:31
char const * name
Definition meshx_fal_interface.h:28
uint32_t base_addr
Definition meshx_fal_interface.h:29
void * priv
Definition meshx_fal_interface.h:32