flash.h
Go to the documentation of this file.
1 /********************************************************************************************************
2  * @file flash.h
3  *
4  * @brief This is the header file for TLSR8258
5  *
6  * @author Driver Group
7  * @date May 8, 2018
8  *
9  * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd.
10  * All rights reserved.
11  *
12  * The information contained herein is confidential property of Telink
13  * Semiconductor (Shanghai) Co., Ltd. and is available under the terms
14  * of Commercial License Agreement between Telink Semiconductor (Shanghai)
15  * Co., Ltd. and the licensee or the terms described here-in. This heading
16  * MUST NOT be removed from this file.
17  *
18  * Licensees are granted free, non-transferable use of the information in this
19  * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
20  * @par History:
21  * 1.initial release(DEC. 26 2018)
22  *
23  * @version A001
24  *
25  *******************************************************************************************************/
26 
27 #pragma once
28 
29 #include "compiler.h"
30 
34 enum{
42  FLASH_GD_PUYA_READ_UID_CMD = 0x4B, //Flash Type = GD/PUYA
44  FLASH_XTX_READ_UID_CMD = 0x5A, //Flash Type = XTX
45  FLASH_CHIP_ERASE_CMD = 0x60, //or 0xc7
46  FLASH_PAGE_ERASE_CMD = 0x81, //caution: only P25Q40L support this function
51 
52 };
53 
58 typedef enum{
63 
70 _attribute_ram_code_ void flash_erase_page(unsigned int addr);
71 
77 _attribute_ram_code_ void flash_erase_sector(unsigned long addr);
78 
84 void flash_erase_32kblock(unsigned int addr);
85 
91 void flash_erase_64kblock(unsigned int addr);
92 
98 void flash_erase_chip(void);
99 
107 _attribute_ram_code_ void flash_write_page(unsigned long addr, unsigned long len, unsigned char *buf);
108 
116 _attribute_ram_code_ void flash_read_page(unsigned long addr, unsigned long len, unsigned char *buf);
117 
123 unsigned char flash_write_status(unsigned char data);
124 
130 unsigned char flash_read_status(void);
131 
141 void flash_deep_powerdown(void);
142 
154 
155 /***********************************
156  * @brief This function serves to read MID of flash
157  * @param[in] buf - store MID of flash
158  * @return none.
159  */
160 void flash_read_mid(unsigned char *buf);
161 
169 void flash_read_uid(unsigned char idcmd,unsigned char *buf);
177 int flash_read_mid_uid_with_check( unsigned int *flash_mid ,unsigned char *flash_uid);
184 void flash_lock(Flash_TypeDef type , unsigned short data);
185 
191 void flash_unlock(Flash_TypeDef type);
192 
193 
194 
195 
196 
197 
198 
199 
200 
201  //end of GP4
Definition: flash.h:60
Definition: flash.h:42
Definition: flash.h:45
void flash_release_deep_powerdown(void)
The Release from Power-Down or High Performance Mode/Device ID command is a Multi-purpose command...
void flash_lock(Flash_TypeDef type, unsigned short data)
This function serves to protect data for flash.
Definition: flash.h:59
unsigned char flash_write_status(unsigned char data)
This function write the status of flash.
void flash_erase_64kblock(unsigned int addr)
This function serves to erase a block(64k).
Definition: flash.h:48
void flash_unlock(Flash_TypeDef type)
This function serves to protect data for flash.
void flash_read_mid(unsigned char *buf)
Definition: flash.h:43
Definition: flash.h:39
_attribute_ram_code_ void flash_erase_sector(unsigned long addr)
This function serves to erase a sector.
Definition: flash.h:38
Definition: flash.h:47
Definition: flash.h:50
unsigned char flash_read_status(void)
This function reads the status of flash.
#define _attribute_ram_code_
Definition: compiler.h:33
Definition: flash.h:40
_attribute_ram_code_ void flash_read_page(unsigned long addr, unsigned long len, unsigned char *buf)
This function reads the content from a page to the buf.
void flash_erase_chip(void)
This function serves to erase a page(256 bytes).
void flash_erase_32kblock(unsigned int addr)
This function serves to erase a block(32k).
_attribute_ram_code_ void flash_write_page(unsigned long addr, unsigned long len, unsigned char *buf)
This function writes the buffer's content to a page.
void flash_deep_powerdown(void)
Deep Power Down mode to put the device in the lowest consumption mode it can be used as an extra soft...
Flash_TypeDef
flash type definition
Definition: flash.h:58
Definition: flash.h:37
Definition: flash.h:49
Definition: flash.h:46
void flash_read_uid(unsigned char idcmd, unsigned char *buf)
This function serves to read UID of flash.
_attribute_ram_code_ void flash_erase_page(unsigned int addr)
This function serves to erase a page(256 bytes).
Definition: flash.h:35
Definition: flash.h:61
int flash_read_mid_uid_with_check(unsigned int *flash_mid, unsigned char *flash_uid)
This function serves to read flash mid and uid,and check the correctness of mid and uid...
Definition: flash.h:44
Definition: flash.h:41
Definition: flash.h:36