![]() |
CI130X SDK API手册
2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
|
SPIFLASH驱动文件 更多...
#include <string.h>
#include "ci130x_spiflash.h"
#include "ci130x_dma.h"
#include "ci130x_scu.h"
#include "ci130x_dpmu.h"
#include "ci130x_core_eclic.h"
#include "ci130x_dtrflash.h"
#include "platform_config.h"
#include "romlib_runtime.h"
#include "ci_log.h"
宏定义 | |
#define | SPIC_CLK (get_apb_clk()) |
#define | SPIC_MS (SPIC_CLK / 1000) |
#define | OTHER_TIMR (20UL) /* ms */ |
#define | ERASE_64K (64 * 1024) |
#define | ERASE_4K (4 * 1024) |
#define | FLASH_PAGE_SIZE (256) |
#define | SPIFLASH_CPU (0) /*数据FIFO:0,DMA模式,1,CPU模式 */ |
#define | SPIFLASH_CMD_QUAD (0) /*命令模式:0,单线,1,四线 */ |
#define | SPIFLASH_DATA_QUAD (1) /*数据模式:0,单线,1,四线 */ |
#define | SPIFLASH_NORMAL_READ (1) /*0:不使用普通读,1:使用普通读 */ |
#define | SPIFLASH_NORMAL_WRITE_READ_CLK (FLASH_CLK_DIV_4) /*240M主频,普通模式读写只能4分频 */ |
#define | SPIFLASH_XIP_READ_CLK (FLASH_CLK_DIV_2) /*240M主频,XIP可以2分频 */ |
枚举 | |
enum | spic_status_protect_t { SPIC_SOFTWAREPROTECTION =0, SPIC_HARDWAREPROTECTION =1, SPIC_POWERSUPPLYLOCK_DOWN =2, SPIC_ONETIMEPROGRAM =3, SPIC_RESV =-1 } |
SPI保护类型定义 更多... | |
函数 | |
static int32_t | spic_send_cmd (spic_base_t spic, spic_cmd_code_t cmd) |
static int32_t | spic_read_cmd_value (spic_base_t spic, spic_cmd_code_t cmd, uint8_t *value, uint8_t value_len) |
static int32_t | spic_quad_enable (spic_base_t spic, uint8_t cmd_md, uint8_t data_md) |
static int32_t | spic_read_status_register (spic_base_t spic, spic_cmd_code_t reg, uint8_t *status) |
读取状态寄存器 更多... | |
static int32_t | spic_check_busy (spic_base_t spic, int32_t timeout) |
检查BUSY状态 更多... | |
static int32_t | spic_write_status_register (spic_base_t spic, char reg1, char reg2, char reg3) |
写状态寄存器 更多... | |
int32_t | spic_read_unique_id (spic_base_t spic, uint8_t *unique) |
读取Unique ID 更多... | |
int32_t | spic_read_jedec_id (spic_base_t spic, uint8_t *jedec) |
读取Jedec ID 更多... | |
static int32_t | spic_quad_mode (spic_base_t spic) |
设置FLASH四线模式 更多... | |
static int32_t | spic_powerdown (spic_base_t spic) |
powerdown 更多... | |
static int32_t | spic_releasepowerdown (spic_base_t spic) |
releasepowerdown 更多... | |
static int32_t | spic_reset (spic_base_t spic) |
reset flash 更多... | |
int32_t | spic_protect (spic_base_t spic, FunctionalState cmd) |
FLASH保护设置 更多... | |
int32_t | spic_erase_security_reg (spic_base_t spic, spic_security_reg_t reg) |
擦除FLASH安全寄存器 更多... | |
int32_t | spic_write_security_reg (spic_base_t spic, spic_security_reg_t reg, uint32_t buf, uint32_t addr, uint32_t size) |
写FLASH的安全寄存器 更多... | |
int32_t | spic_read_security_reg (spic_base_t spic, spic_security_reg_t reg, uint32_t buf, uint32_t addr, uint32_t size) |
读FLASH的安全寄存器 更多... | |
int32_t | spic_security_reg_lock (spic_base_t spic, spic_security_reg_t reg) |
FLASH的安全寄存器上锁,慎用:上锁之后将导致该安全寄存器不可再次编程 更多... | |
static int32_t | spic_erase (spic_base_t spic, spic_cmd_code_t code, uint32_t addr) |
擦除FLASH 更多... | |
int32_t | spic_quad_write_page (spic_base_t spic, uint32_t buf, uint32_t addr, uint32_t size) |
写FLASH的某一页 更多... | |
int32_t | spic_quad_read_page (spic_base_t spic, uint32_t buf, uint32_t addr, uint32_t size) |
读FLASH的某一块 更多... | |
int32_t | spic_xipconfig (spic_base_t spic) |
FLASH的XIP模式初始化 更多... | |
int32_t | flash_clk_div_init (spic_base_t spic) |
FLASH时钟初始化 更多... | |
int32_t | flash_init (spic_base_t spic) |
FLASH普通模式初始化 更多... | |
static int32_t | flash_policy_erase (spic_base_t spic, uint32_t addr, uint32_t size) |
FLASH擦除 更多... | |
static int32_t | flash_write_rule (spic_base_t spic, uint32_t buf, uint32_t addr, uint32_t size) |
spiflash 写规则 更多... | |
static int32_t | flash_quad_write (spic_base_t spic, uint32_t addr, uint32_t buf, uint32_t size) |
写FLASH 更多... | |
static int32_t | flash_quad_read (spic_base_t spic, uint32_t buf, uint32_t addr, uint32_t size) |
读FLASH 更多... | |
int32_t | flash_erase (spic_base_t spic, uint32_t addr, uint32_t size) |
FLASH擦除,兼容32M以上Flash 更多... | |
int32_t | flash_write (spic_base_t spic, uint32_t addr, uint32_t buf, uint32_t size) |
写FLASH,兼容32M以上Flash 更多... | |
int32_t | flash_read (spic_base_t spic, uint32_t buf, uint32_t addr, uint32_t size) |
读FLASH,兼容32M以上Flash 更多... | |
变量 | |
uint8_t | spi_flash_drv0_drv1 = 1 |
uint8_t | spic_cmd_quad_flag = 0 |
uint8_t | spic_data_quad_flag = 0 |
SPIFLASH驱动文件
#define ERASE_4K (4 * 1024) |
#define ERASE_64K (64 * 1024) |
#define FLASH_PAGE_SIZE (256) |
#define OTHER_TIMR (20UL) /* ms */ |
#define SPIC_CLK (get_apb_clk()) |
#define SPIC_MS (SPIC_CLK / 1000) |
#define SPIFLASH_CMD_QUAD (0) /*命令模式:0,单线,1,四线 */ |
#define SPIFLASH_CPU (0) /*数据FIFO:0,DMA模式,1,CPU模式 */ |
#define SPIFLASH_DATA_QUAD (1) /*数据模式:0,单线,1,四线 */ |
#define SPIFLASH_NORMAL_READ (1) /*0:不使用普通读,1:使用普通读 */ |
#define SPIFLASH_NORMAL_WRITE_READ_CLK (FLASH_CLK_DIV_4) /*240M主频,普通模式读写只能4分频 */ |
#define SPIFLASH_XIP_READ_CLK (FLASH_CLK_DIV_2) /*240M主频,XIP可以2分频 */ |
|
static |
FLASH擦除
spic | spiflash控制器 |
addr | 地址 |
size | 大小 |
RETURN_OK | |
RETURN_ERR |
|
static |
读FLASH
spic | spiflash控制器 |
buf | mem地址 |
addr | FLASH地址 |
size | 大小 |
RETURN_OK | |
RETURN_ERR |
|
static |
写FLASH
spic | spiflash控制器 |
addr | FLASH地址 |
buf | mem地址 |
size | 大小 |
RETURN_OK | |
RETURN_ERR |
|
static |
spiflash 写规则
spic | spiflash控制器 |
buf | mem地址 |
addr | flash地址 |
size | 大小 |
RETURN_OK | |
RETURN_ERR |
|
static |
检查BUSY状态
spic | spiflash控制器组 |
timeout | 超时时间 |
RETURN_OK | |
RETURN_ERR |
|
static |
擦除FLASH
spic | spiflash控制器 |
code | 擦除命令 |
addr | 擦除地址 |
RETURN_OK | |
RETURN_ERR |
|
static |
powerdown
spic | spiflash控制器 |
RETURN_OK | |
RETURN_ERR |
|
static |
|
static |
设置FLASH四线模式
spic | spiflash控制器 |
RETURN_OK | |
RETURN_ERR |
int32_t spic_quad_read_page | ( | spic_base_t | spic, |
uint32_t | buf, | ||
uint32_t | addr, | ||
uint32_t | size | ||
) |
读FLASH的某一块
spic | spiflash控制器 |
buf | mem地址 |
addr | FLASH地址 |
size | 读FLASH的字节数 |
RETURN_OK | |
RETURN_ERR |
int32_t spic_quad_write_page | ( | spic_base_t | spic, |
uint32_t | buf, | ||
uint32_t | addr, | ||
uint32_t | size | ||
) |
写FLASH的某一页
spic | spiflash控制器 |
buf | mem地址 |
addr | FLASH地址 |
size | 写FLASH的字节数 |
RETURN_OK | |
RETURN_ERR |
|
static |
|
static |
读取状态寄存器
spic | spiflash控制器组 |
reg | 状态寄存器 |
status | 读取到的状态值 |
RETURN_OK | |
RETURN_ERR |
|
static |
releasepowerdown
spic | spiflash控制器 |
RETURN_OK | |
RETURN_ERR |
|
static |
reset flash
spic | spiflash控制器 |
RETURN_OK | |
RETURN_ERR |
|
static |
|
static |
写状态寄存器
spic | spiflash控制器组 |
reg1 | 状态寄存器1的值 |
reg2 | 状态寄存器2的值 |
RETURN_OK | |
RETURN_ERR |
uint8_t spi_flash_drv0_drv1 = 1 |
uint8_t spic_cmd_quad_flag = 0 |
uint8_t spic_data_quad_flag = 0 |