• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  ****************************************************************************************
3  *
4  * @file lcp_sdk.h
5  *
6  * @brief LCP SDK API
7  *
8  ****************************************************************************************
9  * @attention
10   #####Copyright (c) 2019 GOODIX
11   All rights reserved.
12 
13     Redistribution and use in source and binary forms, with or without
14     modification, are permitted provided that the following conditions are met:
15   * Redistributions of source code must retain the above copyright
16     notice, this list of conditions and the following disclaimer.
17   * Redistributions in binary form must reproduce the above copyright
18     notice, this list of conditions and the following disclaimer in the
19     documentation and/or other materials provided with the distribution.
20   * Neither the name of GOODIX nor the names of its contributors may be used
21     to endorse or promote products derived from this software without
22     specific prior written permission.
23 
24   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34   POSSIBILITY OF SUCH DAMAGE.
35  *****************************************************************************************
36  */
37 
38 /**
39 * @addtogroup BLE
40 * @{
41 * @brief Definitions and prototypes for the BLE SDK interface.
42 */
43 
44 /**
45 * @addtogroup BLE_LCP Light Communication Protocol (LCP)
46 * @{
47 * @brief Definitions and prototypes for the LCP interface.
48 */
49 
50 #ifndef _LCP_SDK_H_
51 #define _LCP_SDK_H_
52 
53 
54 /** @addtogroup BLE_LCP_TYPEDEFS Typedefs
55  * @{ */
56 /** @brief RX handler callback function. */
57 typedef uint16_t (*rx_handler_cb_t) (uint8_t header, uint8_t length, uint8_t *p_payload);
58 /** @} */
59 
60 /** @addtogroup BLE_LCP_ENUMERATIONS Enumerations
61  * @{ */
62 /** @brief Protocol Mode. */
63 enum PROTOCOL_MODE {
64     BLE_ADV,       /**< BLE ADV mode. */
65     BLE_SCAN,      /**< BLE SCAN mode. */
66     LCP_TX,        /**< LCP TX mode. */
67     LCP_RX,        /**< LCP RX mode. */
68 };
69 /** @} */
70 
71 /** @addtogroup BLE_LCP_STRUCTURES Structures
72  * @{ */
73 /** @brief LCP Parameter. */
74 typedef struct {
75     uint8_t   mode;                 /**< Set protocol mode, see @ref PROTOCOL_MODE. */
76     int8_t    txpwr_dbm;            /**< The value of the tx power(range: -20-7), uint: dBm. */
77     uint8_t   ch_idx;               /**< The value of the channel index(range: 0-39). */
78     uint32_t  freq;                 /**< The value of the frequency(range: 2360-2520), uint: MHz. */
79     uint32_t  access_address;       /**< The value of the access address. */
80     uint32_t  crc_init;             /**< The initial value of the crc. */
81     rx_handler_cb_t rx_handler_cb;  /**< The callback function of rx. */
82 } gdx_lcp_config_t;
83 /** @} */
84 
85 /** @addtogroup BLE_LCP_FUNCTIONS Functions
86  * @{ */
87 /**
88  ****************************************************************************************
89  * @brief Initialize LCP.
90  *
91  * @param[in] gdx_lcp_config: Configure the parameter of LCP, @ref gdx_lcp_config_t.
92  *
93  * @retval ::SDK_SUCCESS: The LCP parameter is successfully configured.
94  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
95  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
96  ****************************************************************************************
97  */
98 uint16_t gdx_lcp_init(gdx_lcp_config_t *gdx_lcp_config);
99 
100 /**
101  ****************************************************************************************
102  * @brief Deinitialize LCP.
103  *
104  * @retval ::SDK_SUCCESS: The LCP is successfully Deinitialized.
105  ****************************************************************************************
106  */
107 uint16_t gdx_lcp_deinit(void);
108 
109 /**
110  ****************************************************************************************
111  * @brief Set the tx power of LCP.
112  *
113  * @param[in] txpwr_dbm: The value of the tx power, Range: -20dbm to 7dbm.
114  *
115  * @retval ::SDK_SUCCESS: Operation is Success.
116  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
117  ****************************************************************************************
118  */
119 uint16_t gdx_lcp_tx_power_set(int8_t txpwr_dbm);
120 
121 /**
122  ****************************************************************************************
123  * @brief Get the tx power of LCP.
124  *
125  * @param[in] txpwr_dbm: The value of the tx power, Range: -20dbm to 7dbm.
126  *
127  * @retval ::SDK_SUCCESS: Operation is Success.
128  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
129  ****************************************************************************************
130  */
131 uint16_t gdx_lcp_tx_power_get(int8_t *txpwr_dbm);
132 
133 /**
134  ****************************************************************************************
135  * @brief Set the channel of LCP.
136  *
137  * @param[in] freq: The value of the frequency, Range: 2360MHz to 2520MHz.
138  * @param[in] ch_idx: The value of the channel index, Range: 0 to 39.
139  *
140  * @retval ::SDK_SUCCESS: Operation is Success.
141  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
142  ****************************************************************************************
143  */
144 uint16_t gdx_lcp_channel_set(uint32_t freq, uint8_t ch_idx);
145 
146 /**
147  ****************************************************************************************
148  * @brief Get the channel of LCP.
149  *
150  * @param[in] freq: The value of the frequency, Range: 2360MHz to 2520MHz.
151  * @param[in] ch_idx: The value of the channel index, Range: 0 to 39.
152  *
153  * @retval ::SDK_SUCCESS: Operation is Success.
154  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
155  ****************************************************************************************
156  */
157 uint16_t gdx_lcp_channel_get(uint32_t *freq, uint8_t *ch_idx);
158 
159 /**
160  ****************************************************************************************
161  * @brief Transmmit a packet.
162  *
163  * @param[in] header: The header of the packet.
164  * @param[in] length: The length of the packet payload.
165  * @param[in] p_payload: The pointer of the packet payload.
166  *
167  * @retval ::SDK_SUCCESS: Operation is Success.
168  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
169  ****************************************************************************************
170  */
171 uint16_t gdx_lcp_data_tx(uint8_t header, uint8_t length, uint8_t *p_payload);
172 
173 /**
174  ****************************************************************************************
175  * @brief Start receiving packets
176  *
177  * @retval ::SDK_SUCCESS: Operation is Success.
178  ****************************************************************************************
179  */
180 uint16_t gdx_lcp_rx_start(void);
181 
182 /**
183  ****************************************************************************************
184  * @brief Stop receiving packets
185  *
186  * @retval ::SDK_SUCCESS: Operation is Success.
187  ****************************************************************************************
188  */
189 uint16_t gdx_lcp_rx_stop(void);
190 
191 /** @} */
192 
193 #endif
194 
195 /** @} */
196 /** @} */
197