![]() |
CI13LC SDK API手册
2.1.1
本手册用于描述CI13LC SDK各个组件和驱动API
|
SPIFLASH驱动文件 更多...
#include <string.h>#include "ci_spiflash.h"#include "ci_dma.h"#include "ci_scu.h"#include "ci_dpmu.h"#include "ci_core_eclic.h"#include "ci_dtrflash.h"#include "romlib_api.h"#include "ci_log.h"宏定义 | |
| #define | SPIC_MS (get_apb_clk() / 1000) /* 60000000 / 1000 */ |
| #define | OTHER_TIMR (20UL) /* ms */ |
| #define | ERASE_64K (64 * 1024) |
| #define | ERASE_4K (4 * 1024) |
| #define | FLASH_PAGE_SIZE (256) |
| #define | SPIC_DUMMY_BYTE (8) /*单线模式时,1个byte数据的dummy cycle是8*/ |
| #define | SPIFLASH_CPU (1) /*数据FIFO:0,DMA模式,1,CPU模式 */ |
| #define | SPIFLASH_CMD_QUAD (MD_SEL_LINE_1) /*命令模式:0,单线,1,四线 */ |
| #define | SPIFLASH_DATA_QUAD (MD_SEL_LINE_4) /*数据模式:0,单线,1,四线 */ |
| #define | SPIFLASH_NORMAL_READ (1) /*0:不使用普通读,1:使用普通读 */ |
| #define | SPIFLASH_NORMAL_CLK (FLASH_CLK_DIV_4) /*240M主频,普通模式读写只能4分频 */ |
| #define | SPIFLASH_XIP_CLK (FLASH_CLK_DIV_2) /*240M主频,XIP可以2分频 */ |
| #define | SPIC_FLASH_SEL (0) /*双Flash选择:0或1*/ |
| #define | SPIC_ADDR_SIZE (3) /*Address的数据长度:单位Bytes*/ |
| #define | SPIC_FLASH_DRV0_DRV1 (1) /*FLASH驱动能力,0:25%,1:50%,2:75%,3:100% */ |
| #define | FLASH_READ_STATUS (0) /*FLASH读状态寄存器开关*/ |
枚举 | |
| enum | spic_status_protect_t { SPIC_SOFTWAREPROTECTION =0, SPIC_HARDWAREPROTECTION =1, SPIC_POWERSUPPLYLOCK_DOWN =2, SPIC_ONETIMEPROGRAM =3, SPIC_RESV =-1 } |
| SPI保护类型定义 更多... | |
函数 | |
| static void | flash_set_status_size () |
| static uint8_t | flash_get_status_size () |
| static int32_t | spic_send_cmd (spic_base_t spic, spic_cmd_code_t cmd) |
| 向flash发送命令 更多... | |
| static int32_t | spic_read_cmd_value (spic_base_t spic, spic_cmd_code_t cmd, uint8_t *value, uint8_t value_len) |
| 读flash某些命令的值 更多... | |
| static int32_t | spic_quad_enable (spic_base_t spic, uint8_t cmd_md, uint8_t data_md) |
| 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 更多... | |
| int32_t | spic_quad_mode (spic_base_t spic) |
| 设置FLASH四线模式 更多... | |
| static int32_t | spic_powerdown_release (spic_base_t spic) |
| powerdown release 更多... | |
| 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的安全寄存器上锁,慎用:上锁之后将导致该安全寄存器不可再次编程 更多... | |
| 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_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 更多... | |
变量 | |
| static uint8_t | spic_cmd_quad_flag = MD_SEL_LINE_1 |
| static uint8_t | spic_data_quad_flag = MD_SEL_LINE_1 |
| static uint8_t | flash_status_size = 0 |
SPIFLASH驱动文件
| #define ERASE_4K (4 * 1024) |
| #define ERASE_64K (64 * 1024) |
| #define FLASH_PAGE_SIZE (256) |
| #define FLASH_READ_STATUS (0) /*FLASH读状态寄存器开关*/ |
| #define OTHER_TIMR (20UL) /* ms */ |
| #define SPIC_ADDR_SIZE (3) /*Address的数据长度:单位Bytes*/ |
| #define SPIC_DUMMY_BYTE (8) /*单线模式时,1个byte数据的dummy cycle是8*/ |
| #define SPIC_FLASH_DRV0_DRV1 (1) /*FLASH驱动能力,0:25%,1:50%,2:75%,3:100% */ |
| #define SPIC_FLASH_SEL (0) /*双Flash选择:0或1*/ |
| #define SPIC_MS (get_apb_clk() / 1000) /* 60000000 / 1000 */ |
| #define SPIFLASH_CMD_QUAD (MD_SEL_LINE_1) /*命令模式:0,单线,1,四线 */ |
| #define SPIFLASH_CPU (1) /*数据FIFO:0,DMA模式,1,CPU模式 */ |
| #define SPIFLASH_DATA_QUAD (MD_SEL_LINE_4) /*数据模式:0,单线,1,四线 */ |
| #define SPIFLASH_NORMAL_CLK (FLASH_CLK_DIV_4) /*240M主频,普通模式读写只能4分频 */ |
| #define SPIFLASH_NORMAL_READ (1) /*0:不使用普通读,1:使用普通读 */ |
| #define SPIFLASH_XIP_CLK (FLASH_CLK_DIV_2) /*240M主频,XIP可以2分频 */ |
|
static |
|
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 |
|
static |
spiflash 写规则
| spic | spiflash控制器 |
| buf | mem地址 |
| addr | flash地址 |
| size | 大小 |
| RETURN_OK | |
| RETURN_ERR |
|
static |
检查BUSY状态
| spic | spiflash控制器组 |
| timeout | 超时时间 |
| RETURN_OK | |
| RETURN_ERR |
| int32_t spic_erase | ( | spic_base_t | spic, |
| spic_cmd_code_t | code, | ||
| uint32_t | addr | ||
| ) |
擦除FLASH
| spic | spiflash控制器 |
| code | 擦除命令 |
| addr | 擦除地址 |
| RETURN_OK | |
| RETURN_ERR |
|
static |
powerdown release
| spic | spiflash控制器 |
| RETURN_OK | |
| RETURN_ERR |
|
static |
| int32_t spic_quad_mode | ( | spic_base_t | spic | ) |
设置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 |
读flash某些命令的值
| spic | spiflash控制器组 |
| cmd | 命令 |
| value | 值缓存区地址 |
| value_len | 值长度 |
| RETURN_OK、RETURN_ERR |
| int32_t spic_read_status_register | ( | spic_base_t | spic, |
| spic_cmd_code_t | reg, | ||
| uint8_t * | status | ||
| ) |
读取状态寄存器
| spic | spiflash控制器组 |
| reg | 状态寄存器 |
| status | 读取到的状态值 |
| RETURN_OK | |
| RETURN_ERR |
| int32_t spic_reset | ( | spic_base_t | spic | ) |
reset flash
| spic | spiflash控制器 |
| RETURN_OK | |
| RETURN_ERR |
|
static |
向flash发送命令
| spic | spiflash控制器组 |
| cmd | 命令 |
| RETURN_OK、RETURN_ERR |
|
static |
写状态寄存器
| spic | spiflash控制器组 |
| reg1 | 状态寄存器1的值 |
| reg2 | 状态寄存器2的值 |
| RETURN_OK | |
| RETURN_ERR |
|
static |
|
static |
|
static |
1.8.14