Files
kunlun/driver/extern/bluetooth/inc/iot_bt_ext.h
2024-09-28 14:24:04 +08:00

139 lines
4.1 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_BT_EXT_H_
#define _IOT_BT_EXT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "os_types_api.h"
#include "os_utils_api.h"
#include "os_timer_api.h"
#include "iot_uart_api.h"
#include "iot_bt_ext_protocol.h"
#include "iot_bt_ext_api.h"
/* peripheral config information */
#define IOT_EXT_BT_PERI_BUF_LEN 1024 //TODO: may need to be fix
/* @brief bluetooth alarm task callback function.
* implement by post messages.
*
* @param elapsed_time: elapsed time, unit: ms.
* @return: none
*/
typedef void (*iot_bt_ext_alarm_func_t)(uint32_t elapsed_time);
/* @brief bluetooth sub system open function.
*
* @return: error code, see ERR_XXX
*/
typedef uint32_t (*iot_bt_ext_sub_open_func_t)(void);
/* @brief bluetooth sub system close function.
*
* @return: none
*/
typedef void (*iot_bt_ext_sub_close_func_t)(void);
/* bluetootch user information ctxt */
typedef struct _iot_bt_ext_user_info {
/* user port id, see IOT_BT_EXT_PORT_USER_ID */
uint32_t port_id;
/* user port rx data report function callback */
iot_bt_ext_rpt_func_t rx_rpt_func;
} iot_bt_ext_user_info_t;
/* peripheral uart config information */
typedef struct _iot_bt_ext_uart_cfg {
/* uart parity mode */
uint32_t parity : 8,
/* uart data len */
data : 8,
/* uart stop len */
stop : 8,
/* reserved */
rsvd : 8;
/* baudrate */
uint32_t baud;
} iot_bt_ext_uart_cfg_t;
typedef struct _iot_bt_ext_peri_ctxt {
iot_bt_ext_uart_cfg_t uart_cfg;
/* uart handle */
iot_uart_h peri_hdl;
} iot_bt_ext_peri_ctxt_t;
/* sub system config */
typedef struct _iot_bt_ext_sub_cfg {
/* sub system port id */
uint32_t port_id;
/* sub system open function entry */
iot_bt_ext_sub_open_func_t open_func;
/* sub system close function entry */
iot_bt_ext_sub_close_func_t close_func;
/* sub system rx report function entry */
iot_bt_ext_rpt_func_t rx_rpt_func;
/* sub systen alarm function callback */
iot_bt_ext_alarm_func_t alarm_func;
} iot_bt_ext_sub_cfg_t;
typedef struct _iot_bt_ext_sub_ctxt {
/* sub system number */
uint32_t sub_num : 8,
/* reserved */
rsvd : 24;
/* sub system config entry */
iot_bt_ext_sub_cfg_t *cfg;
} iot_bt_ext_sub_info_t;
typedef struct _iot_bt_ext_ctxt {
/* alarm timer period, unit:ms */
uint32_t alarm_period : 16,
/* reserved */
rsvd : 16;
/* alarm timer id */
timer_id_t alarm_timer;
/* task handle */
iot_task_h task_hdl;
/* peripheral infomation */
iot_bt_ext_peri_ctxt_t peri_info;
/* */
iot_bt_ext_sub_info_t sub_info;
/* plc bt protocol tx rx information */
iot_bt_ext_user_info_t user_info[IOT_BT_EXT_PORT_USER_NUM];
} iot_bt_ext_ctxt_t;
/* @brief open plc bt module
*
* @param none
* @return: errno, see ERR_XXX
*/
uint32_t iot_bt_ext_open(void);
/* @brief close plc bt module
*
* @param none
* @return: errno, see ERR_XXX
*/
uint32_t iot_bt_ext_close(void);
#ifdef __cplusplus
}
#endif
#endif