gr55xx_lcp.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_lcp.h
5 *
6 * @brief GR55XX LCP 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 _GR55XX_LCP_H_
51 #define _GR55XX_LCP_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 {
65 BLE_ADV, /**< BLE ADV mode. */
66 BLE_SCAN, /**< BLE SCAN mode. */
67 LCP_TX, /**< LCP TX mode. */
68 LCP_RX, /**< LCP RX mode. */
69 };
70 /** @} */
71
72 /**@addtogroup BLE_LCP_STRUCTURES Structures
73 * @{ */
74 /**@brief LCP Parameter. */
75 typedef struct
76 {
77 uint8_t mode; /**< Set protocol mode, see @ref PROTOCOL_MODE. */
78 int8_t txpwr_dbm; /**< The value of the tx power(range: -20-7), uint: dBm. */
79 uint8_t ch_idx; /**< The value of the channel index(range: 0-39). */
80 uint32_t freq; /**< The value of the frequency(range: 2360-2520), uint: MHz. */
81 uint32_t access_address; /**< The value of the access address. */
82 uint32_t crc_init; /**< The initial value of the crc. */
83 rx_handler_cb_t rx_handler_cb; /**< The callback function of rx. */
84 } gdx_lcp_config_t;
85 /** @} */
86
87 /** @addtogroup BLE_LCP_FUNCTIONS Functions
88 * @{ */
89 /**
90 ****************************************************************************************
91 * @brief Initialize LCP.
92 *
93 * @param[in] gdx_lcp_config: Configure the parameter of LCP, @ref gdx_lcp_config_t.
94 *
95 * @retval ::SDK_SUCCESS: The LCP parameter is successfully configured.
96 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
97 * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
98 ****************************************************************************************
99 */
100 uint16_t gdx_lcp_init(gdx_lcp_config_t *gdx_lcp_config);
101
102 /**
103 ****************************************************************************************
104 * @brief Deinitialize LCP.
105 *
106 * @retval ::SDK_SUCCESS: The LCP is successfully Deinitialized.
107 ****************************************************************************************
108 */
109 uint16_t gdx_lcp_deinit(void);
110
111 /**
112 ****************************************************************************************
113 * @brief Set the tx power of LCP.
114 *
115 * @param[in] txpwr_dbm: The value of the tx power, Range: -20dbm to 7dbm.
116 *
117 * @retval ::SDK_SUCCESS: Operation is Success.
118 * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
119 ****************************************************************************************
120 */
121 uint16_t gdx_lcp_tx_power_set(int8_t txpwr_dbm);
122
123 /**
124 ****************************************************************************************
125 * @brief Get the tx power of LCP.
126 *
127 * @param[in] txpwr_dbm: The value of the tx power, Range: -20dbm to 7dbm.
128 *
129 * @retval ::SDK_SUCCESS: Operation is Success.
130 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
131 ****************************************************************************************
132 */
133 uint16_t gdx_lcp_tx_power_get(int8_t *txpwr_dbm);
134
135 /**
136 ****************************************************************************************
137 * @brief Set the channel of LCP.
138 *
139 * @param[in] freq: The value of the frequency, Range: 2360MHz to 2520MHz.
140 * @param[in] ch_idx: The value of the channel index, Range: 0 to 39.
141 *
142 * @retval ::SDK_SUCCESS: Operation is Success.
143 * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
144 ****************************************************************************************
145 */
146 uint16_t gdx_lcp_channel_set(uint32_t freq, uint8_t ch_idx);
147
148 /**
149 ****************************************************************************************
150 * @brief Get the channel of LCP.
151 *
152 * @param[in] freq: The value of the frequency, Range: 2360MHz to 2520MHz.
153 * @param[in] ch_idx: The value of the channel index, Range: 0 to 39.
154 *
155 * @retval ::SDK_SUCCESS: Operation is Success.
156 * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
157 ****************************************************************************************
158 */
159 uint16_t gdx_lcp_channel_get(uint32_t *freq, uint8_t *ch_idx);
160
161 /**
162 ****************************************************************************************
163 * @brief Transmmit a packet.
164 *
165 * @param[in] header: The header of the packet.
166 * @param[in] length: The length of the packet payload.
167 * @param[in] p_payload: The pointer of the packet payload.
168 *
169 * @retval ::SDK_SUCCESS: Operation is Success.
170 * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
171 ****************************************************************************************
172 */
173 uint16_t gdx_lcp_data_tx(uint8_t header, uint8_t length, uint8_t *p_payload);
174
175 /**
176 ****************************************************************************************
177 * @brief Start receiving packets
178 *
179 * @retval ::SDK_SUCCESS: Operation is Success.
180 ****************************************************************************************
181 */
182 uint16_t gdx_lcp_rx_start(void);
183
184 /**
185 ****************************************************************************************
186 * @brief Stop receiving packets
187 *
188 * @retval ::SDK_SUCCESS: Operation is Success.
189 ****************************************************************************************
190 */
191 uint16_t gdx_lcp_rx_stop(void);
192
193 /** @} */
194
195 #endif
196
197 /** @} */
198 /** @} */
LCP_TX
@ LCP_TX
LCP TX mode.
Definition: gr55xx_lcp.h:67
gdx_lcp_init
uint16_t gdx_lcp_init(gdx_lcp_config_t *gdx_lcp_config)
Initialize LCP.
PROTOCOL_MODE
PROTOCOL_MODE
Protocol Mode.
Definition: lcp_sdk.h:64
gdx_lcp_config_t
LCP Parameter.
Definition: lcp_sdk.h:76
gdx_lcp_tx_power_set
uint16_t gdx_lcp_tx_power_set(int8_t txpwr_dbm)
Set the tx power of LCP.
gdx_lcp_rx_stop
uint16_t gdx_lcp_rx_stop(void)
Stop receiving packets.
gdx_lcp_data_tx
uint16_t gdx_lcp_data_tx(uint8_t header, uint8_t length, uint8_t *p_payload)
Transmmit a packet.
rx_handler_cb_t
uint16_t(* rx_handler_cb_t)(uint8_t header, uint8_t length, uint8_t *p_payload)
RX handler callback function.
Definition: gr55xx_lcp.h:57
gdx_lcp_tx_power_get
uint16_t gdx_lcp_tx_power_get(int8_t *txpwr_dbm)
Get the tx power of LCP.
gdx_lcp_rx_start
uint16_t gdx_lcp_rx_start(void)
Start receiving packets.
gdx_lcp_channel_set
uint16_t gdx_lcp_channel_set(uint32_t freq, uint8_t ch_idx)
Set the channel of LCP.
LCP_RX
@ LCP_RX
LCP RX mode.
Definition: gr55xx_lcp.h:68
BLE_ADV
@ BLE_ADV
BLE ADV mode.
Definition: gr55xx_lcp.h:65
gdx_lcp_deinit
uint16_t gdx_lcp_deinit(void)
Deinitialize LCP.
BLE_SCAN
@ BLE_SCAN
BLE SCAN mode.
Definition: gr55xx_lcp.h:66
gdx_lcp_channel_get
uint16_t gdx_lcp_channel_get(uint32_t *freq, uint8_t *ch_idx)
Get the channel of LCP.