![]() |
CI130X SDK API手册
2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
|
#include "ci130x_dtrflash.h"
#include "ci130x_system.h"
#include "ci130x_dma.h"
#include "romlib_runtime.h"
结构体 | |
struct | spic_register |
struct | spic_config_t |
宏定义 | |
#define | DMAC_CHANNEL0_LOCK() do{}while(0); |
#define | DMAC_CHANNEL0_UNLOCK() do{}while(0); |
#define | SPIC_TIMEOUT_ARBT (5000) |
#define | SPIC_TIMEOUT_MAIN_CTRL (5000) |
#define | SPIC_TIMEOUT_DMA (5000) |
#define | SPIC_FIFO_ADDR (0x50000000) |
#define | SPIC_DMA_FIFO_ADDR (0x60000000) |
#define | SPIC_CS_HIGH_CYCLE (1) |
#define | SPIC_CS_LOW_CYCLE (1) |
#define | SPIC_WFIFO_AMFULL_LEVEL (60) |
#define | SPIC_RFIFO_AMEMPTY_LEVEL (60) |
#define | SPIC_RFIFO_AMFULL_LEVEL (4) |
#define | STATE_REG_GM_DONE_INT (0x1 << 3) |
类型定义 | |
typedef volatile struct spic_register | spic_register_t |
typedef volatile struct spic_register * | spic_register_p |
typedef struct spic_config_t * | spic_config_p |
函数 | |
void | spic_change_clk (uint32_t spic_base, flash_clk_div_t clk) |
static int32_t | spic_wait_idle (uint32_t spic_base) |
等待spic空闲 更多... | |
static int32_t | spic_ready_change_mode (uint32_t spic_base) |
spic是否能够进行模式切换 更多... | |
static int32_t | spic_general_mode_config (uint32_t spic_base, spic_config_p config) |
通用模式配置 更多... | |
static int32_t | spic_xip_read_mode_config (uint32_t spic_base, spic_config_p config) |
XIP模式读数据 更多... | |
static int32_t | spic_config_init (spic_config_p config, spic_base_config_p spic_base_config) |
配置结构体简化 更多... | |
int32_t | spic_cmd (uint32_t spic_base, spic_base_config_p spic_base_config) |
spic向flash发送命令 更多... | |
int32_t | spic_read_by_cpu (uint32_t spic_base, spic_base_config_p spic_base_config, uint8_t *read_data, uint32_t read_len) |
spic以CPU的方式向flash读数据 更多... | |
int32_t | spic_write_by_cpu (uint32_t spic_base, spic_base_config_p spic_base_config, uint8_t *write_data, uint32_t write_len) |
spic以CPU的方式向flash写数据 更多... | |
int32_t | spic_read_by_dma (uint32_t spic_base, spic_base_config_p spic_base_config, uint8_t *read_data, uint32_t read_len) |
spic以DMA的方式向flash读数据 更多... | |
int32_t | spic_write_by_dma (uint32_t spic_base, spic_base_config_p spic_base_config, uint8_t *write_data, uint32_t write_len) |
spic以DMA的方式向flash写数据 更多... | |
int32_t | spic_xip_config (uint32_t spic_base, spic_base_config_p spic_base_config) |
int32_t | spic_init (uint32_t spic_base, spic_init_p init) |
spic控制器初始化 更多... | |
int32_t | spic_clk_phase_set (uint32_t spic_base, uint32_t tx_shift, uint32_t tx_nege_en, uint32_t rx_shift, uint32_t rx_nege_en) |
flash时钟相位调制 更多... | |
void | spic_prefetch_en (uint32_t spic_base, bool en) |
flash预取开关 更多... | |
变量 | |
static uint8_t | spi_dma_buf [512] |
static uint32_t | global_flash_sel = 0 |
static uint32_t | global_addr_size = 0 |
DMACChannelx | dmachanel = DMACChannel0 |
typedef | enum |
struct spic_register |
struct spic_config_t |
#define DMAC_CHANNEL0_LOCK | ( | ) | do{}while(0); |
#define DMAC_CHANNEL0_UNLOCK | ( | ) | do{}while(0); |
#define SPIC_CS_HIGH_CYCLE (1) |
#define SPIC_CS_LOW_CYCLE (1) |
#define SPIC_DMA_FIFO_ADDR (0x60000000) |
#define SPIC_FIFO_ADDR (0x50000000) |
#define SPIC_RFIFO_AMEMPTY_LEVEL (60) |
#define SPIC_RFIFO_AMFULL_LEVEL (4) |
#define SPIC_TIMEOUT_ARBT (5000) |
#define SPIC_TIMEOUT_DMA (5000) |
#define SPIC_TIMEOUT_MAIN_CTRL (5000) |
#define SPIC_WFIFO_AMFULL_LEVEL (60) |
#define STATE_REG_GM_DONE_INT (0x1 << 3) |
typedef struct spic_config_t* spic_config_p |
typedef volatile struct spic_register* spic_register_p |
typedef volatile struct spic_register spic_register_t |
void spic_change_clk | ( | uint32_t | spic_base, |
flash_clk_div_t | clk | ||
) |
int32_t spic_clk_phase_set | ( | uint32_t | spic_base, |
uint32_t | tx_shift, | ||
uint32_t | tx_nege_en, | ||
uint32_t | rx_shift, | ||
uint32_t | rx_nege_en | ||
) |
flash时钟相位调制
tx_shift | 偏移X个core_clk,注意X必须小于core_clk与flash_clk的频率倍数(dtr模式下小于倍数的一半) |
tx_nege_en | 配置为1时在shift的基础上再向后平移半个core_clk周期 |
rx_shift | 偏移X个core_clk,注意X必须小于core_clk与flash_clk的频率倍数(dtr模式下小于倍数的一半) |
rx_nege_en | 配置为1时在shift的基础上再向后平移半个core_clk周期 |
int32_t spic_cmd | ( | uint32_t | spic_base, |
spic_base_config_p | spic_base_config | ||
) |
spic向flash发送命令
spic_base_config | 配置结构体指针 |
|
static |
配置结构体简化
config | 完整的配置结构体指针 |
spic_base_config | 简化版配置结构体指针 |
|
static |
通用模式配置
config | 配置结构体指针 |
int32_t spic_init | ( | uint32_t | spic_base, |
spic_init_p | init | ||
) |
spic控制器初始化
init | 初始化结构体 |
void spic_prefetch_en | ( | uint32_t | spic_base, |
bool | en | ||
) |
flash预取开关
en | enable:开启;disable:关闭; |
int32_t spic_read_by_cpu | ( | uint32_t | spic_base, |
spic_base_config_p | spic_base_config, | ||
uint8_t * | read_data, | ||
uint32_t | read_len | ||
) |
spic以CPU的方式向flash读数据
spic_base_config | 配置结构体指针 |
read_data | 数据指针 |
read_len | 数据长度 |
int32_t spic_read_by_dma | ( | uint32_t | spic_base, |
spic_base_config_p | spic_base_config, | ||
uint8_t * | read_data, | ||
uint32_t | read_len | ||
) |
spic以DMA的方式向flash读数据
spic_base_config | 配置结构体指针 |
read_data | 数据指针 |
read_len | 数据长度 |
|
static |
spic是否能够进行模式切换
|
static |
等待spic空闲
int32_t spic_write_by_cpu | ( | uint32_t | spic_base, |
spic_base_config_p | spic_base_config, | ||
uint8_t * | write_data, | ||
uint32_t | write_len | ||
) |
spic以CPU的方式向flash写数据
spic_base_config | 配置结构体指针 |
write_data | 数据指针 |
write_len | 数据长度 |
int32_t spic_write_by_dma | ( | uint32_t | spic_base, |
spic_base_config_p | spic_base_config, | ||
uint8_t * | write_data, | ||
uint32_t | write_len | ||
) |
spic以DMA的方式向flash写数据
spic_base_config | 配置结构体指针 |
write_data | 数据指针 |
write_len | 数据长度 |
int32_t spic_xip_config | ( | uint32_t | spic_base, |
spic_base_config_p | spic_base_config | ||
) |
|
static |
XIP模式读数据
config | 配置结构体指针 |
DMACChannelx dmachanel = DMACChannel0 |
typedef enum |
< 功能:flash fifo时钟与sram时钟频率关系 功能:同频 功能:2分频 功能:4分频
|
static |
|
static |
|
static |