111 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			111 lines
		
	
	
		
			3.2 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 IOT_IPC_H
							 | 
						||
| 
								 | 
							
								#define IOT_IPC_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								#include "iot_ipc_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* max family number supported */
							 | 
						||
| 
								 | 
							
								#define IOT_IPC_FAMILY_MAX              5
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* max client number each family supported */
							 | 
						||
| 
								 | 
							
								#define IOT_IPC_CLIENT_PER_F_MAX        4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define ipc uart message command */
							 | 
						||
| 
								 | 
							
								#define IOT_IPC_UART_MSG_CMD_FWD        0
							 | 
						||
| 
								 | 
							
								#define IOT_IPC_UART_MSG_CMD_CALLBACK   1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* pack for the structures in the whole file */
							 | 
						||
| 
								 | 
							
								#pragma pack(push)  /* save the pack status */
							 | 
						||
| 
								 | 
							
								#pragma pack(1)     /* 1 byte align */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define ipc uart message header structure for AMP image */
							 | 
						||
| 
								 | 
							
								typedef struct _iot_ipc_uart_msg_hdr {
							 | 
						||
| 
								 | 
							
								    /* start char, see IOT_IPC_MSG_START_CHAR */
							 | 
						||
| 
								 | 
							
								    uint8_t start_char_1;
							 | 
						||
| 
								 | 
							
								    /* command, see IOT_IPC_UART_MSG_CMD_XXX */
							 | 
						||
| 
								 | 
							
								    uint8_t cmd;
							 | 
						||
| 
								 | 
							
								    /* start char, see IOT_IPC_MSG_START_CHAR */
							 | 
						||
| 
								 | 
							
								    uint8_t start_char_2;
							 | 
						||
| 
								 | 
							
								    /* sequence */
							 | 
						||
| 
								 | 
							
								    uint8_t seq;
							 | 
						||
| 
								 | 
							
								    /* data length */
							 | 
						||
| 
								 | 
							
								    uint16_t len;
							 | 
						||
| 
								 | 
							
								    /* data */
							 | 
						||
| 
								 | 
							
								    uint8_t data[0];
							 | 
						||
| 
								 | 
							
								} iot_ipc_uart_msg_hdr;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define ipc uart fwd command header structure for AMP image */
							 | 
						||
| 
								 | 
							
								typedef struct _iot_ipc_uart_cmd_fwd_hdr {
							 | 
						||
| 
								 | 
							
								    /* IPC source family ID */
							 | 
						||
| 
								 | 
							
								    uint16_t s_f_id  :4,
							 | 
						||
| 
								 | 
							
								    /* IPC source client ID */
							 | 
						||
| 
								 | 
							
								             s_c_id  :4,
							 | 
						||
| 
								 | 
							
								    /* IPC destination family ID */
							 | 
						||
| 
								 | 
							
								             d_f_id  :4,
							 | 
						||
| 
								 | 
							
								    /* IPC destination client ID */
							 | 
						||
| 
								 | 
							
								             d_c_id  :4;
							 | 
						||
| 
								 | 
							
								    /* header reserve length for restoring pkt */
							 | 
						||
| 
								 | 
							
								    uint16_t hdr_rsvd_len;
							 | 
						||
| 
								 | 
							
								    /* tail reserve length for restoring pkt */
							 | 
						||
| 
								 | 
							
								    uint16_t tail_rsvd_len;
							 | 
						||
| 
								 | 
							
								    /* source packet pointer for fwd data */
							 | 
						||
| 
								 | 
							
								    uint32_t pkt_ptr;
							 | 
						||
| 
								 | 
							
								    /* fwd data */
							 | 
						||
| 
								 | 
							
								    uint8_t data[0];
							 | 
						||
| 
								 | 
							
								} iot_ipc_uart_cmd_fwd_hdr;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define ipc uart callback command header structure for AMP image */
							 | 
						||
| 
								 | 
							
								typedef struct _iot_ipc_uart_cmd_callback_t {
							 | 
						||
| 
								 | 
							
								    /* source packet pointer */
							 | 
						||
| 
								 | 
							
								    uint32_t pkt_ptr;
							 | 
						||
| 
								 | 
							
								} iot_ipc_uart_cmd_callback_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define ipc uart message tail structure for AMP image */
							 | 
						||
| 
								 | 
							
								typedef struct _iot_ipc_uart_msg_tail {
							 | 
						||
| 
								 | 
							
								    /* cs check from start_char_1 to data */
							 | 
						||
| 
								 | 
							
								    uint8_t cs;
							 | 
						||
| 
								 | 
							
								    /* end char, see IOT_IPC_MSG_END_CHAR */
							 | 
						||
| 
								 | 
							
								    uint8_t end_char;
							 | 
						||
| 
								 | 
							
								} iot_ipc_uart_msg_tail;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#pragma pack(pop)   /* restore the pack status */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * iot_ipc_init() - init ipc module
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * return:
							 | 
						||
| 
								 | 
							
								 *  0           --  for success case
							 | 
						||
| 
								 | 
							
								 *  othersie    --  error code
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t iot_ipc_init();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * iot_ipc_deinit() - deinit ipc module
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_ipc_deinit();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* IOT_IPC_H */
							 |