95 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			95 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifndef CLI_IC_TOOL_H
							 | 
						||
| 
								 | 
							
								#define CLI_IC_TOOL_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* pack for the structures in the whole file */
							 | 
						||
| 
								 | 
							
								#pragma pack(push)  // save the pack status
							 | 
						||
| 
								 | 
							
								#pragma pack(1)     // 1 byte align
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct cli_cmd_read_data {
							 | 
						||
| 
								 | 
							
								    uint32_t addr;
							 | 
						||
| 
								 | 
							
								    uint16_t length;
							 | 
						||
| 
								 | 
							
								    uint8_t operation_type;
							 | 
						||
| 
								 | 
							
								} cli_cmd_read_data_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								typedef struct _cli_data_info {
							 | 
						||
| 
								 | 
							
								    uint32_t addr;
							 | 
						||
| 
								 | 
							
								    uint8_t operation_type;
							 | 
						||
| 
								 | 
							
								    uint16_t len;
							 | 
						||
| 
								 | 
							
								    uint8_t data[];
							 | 
						||
| 
								 | 
							
								} cli_data_info;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* data info */
							 | 
						||
| 
								 | 
							
								typedef struct _cli_reg_info {
							 | 
						||
| 
								 | 
							
								    uint32_t addr;
							 | 
						||
| 
								 | 
							
								    uint8_t operation_type;
							 | 
						||
| 
								 | 
							
								    uint32_t value;
							 | 
						||
| 
								 | 
							
								} cli_reg_info;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* set data ack */
							 | 
						||
| 
								 | 
							
								typedef struct _cli_set_data_ack {
							 | 
						||
| 
								 | 
							
								    uint32_t addr;
							 | 
						||
| 
								 | 
							
								    uint16_t len;
							 | 
						||
| 
								 | 
							
								    uint8_t operation_type;
							 | 
						||
| 
								 | 
							
								    uint8_t result;
							 | 
						||
| 
								 | 
							
								} cli_set_data_ack;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								enum CLI_DATA_OPERATION_TYPE {
							 | 
						||
| 
								 | 
							
								    CLI_DATA_OPERATION_TYPE_REG,
							 | 
						||
| 
								 | 
							
								    CLI_DATA_OPERATION_TYPE_RAM,
							 | 
						||
| 
								 | 
							
								    CLI_DATA_OPERATION_TYPE_FLASH,
							 | 
						||
| 
								 | 
							
								    CLI_DATA_OPERATION_TYPE_REG_GROUP,
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief This function is used to read data from the common memory.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param buffer is required by function.
							 | 
						||
| 
								 | 
							
								 * @param length is required by function.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cli_common_memory_read_data(iot_pkt_t *buffer, uint32_t length);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief This function is used to write data from the common memory.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param buffer is required by function.
							 | 
						||
| 
								 | 
							
								 * @param length is required by function.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void cli_common_memory_write_data(iot_pkt_t *buffer, uint32_t bufferlen);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief This function is used to msgid processing.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param msgid is required by function.
							 | 
						||
| 
								 | 
							
								 * @param buffer is required by function.
							 | 
						||
| 
								 | 
							
								 * @param length is required by function.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_ic_tool_op(int msgid, iot_pkt_t* buffer, uint32_t len);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)   // restore the pack status
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* CLI_IC_TOOL_H */
							 | 
						||
| 
								 | 
							
								
							 |