CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
结构体 | 宏定义 | 类型定义 | 枚举 | 函数 | 变量
flash_update.c 文件参考
#include "flash_update.h"
#include "ci130x_timer.h"
#include "ci130x_spiflash.h"
#include "ci130x_uart.h"
#include "ci130x_scu.h"
#include "ci_log.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sdk_default_config.h"

结构体

struct  recv_buffer_struct
 

宏定义

#define RECIEVE_BUFFER_COUNT   3
 
#define MSG_HEAD_S   0xa5
 
#define MSG_HEAD_E   0x0f
 
#define MSG_HEAD   0x0FA5
 
#define MSG_TAIL   0xFF
 
#define SRAM_START_ADDR   0x1FFB0000
 
#define MAX_SRAM_CODE_SIZE   (1024*(480-32))
 
#define TCM_START_ADDR   ICACHE_TCM_S
 
#define TCM_SIZE   (ICACHE_TCM_E - ICACHE_TCM_S + 1)
 
#define UPDATE_ERASE_64K   (64 * 1024)
 
#define UPDATE_ERASE_4K   (4 * 1024)
 
#define UPDATE_DEAL_PER_PACKET   (4096)
 
#define MAX_DATA_RECEIVE_PER_PACKET   (UPDATE_DEAL_PER_PACKET+4)/*because buffer address is fixed,so now don't big than 8k*/
 
#define CHAR_BUF_TO_INT_LITTILE(buf)   ((buf)[0]|((buf)[1]<<8)|((buf)[2]<<16)|((buf)[3]<<24))
 

类型定义

typedef struct recv_buffer_struct recv_buffer_t
 

枚举

enum  uart_receive_state_t {
  STATE_HEAD0 = 0x00,
  STATE_HEAD1 = 0x01,
  STAT_LENGTH0 = 0x02,
  STAT_LENGTH1 = 0x03,
  STATE_TYPE = 0x04,
  STATE_CMD = 0x05,
  STATE_NUMBER = 0x06,
  STATE_DATA = 0x07,
  STATE_CRC0 = 0x08,
  STATE_CRC1 = 0x09,
  STATE_TAIL = 0x0a
}
 

函数

recv_buffer_tget_buffer (recv_buffer_t **queue)
 
void append_buffer (recv_buffer_t **queue, recv_buffer_t *p_buffer)
 
int32_t flash_update_buf_init (void)
 
static int32_t flash_erase_function (spic_base_t spic, uint32_t addr, uint32_t size)
 
void send_func (void)
 
void receive_func (uint8_t receive_char)
 
void Resolution_func ()
 
uint16_t crc_func (uint16_t crc, uint8_t *buf, uint32_t len)
 
void make_packet (uint8_t type, uint8_t cmd, uint8_t number, uint8_t *data, uint16_t data_length)
 
void send_req_update_req_packet (void)
 
void send_req_update_write_packet (uint32_t offset, uint32_t size)
 
void send_req_update_write_packet_ex (uint32_t index, uint32_t offset, uint32_t size)
 
void send_req_update_block_write_done_packet (void)
 
void send_ack_system_reset (void)
 
void send_ack_get_info_packet (void)
 
void send_ack_update_check_ready_packet (void)
 
void send_ack_update_block_info_packet (void)
 
void send_ack_update_era_packet (void)
 
void send_ack_update_verify_packet (uint8_t verify)
 
void send_ack_try_fast_bd_packet (void)
 
void send_ack_try_fast_bd_test_packet (uint32_t size)
 
void send_ack_update_read_packet (uint32_t StartAddr, uint32_t Size)
 
void send_ack_update_complet_packet (void)
 
void send_notify_progress_packet (int index, int current, int total)
 
int32_t get_update_state (void)
 
void set_update_complete_status (void)
 
int32_t have_a_new_message (void)
 

变量

uint32_t success_flag = 0
 
uint32_t write_block_addr = 0
 
uint32_t write_block_size = 0
 
uint32_t offset = 0
 
static uint16_t write_block_crc = 0
 
static uint16_t write_block_crc0 = 0
 
Data_p Send_Box = NULL
 
Data_t send_message
 
recv_buffer_t rcv_buffer [3]
 
recv_buffer_tp_recv_buffer = NULL
 
recv_buffer_tfull_buffer_chain = NULL
 
recv_buffer_tidle_buffer_chain = NULL
 
FileConfig_Struct FileConfigInfo
 
uint8_t UpdateState
 
static uint8_t * send_data_buf
 
static uint8_t * read_buf_for_crc
 
static uint8_t rev_state = STATE_HEAD0
 
static uint16_t length0 = 0
 
static uint16_t length1 = 0
 
static uint16_t crc0 = 0
 
static uint16_t crc1 = 0
 
static uint16_t data_rev_count
 
static const uint16_t crc16tab_ccitt [256]
 

详细描述

版本
V1.0.0
日期
2017.12

结构体说明

◆ recv_buffer_struct

struct recv_buffer_struct
成员变量
uint8_t * data_buffer
Data_t message
struct recv_buffer_struct * next

宏定义说明

◆ CHAR_BUF_TO_INT_LITTILE

#define CHAR_BUF_TO_INT_LITTILE (   buf)    ((buf)[0]|((buf)[1]<<8)|((buf)[2]<<16)|((buf)[3]<<24))

◆ MAX_DATA_RECEIVE_PER_PACKET

#define MAX_DATA_RECEIVE_PER_PACKET   (UPDATE_DEAL_PER_PACKET+4)/*because buffer address is fixed,so now don't big than 8k*/

◆ MAX_SRAM_CODE_SIZE

#define MAX_SRAM_CODE_SIZE   (1024*(480-32))

