/*********************************************************
//file		:hd_dev_gpio.h
//author	:libo
//date		:2020/05/10
//version	:V1.0
//brief		:GSP HAL层GPIO接口H文件
*********************************************************/
#ifndef FUNC_QUEUE_RECORD_H
#define FUNC_QUEUE_RECORD_H

/* Includes----------------------------------------------------------------------------------*/
#include "cmsis_os.h" /* _FS_REENTRANT set to 1 and CMSIS API chosen */

/* Public macro------------------------------------------------------------------------------*/
#define QUEUE_MSG_Q_NUM 			8    
#define QUEUE_MSG_ITEM_SIZE		256    

/* Public define-----------------------------------------------------------------------------*/

/* Public typedef----------------------------------------------------------------------------*/
typedef struct{
	QueueHandle_t hQueue;				//信息队列句柄
	uint32_t 			remain_size;	//队列剩余大小
	uint32_t 			used_size;		//队列使用大小
	uint32_t 			total_size;		//消息队列总大小
}record_queue_object;

typedef struct queue_record_object
{
	uint8_t 	link_ok; 				//用于标识当前状态是1：读取，0：写入；
	uint8_t   flash_ok;					//存储器状态标志
	uint32_t 	running;
	uint32_t 	wr_idx;
	uint32_t 	msg_cnt;
	uint32_t 	wr_cnt;
	uint32_t 	rd_cnt;
	uint8_t 	opt_flag;
	char 			buf[QUEUE_MSG_ITEM_SIZE];
	uint32_t 	buf_len;
	char        cmd[32];
	int32_t 	(*flash_pop) (void *buf, uint32_t len);
	int32_t 	(*flash_push)(void *buf, uint32_t len);
}queue_record_object;

/* public function---------------------------------------------------------------------------*/
extern record_queue_object lifo_queue_obj;
extern record_queue_object fifo_queue_obj;
extern queue_record_object queue_record_obj;

void 		func_record_queue_init(void);
void 		func_record_queue_work(void);
void 		func_record_queue_main(void const *argument);
void 		func_record_queue_check(record_queue_object * queue_obj);
void 		func_record_queue_update(void);

uint32_t func_record_queue_write(void *buf ,uint32_t len);
uint32_t func_record_queue_read(void *buf ,uint32_t len);
uint32_t func_record_queue_obj_cnt(void);
void 		 func_record_queue_link_set(uint8_t stat);
uint8_t  func_record_queue_link_get(void);
uint8_t  func_record_queue_flash_get(void);
uint8_t func_record_queue_flash_set(uint8_t stat);
void 		func_record_queue_test(void);
#endif    /*********FUNC_QUEUE_RECORD_H****************/
/******************************the end of file************************************************/

