142 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			4.1 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_API_H
 | |
| #define IOT_IPC_API_H
 | |
| 
 | |
| #include "os_types_api.h"
 | |
| #include "iot_pkt_api.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| /** \defgroup IPC_APIs IPC APIs
 | |
|   * @brief WQ30x1 INTER PROCESS COMMUNICATION API
 | |
|   *
 | |
|   * Inter process cummunication helper functions
 | |
|   *
 | |
|   */
 | |
| 
 | |
| /** @addtogroup IPC_APIs
 | |
|   * @{
 | |
|   */
 | |
| 
 | |
| /* PLC family definitions */
 | |
| #define IOT_IPC_FID_PLC                 0
 | |
| #define IOT_IPC_CID_PLC_LIB             0
 | |
| #define IOT_IPC_CID_PLC_MAC             1
 | |
| 
 | |
| /* SWC family definitions */
 | |
| #define IOT_IPC_FID_SWC                 1
 | |
| #define IOT_IPC_CID_SWC_APP             0
 | |
| #define IOT_IPC_CID_SWC_MAC             1
 | |
| 
 | |
| /* SG extend SDK family definitions */
 | |
| #define IOT_IPC_FID_SG_EXT_SDK          2
 | |
| #define IOT_IPC_CID_SG_EXT_CUS_APP      0
 | |
| #define IOT_IPC_CID_SG_EXT_SG_APP       1
 | |
| 
 | |
| /* ADA Dump family definitions */
 | |
| #define IOT_IPC_FID_ADA                 3
 | |
| #define IOT_IPC_CID_ADA_CLI             0
 | |
| #define IOT_IPC_CID_ADA_MAC             1
 | |
| 
 | |
| /* DEVICE family definitions */
 | |
| #define IOT_IPC_FID_DEV                 4
 | |
| #define IOT_IPC_CID_DEV_LED_CUS         0
 | |
| #define IOT_IPC_CID_DEV_LED_PLC         1
 | |
| #define IOT_IPC_CID_DEV_PM_CUS          2
 | |
| #define IOT_IPC_CID_DEV_PM_PLC          3
 | |
| /* common definitions */
 | |
| #define IOT_IPC_CID_BCAST               0xf
 | |
| 
 | |
| typedef struct _iot_ipc_addr {
 | |
|     /** IPC family ID */
 | |
|     uint8_t     f_id        :4,
 | |
|     /** IPC client ID */
 | |
|                 c_id        :4;
 | |
| } iot_ipc_addr_t;
 | |
| 
 | |
| /*
 | |
|  * callback to receive pkt from ipc. pkt ownership will transferred to the
 | |
|  * callee. the callee should call iot_pkt_free to free the pkt ASAP.
 | |
|  * @param:      parameter registered in iot_ipc_register_client
 | |
|  * @addr:       source of the packet
 | |
|  * @pkt:        pointer to the packet
 | |
|  */
 | |
| typedef void (*iot_ipc_recv_func_t)(void *param, iot_ipc_addr_t *addr,
 | |
|     iot_pkt_t *pkt);
 | |
| 
 | |
| typedef struct _iot_ipc_client {
 | |
|     /** address of the client */
 | |
|     iot_ipc_addr_t      addr;
 | |
|     /** callback to receive packet from ipc */
 | |
|     iot_ipc_recv_func_t recv;
 | |
|     /** parameter that will be transferred back alone with the callback */
 | |
|     void                *param;
 | |
| } iot_ipc_client_t;
 | |
| 
 | |
| /* ipc client hanlder */
 | |
| typedef void *iot_ipc_h;
 | |
| 
 | |
| /*
 | |
|  * iot_ipc_register_client() - register ipc client
 | |
|  * @client:     pointer to client descripter
 | |
|  *
 | |
|  * return:
 | |
|  *  NULL        -- for failure case
 | |
|  *  othersie    -- ipc client handler
 | |
|  */
 | |
| iot_ipc_h iot_ipc_register_client(iot_ipc_client_t *client);
 | |
| 
 | |
| /*
 | |
|  * iot_ipc_deregister_client() - deregister ipc client
 | |
|  * @handle:      ipc client handler
 | |
|  *
 | |
|  * return:
 | |
|  *  0           --  for success case
 | |
|  *  othersie    --  error code
 | |
|  */
 | |
| uint32_t iot_ipc_deregister_client(iot_ipc_h handle);
 | |
| 
 | |
| /*
 | |
|  * iot_ipc_send() - send a packet through ipc
 | |
|  * @handle:     ipc client handler
 | |
|  * @addr:       target address
 | |
|  * @pkt:        pointer to the packet.
 | |
|  *              iot_ipc_send will forward or free the pkt.
 | |
|  */
 | |
| void iot_ipc_send(iot_ipc_h handle, iot_ipc_addr_t *addr, iot_pkt_t *pkt);
 | |
| 
 | |
| /**
 | |
|  * @brief: allocate a packet for ipc sending data.
 | |
|  * @param size:         size of the packet user want to be allocate.
 | |
|  * @param module_id:    id of the module to allocate the packet
 | |
|  * @retval: NULL -- No memory available.
 | |
|  * @retval: otherwise -- address of the new allocated packet.
 | |
|  */
 | |
| iot_pkt_t *iot_ipc_pkt_alloc(uint32_t size, module_id_t module_id);
 | |
| 
 | |
| /**
 | |
|   * @}
 | |
|   */
 | |
| 
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif /* IOT_IPC_API_H */ |