◆ MSG_HEAD

#define MSG_HEAD   0x0FA5

◆ MSG_HEAD_E

#define MSG_HEAD_E   0x0f

◆ MSG_HEAD_S

#define MSG_HEAD_S   0xa5

◆ MSG_TAIL

#define MSG_TAIL   0xFF

◆ RECIEVE_BUFFER_COUNT

#define RECIEVE_BUFFER_COUNT   3

◆ SRAM_START_ADDR

#define SRAM_START_ADDR   0x1FFB0000

◆ TCM_SIZE

#define TCM_SIZE   (ICACHE_TCM_E - ICACHE_TCM_S + 1)

◆ TCM_START_ADDR

#define TCM_START_ADDR   ICACHE_TCM_S

◆ UPDATE_DEAL_PER_PACKET

#define UPDATE_DEAL_PER_PACKET   (4096)

◆ UPDATE_ERASE_4K

#define UPDATE_ERASE_4K   (4 * 1024)

◆ UPDATE_ERASE_64K

#define UPDATE_ERASE_64K   (64 * 1024)

类型定义说明

◆ recv_buffer_t

枚举类型说明

◆ uart_receive_state_t

枚举值
STATE_HEAD0 
STATE_HEAD1 
STAT_LENGTH0 
STAT_LENGTH1 
STATE_TYPE 
STATE_CMD 
STATE_NUMBER 
STATE_DATA 
STATE_CRC0 
STATE_CRC1 
STATE_TAIL 

函数说明

◆ append_buffer()

void append_buffer ( recv_buffer_t **  queue,
recv_buffer_t p_buffer 
)

◆ crc_func()

uint16_t crc_func ( uint16_t  crc,
uint8_t *  buf,
uint32_t  len 
)

◆ flash_erase_function()

static int32_t flash_erase_function ( spic_base_t  spic,
uint32_t  addr,
uint32_t  size 
)
static

◆ flash_update_buf_init()

int32_t flash_update_buf_init ( void  )

◆ get_buffer()

recv_buffer_t* get_buffer ( recv_buffer_t **  queue)

◆ get_update_state()

int32_t get_update_state ( void  )

◆ have_a_new_message()

int32_t have_a_new_message ( void  )

◆ make_packet()

void make_packet ( uint8_t  type,
uint8_t  cmd,
uint8_t  number,
uint8_t *  data,
uint16_t  data_length 
)

◆ receive_func()

void receive_func ( uint8_t  receive_char)

◆ Resolution_func()

void Resolution_func ( )

◆ send_ack_get_info_packet()

void send_ack_get_info_packet ( void  )

◆ send_ack_system_reset()

void send_ack_system_reset ( void  )

◆ send_ack_try_fast_bd_packet()

void send_ack_try_fast_bd_packet ( void  )

◆ send_ack_try_fast_bd_test_packet()

void send_ack_try_fast_bd_test_packet ( uint32_t  size)

◆ send_ack_update_block_info_packet()

void send_ack_update_block_info_packet ( void  )

◆ send_ack_update_check_ready_packet()

void send_ack_update_check_ready_packet ( void  )

◆ send_ack_update_complet_packet()

void send_ack_update_complet_packet ( void  )

◆ send_ack_update_era_packet()

void send_ack_update_era_packet ( void  )

◆ send_ack_update_read_packet()

void send_ack_update_read_packet ( uint32_t  StartAddr,
uint32_t  Size 
)

◆ send_ack_update_verify_packet()

void send_ack_update_verify_packet ( uint8_t  verify)

◆ send_func()

void send_func ( void  )

◆ send_notify_progress_packet()

void send_notify_progress_packet ( int  index,
int  current,
int  total 
)

◆ send_req_update_block_write_done_packet()

void send_req_update_block_write_done_packet ( void  )

◆ send_req_update_req_packet()

void send_req_update_req_packet ( void  )

◆ send_req_update_write_packet()

void send_req_update_write_packet ( uint32_t  offset,
uint32_t  size 
)

◆ send_req_update_write_packet_ex()

void send_req_update_write_packet_ex ( uint32_t  index,
uint32_t  offset,
uint32_t  size 
)

◆ set_update_complete_status()

void set_update_complete_status ( void  )

变量说明

◆ crc0

uint16_t crc0 = 0
static

◆ crc1

uint16_t crc1 = 0
static

◆ crc16tab_ccitt

const uint16_t crc16tab_ccitt[256]
static

◆ data_rev_count

uint16_t data_rev_count
static

◆ FileConfigInfo

FileConfig_Struct FileConfigInfo

◆ full_buffer_chain

recv_buffer_t* full_buffer_chain = NULL

◆ idle_buffer_chain

recv_buffer_t* idle_buffer_chain = NULL

◆ length0

uint16_t length0 = 0
static

◆ length1

uint16_t length1 = 0
static

◆ offset

uint32_t offset = 0

◆ p_recv_buffer

recv_buffer_t* p_recv_buffer = NULL

◆ rcv_buffer

recv_buffer_t rcv_buffer[3]

◆ read_buf_for_crc

uint8_t* read_buf_for_crc
static

◆ rev_state

uint8_t rev_state = STATE_HEAD0
static

◆ Send_Box

Data_p Send_Box = NULL

◆ send_data_buf

uint8_t* send_data_buf
static

◆ send_message

Data_t send_message

◆ success_flag

uint32_t success_flag = 0

◆ UpdateState

uint8_t UpdateState

◆ write_block_addr

uint32_t write_block_addr = 0

◆ write_block_crc

uint16_t write_block_crc = 0
static

◆ write_block_crc0

uint16_t write_block_crc0 = 0
static

◆ write_block_size

uint32_t write_block_size = 0