Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pal_nvm.h « Inc « mesh « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 12f2ea134bb3b001306e780ef0d80bbfc827870a (plain)
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
/**
******************************************************************************
* @file    pal_nvm.h
* @author  BLE Mesh Team
* @brief   Header file for pal_nvm.c 
******************************************************************************
* @attention
*
* Copyright (c) 2018-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PAL_NVM_H
#define __PAL_NVM_H

#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \
                                __disable_irq()
/* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */ 
#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit)

/* Includes ------------------------------------------------------------------*/

/* Exported macro ------------------------------------------------------------*/
/* Exported variables  -------------------------------------------------------*/
extern const void* mobleNvmBase;

/* Private define ------------------------------------------------------------*/
#define NVM_BASE                                     ((unsigned int)mobleNvmBase)
#if defined(STM32WB55xx)
#define NVM_SIZE                                                           8192U
#elif defined(STM32WB15xx)
#define NVM_SIZE                                                           4096U
#endif

typedef enum
{
    MOBLE_NVM_COMPARE_EQUAL,
    MOBLE_NVM_COMPARE_NOT_EQUAL,
    MOBLE_NVM_COMPARE_NOT_EQUAL_ERASE
} MOBLE_NVM_COMPARE;

/* Exported Functions Prototypes ---------------------------------------------*/
MOBLE_RESULT PalNvmRead(MOBLEUINT32 address,
                        MOBLEUINT32 offset,
                        void *buf, 
                        MOBLEUINT32 size, 
                        MOBLEBOOL backup);
MOBLE_RESULT PalNvmBackupRead(MOBLEUINT32 address, 
                              void *buf, 
                              MOBLEUINT32 size);
MOBLE_RESULT PalNvmWrite(MOBLEUINT32 address,
                         MOBLEUINT32 offset,
                         void const *buf, 
                         MOBLEUINT32 size);
MOBLEBOOL    PalNvmIsWriteProtected(void);
MOBLE_RESULT PalNvmCompare(MOBLEUINT32 address,
                           MOBLEUINT32 offset,
                           void const *buf, 
                           MOBLEUINT32 size, 
                           MOBLE_NVM_COMPARE* result);
MOBLE_RESULT PalNvmErase(MOBLEUINT32 address,
                         MOBLEUINT32 offset);
MOBLE_RESULT PalNvmProcess(void);

#endif /* __PAL_NVM_H */