-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash.h
More file actions
52 lines (41 loc) · 1.28 KB
/
flash.h
File metadata and controls
52 lines (41 loc) · 1.28 KB
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
/*
* About:
* General section for the various memory Flash chips.
*
* Author:
* EXL
*
* License:
* MIT
*/
#ifndef FLASH_H
#define FLASH_H
#include "platform.h"
/**
* General flash functions.
*/
extern int flash_init(void);
extern int flash_unlock(volatile u16 *reg_addr_ctl);
extern int flash_erase(volatile u16 *reg_addr_ctl);
extern int flash_write_block(volatile u16 *reg_addr_ctl, volatile u16 *buffer, u32 size);
extern int flash_write_buffer(volatile u16 *reg_addr_ctl, const u16 *buffer, u32 size);
extern int flash_geometry(volatile u16 *reg_addr_ctl);
extern u32 flash_get_part_id(volatile u16 *reg_addr_ctl);
extern int flash_get_otp_zone(volatile u16 *reg_addr_ctl, u8 *otp_out_buffer, u16 *size);
/**
* Flash section.
*/
#if defined(FTR_FLASH_DATA_WIDTH_32BIT)
#define FLASH_COMMAND(x) (((FLASH_DATA_WIDTH) (x) | ((FLASH_DATA_WIDTH) (x) << (sizeof(FLASH_DATA_WIDTH) << 2)))
#else
#define FLASH_COMMAND(x) ((FLASH_DATA_WIDTH) (x))
#endif
#define BUFFER_SIZE_TO_WRITE(s) FLASH_COMMAND((s) - 1)
#if defined(FTR_FLASH_DATA_WIDTH_32BIT)
typedef u32 FLASH_DATA_WIDTH;
#else
typedef u16 FLASH_DATA_WIDTH;
#endif
#define FLASH_START_ADDRESS ((volatile FLASH_DATA_WIDTH *) 0x10000000)
#define FLASH_MAX_OTP_SIZE (1024)
#endif /* !FLASH_H */