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
11
12#ifndef INC_FLASH_DRIVER_H_
13#define INC_FLASH_DRIVER_H_
14
15
16
17
18
19#ifdef __cplusplus
20 extern "C" {
21#endif
22
23#include "stdint.h"
24#include "stdbool.h"
25#include "UBI_SDK.h"
26
27#ifdef UBI_SDK_MANUFACTURER_NORDIC
28
29#include "nrf_nvmc.h"
30#include "nordic_common.h"
31#include "nrf_fstorage_sd.h"
32#include "nrf_fstorage_nvmc.h"
34
35
36
37#ifdef UBI_SDK_TARGET_NRF52832
38#define FLASH_START_ADDR 0x076000
39#define FLASH_END_ADDR 0x077000U
40#define MIN_SECTOR_SIZE 0x1000U
41#endif
42
43
44
45
46#define ROUND_MEMORY_CELL_SIZE(_sizeof_, _base_) (_sizeof_%_base_ ? ((_sizeof_/_base_)*_base_+_base_) : (_sizeof_))
47
48typedef enum {
49 FDSE_WRITE_OK = 0,
50 FDSE_OWERWRITING_NOT_REQUERED,
51 FDSE_DATA_CONTAINE_IN_FLASH_BUFFER,
52 FDSE_FLASH_BUFFER_BUSY,
53 FDSE_FLASH_WRITE_ERROR
54 }flash_driver_status_enum;
55
56
57
59
60
61uint32_t readFlash32(uint32_t Address);
62
63
64uint16_t readFlash16(uint32_t Address);
65
66
67uint8_t readFlash8(uint32_t Address);
68
69
70void* getFlashPointer(uint32_t Address);
71
72
73bool WriteBytesToFlash(base_memory_driver_struct* memory_driver,uint32_t Address, uint8_t* Buf, uint32_t Size);
74
75void* SmartWriteToFlash(uint32_t Address, uint8_t* Buf, uint32_t Size,flash_driver_status_enum* status);
76
77
78
79bool compare_memory_val(uint32_t Address, uint8_t* val, uint32_t val_size);
80
81
82bool memory_region_is_free(void* memory_driver,uint32_t Address, uint32_t Len);
83
84void clear_flash_sector(void* memory_driver,uint32_t Address, uint32_t size_clear);
85
86uint32_t getSectorNumber(uint32_t Address);
87
88uint32_t getStartSectorAddress(uint32_t Address);
89
90void finish_used_flash(base_memory_driver_struct* memory_driver);
91
92#endif /* UBI_SDK_MANUFACTURER_NORDIC*/
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* INC_FLASH_DRIVER_H_ */
99
void init_flash_driver(base_memory_driver_struct **memory_driver)
Definition base_memory_driver.h:70