Files
kunlun/rom/riscv/inc/sFlash.h

53 lines
1.9 KiB
C
Raw Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef _S_FLASH_H_
#define _S_FLASH_H_
enum
{
SFCOP_Program =0x0,
SFCOP_Erase =0x1,
SFCOP_Read =0x2,
SFCOP_Opera =0x3
};
#define FLASH_SECTOR_SIZE 0x1000
#define GET_SEC_NUM(offset) ((offset)&0xFFFFF000)
#define GET_PAGE_NUM(offset) ((offset)&0x00000F00)
#define CMD_SECTOR_ERASE 0x20
#define CMD_WRITE_ENABLE 0x06
#define CMD_PAGE_PROGRAM 0x02
#define CMD_READ_DATA 0x03
#define CMD_READ_STS_REG1 0x05
#define CMD_READ_STS_REG2 0x35
#define CMD_WRITE_STS_REG2 0x31
#define CMD_RESET_ENABLE 0x66
#define CMD_RESET 0x99
#define DEFAULT_CMD_ADDR 0x00
void SFC_SET_SWM(uint32_t md, uint32_t cyc);
void SFC_OPR_SET(uint8_t cmd, uint32_t addr, uint8_t mode, uint32_t dlen);
void SFC_OPR_SET_AND_RAISE(uint8_t cmd, uint32_t addr, uint8_t mode, uint32_t dlen);
void SFC_SKIP_BUSY();
void SFC_BUFF_COPY(char *dst, char *src, uint32_t cnt);
void SFC_PE_WT_TIME(uint32_t t);
void sFlashInit(void);
void sFlashPageWrite(int offset, char *pBuf);
void sFlashPageRead(int offset, char *pBuf);
#endif