EPD Extension Kit for MSP430 LaunchPad

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Mem_Flash.h
Go to the documentation of this file.
1
34 #ifndef MEM_FLASH_H_
35 #define MEM_FLASH_H_
36
37 #include "EPD_Kit_Tool_Process.h"
38
39 /******************************************************************************
40 * \brief Each EPD size has 32 pages of image
41 *
42 * \note
43 * - Divided 32 pages into 2 segments A and B. Each segment has 16 pages.
44 * - Segment A: for sequence image buffer at "Drawing" tab of EPD Kit Tool
45 * - Segment B: for Slideshow, ASCII and custom assigned images of EPD Kit Tool
46 */
47
49 #define _flash_sector_size (long)4*1024 //4K
50 #define _page_size_144_200 (long)_flash_sector_size*2 //8k
51 #define _page_size_270 (long)_flash_sector_size*3 //12k
52 #define _image_page_max 16 //16 pages
53 #define _flash_line_size 64
54 //must be 16, 32 or 64. Due to 2.7"=264x176,the 264=33bytes
55
57 #define _image_page_mark ((uint8_t)(_image_page_max-1))
58
60 #define _image_header_mark_offset _flash_line_size-2
61
62
66 #define _image144_size 13 //8K=2^13, for bit shift
67 #define _image144_SOF (long)0x0000 //start address of flash of 1.44"
68 #define _image144_address(x) _image144_SOF+((long)x<<_image144_size)
69
71 #define _image144_mark_image_page_max 4
72 #define _image144_mark_image_SOF (long)(_image144_SOF+(_image_page_max*_page_size_144_200))
73 #define _image144_mark_image_address(x) _image144_mark_image_SOF+((long)x<<_image144_size)
74
76 #define _image144_slideshow_page_max 4
77 #define _image144_slideshow_SOF (long)_image144_mark_image_SOF+ \
78 (_image144_mark_image_page_max*_page_size_144_200)
79 #define _image144_slideshow_address(x) _image144_slideshow_SOF+((long)x<<_image144_size)
80
82 #define _image144_custom_page_max 8
83 #define _image144_custom_SOF (long)_image144_slideshow_SOF+ \
84 (_image144_slideshow_page_max*_page_size_144_200)
85 #define _image144_custom_address(x) _image144_custom_SOF+((long)x<<_image144_size)
86
87
91 #define _image200_size 13 //8K=2^13, for bit shift
92 #define _image200_SOF (long)_image144_custom_SOF+ \
93 (_image144_custom_page_max*_page_size_144_200)
94 #define _image200_address(x) _image200_SOF+((long)x<<_image200_size)
95
97 #define _image200_mark_image_page_max 4
98 #define _image200_mark_image_SOF (long)_image200_SOF+(_image_page_max*_page_size_144_200)
99 #define _image200_mark_image_address(x) _image200_mark_image_SOF+((long)x<<_image200_size)
100
102 #define _image200_slideshow_page_max 4
103 #define _image200_slideshow_SOF (long)_image200_mark_image_SOF+ \
104 (_image200_mark_image_page_max*_page_size_144_200)
105 #define _image200_slideshow_address(x) _image200_slideshow_SOF+((long)x<<_image200_size)
106
108 #define _image200_custom_page_max 8
109 #define _image200_custom_SOF (long)_image200_slideshow_SOF+ \
110 (_image200_slideshow_page_max*_page_size_144_200)
111 #define _image200_custom_address(x) _image200_custom_SOF+((long)x<<_image200_size)
112
113
117 #define _image270_SOF (long)_image200_custom_SOF+ \
118 (_image200_custom_page_max*_page_size_144_200)
119 #define _image270_address(x) _image270_SOF + (((long)x<<13)+((long)x<<12)) //(8*1024) + (4*1024) = 2^13 + 2^12
120
122 #define _image270_mark_image_page_max 4
123 #define _image270_mark_image_SOF (long)_image270_SOF+(_image_page_max*_page_size_270)
124 #define _image270_mark_image_address(x) _image270_mark_image_SOF +(((long)x<<13)+((long)x<<12))
125
127 #define _image270_slideshow_page_max 4
128 #define _image270_slideshow_SOF (long)_image270_mark_image_SOF+ \
129 (_image270_mark_image_page_max*_page_size_270)
130 #define _image270_slideshow_address(x) _image270_slideshow_SOF +(((long)x<<13)+((long)x<<12))
131
133 #define _image270_custom_page_max 8
134 #define _image270_custom_SOF (long)_image270_slideshow_SOF+ \
135 (_image270_slideshow_page_max*_page_size_270)
136 #define _image270_custom_address(x) _image270_custom_SOF +(((long)x<<13)+((long)x<<12))
137
139 #define _parameters_address 0xFF000
140 #define _parameters_address_max 0xFFFF0
141
142 /******************************************************************************/
143 #define _image_state_in_use 0xAF
144 #define _image_state_is_empty 0xFF
145 #define _NULL_address -1
146
147 #define __ASCII_OFFSET 0x20
148 #define __TEXT_Width 8
149 #define __TEXT_High 8
150
154 typedef struct {
155 uint16_t x;
156 uint16_t y;
157 uint8_t str[16];
158 } ASCII_info_t;
159
160 /******************************************************************************/
162 #define ElectronicID 0x13
163
165 #define FLASH_CMD_RDID 0x9F //RDID (Read Identification)
166 #define FLASH_CMD_RES 0xAB //RES (Read Electronic ID)
167 #define FLASH_CMD_REMS 0x90 //REMS (Read Electronic & Device ID)
168
170 #define FLASH_CMD_WRSR 0x01 //WRSR (Write Status Register)
171 #define FLASH_CMD_RDSR 0x05 //RDSR (Read Status Register)
172
174 #define FLASH_CMD_READ 0x03 //READ (1 x I/O)
175 #define FLASH_CMD_FASTREAD 0x0B //FAST READ (Fast read data)
176
178 #define FLASH_CMD_WREN 0x06 //WREN (Write Enable)
179 #define FLASH_CMD_WRDI 0x04 //WRDI (Write Disable)
180 #define FLASH_CMD_PP 0x02 //PP (page program)
181
183 #define FLASH_CMD_SE 0x20 //SE (Sector Erase)
184 #define FLASH_CMD_BE 0xD8 //BE (Block Erase)
185 #define FLASH_CMD_CE 0x60 //CE (Chip Erase) hex code: 60 or C7
186
188 #define FLASH_CMD_DP 0xB9 //DP (Deep Power Down)
189 #define FLASH_CMD_RDP 0xAB //RDP (Release form Deep Power Down)
190
192 #define FLASH_WIP_MASK 0x01
193 #define FLASH_LDSO_MASK 0x02
194 #define FLASH_QE_MASK 0x40
195
196 uint8_t is_flash_existed(void);
197
198 void Flash_cs_high(void);
199 void Flash_cs_low(void);
200 void CMD_SE( long flash_address );
201
202 void CMD_CE(void);
203 //void EraseImage_Ex(long address,uint8_t ptype);
204
205 void Flash_init(void);
206 void read_flash(long Address,uint8_t *target_address, uint8_t byte_length);
207 void write_flash(long Address,uint8_t *source_address, uint8_t byte_length);
208
209 void erase_image(long address,uint8_t ptype);
210 void get_flash_image_info(image_information_t * ImageInfo);
211 long get_flash_mark_image_info(uint8_t PlaneType);
212 long get_custom_image_address(uint8_t PlaneType,uint8_t ImageIdx,uint8_t IsClear);
213 long get_slideshow_image_address(uint8_t PlaneType,uint8_t ImageIdx,uint8_t IsClear);
214 void write_mark(long address);
215 void Readtest(void);
216 void write_ascii(long CanvasAddress,long MarkAddress,uint16_t LocationX,uint16_t LocationY,char *Text);
217 void read_slideshow_parameters(slideshow_information_t * SlideshowInfo);
218 void write_slideshow_parameters(slideshow_information_t * SlideshowInfo);
219
220 #endif /* MEM_FLASH_H_ */