Files
kunlun/inc/plc_lib/iot_plc_lib.h
2024-09-28 14:24:04 +08:00

136 lines
4.4 KiB
C
Executable File

/****************************************************************************
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_PLC_LIB_H
#define IOT_PLC_LIB_H
#include "os_types.h"
#include "iot_config.h"
#include "iot_plc_api.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
/* common PLC message id definitions shared between CCO and STA device */
#define IOT_PLC_MSG_HW_TSFM_PA_SEND 0XE0
#define IOT_PLC_MSG_PM_SAVE_CFG_SET 0xE1
/** IOT_PLC_MSG_HW_TSFM_PA_SEND format */
typedef struct _iot_plc_hw_tsfm_pa_send {
/* send count */
uint8_t send_cnt;
/* length of the data */
uint8_t len;
/* tx encode frequency tone num, each tone is 75MHz/(1 << 14) */
uint32_t freq_tone_num;
/* data */
uint8_t data[4];
} iot_plc_hw_tsfm_pa_send_t;
/** IOT_PLC_MSG_PM_SAVE_CFG_SET format */
typedef struct _iot_plc_set_pm_save_cfg {
/* power save function cfg */
uint32_t allow_sleep : 1,
/* reserved for future */
rsv : 31;
} iot_plc_set_pm_save_cfg_t;
#pragma pack(pop) /* restore the pack status */
#if PLC_SUPPORT_CCO_ROLE
/* define short buffer size and count for plc lib message */
#define PLC_LIB_MSG_SHORT_BUF_SIZE 128
#if RUN_IN_PSRAM
#define PLC_LIB_MSG_SHORT_BUF_CNT 128
#else /* RUN_IN_PSRAM */
#define PLC_LIB_MSG_SHORT_BUF_CNT 32
#endif /* RUN_IN_PSRAM */
/* define long buffer size and count for plc lib message */
#define PLC_LIB_MSG_LONG_BUF_SIZE 1024
#define PLC_LIB_MSG_LONG_BUF_CNT 16
#else /* PLC_SUPPORT_CCO_ROLE */
/* define short buffer size and count for plc lib message */
#define PLC_LIB_MSG_SHORT_BUF_SIZE 32
#define PLC_LIB_MSG_SHORT_BUF_CNT 32
/* define long buffer size and count for plc lib message */
#define PLC_LIB_MSG_LONG_BUF_SIZE 1024
#define PLC_LIB_MSG_LONG_BUF_CNT 1
#endif
/**
* @brief iot_plc_lid_alloc_req() - request to allocate bandwidth for the
* specified lid. the result will be notified through
* iot_plc_recv_func_t callback.
* @param handle: plc application handler
* @param lid: the specified lid
*/
void iot_plc_lid_alloc_req(iot_plc_app_h handle, uint8_t lid);
/**
* @brief iot_plc_lid_rel_req() - request to release bandwidth for the
* specified lid.
* @param handle: plc application handler
* @param lid: the specified lid
*/
void iot_plc_lid_rel_req(iot_plc_app_h handle, uint8_t lid);
/**
* @brief iot_plc_hw_tsfm_pa_send() - send hw tsfm pa data
* @param data: data
* @param len: length of the data
* @param send_cnt: send count
* @param freq_tone_num: encode frequncy tone num. each tone num is
* 75MHz/(1 << 14)
* @return error code. see iot_errno_api.h
*/
uint32_t iot_plc_hw_tsfm_pa_send(uint8_t *data, uint8_t len, uint8_t send_cnt,
uint32_t freq_tone_num);
/**
* @brief iot_plc_lib_init() - init plc lib module
* @param proto: device running mode, see PLC_PROTO_TYPE_XXX.
*
* @retval: 0 -- for success case
* @retval: otherwise -- error code
*/
uint32_t iot_plc_lib_init(uint8_t proto);
/*
* iot_ipc_lib_deinit() - deinit plc lib module
*/
void iot_plc_lib_deinit();
/**
* @brief iot_plc_set_pm_save_cfg() - set pm save cfg
* @param allow_sleep: allow sleep or not
*/
void iot_plc_set_pm_save_cfg(uint8_t allow_sleep);
#ifdef __cplusplus
}
#endif
#endif /* IOT_PLC_LIB_H */