main_ubi_sdk v 0.1.3
This is UBI4 documentation
flash_driver.h
Go to the documentation of this file.
1/*
2 ******************************************************************************
3 * @file flash_driver.h
4 * @author A.Alborov
5 ******************************************************************************
6*/
7
8
9
10#ifndef INC_FLASH_DRIVER_H_
11#define INC_FLASH_DRIVER_H_
12
13
14
15
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include "stdint.h"
22#include "stdbool.h"
23#include "UBI_SDK.h"
24
25#ifdef UBI_SDK_MANUFACTURER_NORDIC
26
27#include "nrf_nvmc.h"
28#include "nordic_common.h"
29#include "nrf_fstorage_sd.h"
30#include "nrf_fstorage_nvmc.h"
32
33
34
35#ifdef UBI_SDK_TARGET_NRF52832
36#define FLASH_START_ADDR 0x00U
37#define FLASH_END_ADDR 0x077000U
38#define MIN_SECTOR_SIZE 0x1000U
39#endif
40
41
42
43
44#define ROUND_MEMORY_CELL_SIZE(_sizeof_, _base_) (_sizeof_%_base_ ? ((_sizeof_/_base_)*_base_+_base_) : (_sizeof_))
45
46typedef enum {
47 FDSE_WRITE_OK = 0,
48 FDSE_OWERWRITING_NOT_REQUERED,
49 FDSE_DATA_CONTAINE_IN_FLASH_BUFFER,
50 FDSE_FLASH_BUFFER_BUSY,
51 FDSE_FLASH_WRITE_ERROR
52 }flash_driver_status_enum;
53
54
55
57
58
59uint32_t readFlash32(uint32_t Address);
60
61
62uint16_t readFlash16(uint32_t Address);
63
64
65uint8_t readFlash8(uint32_t Address);
66
67
68void* getFlashPointer(uint32_t Address);
69
70
71bool WriteBytesToFlash(uint32_t Address, uint8_t* Buf, uint32_t Size);
72
73void* SmartWriteToFlash(uint32_t Address, uint8_t* Buf, uint32_t Size,flash_driver_status_enum* status);
74
75
76
77bool compare_memory_val(uint32_t Address, uint8_t* val, uint32_t val_size);
78
79
80bool memory_region_is_free(uint32_t Address, uint32_t Len);
81
82void clear_flash_sector(uint32_t Address);
83
84uint32_t getSectorNumber(uint32_t Address);
85
86uint32_t getStartSectorAddress(uint32_t Address);
87
88void finish_used_flash();
89
90#endif /* UBI_SDK_MANUFACTURER_NORDIC*/
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* INC_FLASH_DRIVER_H_ */
97
void init_flash_driver(base_memory_driver_struct **memory_driver)
Definition base_memory_driver.h:70