1 //*****************************************************************************
2 //
3 //! @file am_util_ble.h
4 //!
5 //! @brief Useful BLE functions not covered by the HAL.
6 //!
7 //! This file contains functions for interacting with the BLE hardware
8 //! that are not already covered by the HAL. Most of these commands either
9 //! adjust RF settings or facilitate RF testing operations.
10 //!
11 //! @addtogroup ble BLE
12 //! @ingroup utils
13 //! @{
14 //
15 //*****************************************************************************
16 
17 //*****************************************************************************
18 //
19 // Copyright (c) 2023, Ambiq Micro, Inc.
20 // All rights reserved.
21 //
22 // Redistribution and use in source and binary forms, with or without
23 // modification, are permitted provided that the following conditions are met:
24 //
25 // 1. Redistributions of source code must retain the above copyright notice,
26 // this list of conditions and the following disclaimer.
27 //
28 // 2. Redistributions in binary form must reproduce the above copyright
29 // notice, this list of conditions and the following disclaimer in the
30 // documentation and/or other materials provided with the distribution.
31 //
32 // 3. Neither the name of the copyright holder nor the names of its
33 // contributors may be used to endorse or promote products derived from this
34 // software without specific prior written permission.
35 //
36 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
37 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
40 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
41 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 // POSSIBILITY OF SUCH DAMAGE.
47 //
48 // This is part of revision release_sdk_4_4_0-3c5977e664 of the AmbiqSuite Development Package.
49 //
50 //*****************************************************************************
51 
52 #ifndef AM_UTIL_BLE_H
53 #define AM_UTIL_BLE_H
54 
55 //*****************************************************************************
56 //
57 // External function declarations.
58 //
59 //*****************************************************************************
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
64 
65 //*****************************************************************************
66 //
67 //! @brief In DTM mode, set TX to constant trans mode for SRRC/FCC/CE
68 //! set enable as 'true' to constant trans mode, 'false' back to normal
69 //!
70 //! @param pHandle - pointer to BLE Handle
71 //! @param enable - enable or disable
72 //!
73 //! @return Status Code
74 //
75 //*****************************************************************************
76 extern uint32_t am_util_ble_set_constant_transmission(void *pHandle, bool enable);
77 
78 //*****************************************************************************
79 //
80 //! @brief Manually enable/disable transmitter
81 //! set ui8TxCtrl as 1 to manually enable transmitter, 0 back to default
82 //!
83 //! @param pHandle - pointer to BLE Handle
84 //! @param ui8TxCtrl - enable or disable
85 //!
86 //! @return Status Code
87 //
88 //*****************************************************************************
89 extern uint32_t am_util_ble_transmitter_control(void *pHandle, uint8_t ui8TxCtrl);
90 
91 //*****************************************************************************
92 //
93 //! @brief to fix the channel 1 bug in DTM mode
94 //!
95 //! @param pHandle - pointer to BLE Handle
96 //!
97 //! @return Status Code
98 //
99 //*****************************************************************************
100 extern uint32_t am_util_ble_init_rf_channel(void *pHandle);
101 
102 //*****************************************************************************
103 //
104 //! @brief BLE init for BQB test
105 //! set enable as 'true' to init as BQB test mode, 'false' back to default
106 //!
107 //! @param pHandle - pointer to BLE Handle
108 //! @param enable - enable or disable
109 //!
110 //! @return Status Code
111 //
112 //*****************************************************************************
113 extern uint32_t am_util_ble_BQB_test_init(void *pHandle, bool enable);
114 
115 //*****************************************************************************
116 //
117 //! @brief Set the 32M crystal frequency based on the tested values at customer
118 //! side. Set trim value smaller in case of negative frequency offset
119 //! ui32TrimValue: default is 0x400
120 //!
121 //! @param pHandle - pointer to BLE Handle
122 //! @param ui32TrimValue - Trim Value for Crystal
123 //!
124 //! @return Status Code
125 //
126 //*****************************************************************************
127 extern uint32_t am_util_ble_crystal_trim_set(void *pHandle, uint32_t ui32TrimValue);
128 
129 //*****************************************************************************
130 //
131 //! @brief Manually enable/disable transmitter to output carrier signal
132 //! set ui8TxChannel as 0 to 0x27 for each transmit channel, 0xFF back to normal
133 //! modulate mode
134 //!
135 //! @param pHandle - pointer to BLE Handle
136 //!
137 //! @return Status Code
138 //
139 //*****************************************************************************
140 extern uint32_t am_util_ble_hci_reset(void *pHandle);
141 
142 //*****************************************************************************
143 //
144 //! @brief to do directly output modulation signal. change channel ranges from 0 to 0x27,
145 //! pattern from 0 to 7.
146 //!
147 //! @param pHandle - pointer to BLE Handle
148 //! @param channel - channel for transmitter
149 //! @param pattern - pattern for output modulation
150 //!
151 //! @return Status Code
152 //
153 //*****************************************************************************
154 extern uint32_t am_util_ble_trasmitter_test_ex(void *pHandle,
155                                                uint8_t channel,
156                                                uint8_t pattern);
157 
158 //*****************************************************************************
159 //
160 //! @brief to do directly receiver test. change channel ranges from 0 to 0x27, return
161 //! received packets in 100ms.
162 //!
163 //! @param pHandle - pointer to BLE Handle
164 //! @param channel - channel for transmitter
165 //! @param recvpackets - pointer to rx packet
166 //!
167 //! @return Status Code
168 //
169 //*****************************************************************************
170 extern uint32_t am_util_ble_receiver_test_ex(void *pHandle,
171                                              uint8_t channel,
172                                              uint32_t *recvpackets);
173 
174 //*****************************************************************************
175 //
176 //! @brief to directly output carrier wave. change channel ranges from 0 to 0x27.
177 //!
178 //! @param pHandle - pointer to BLE Handle
179 //! @param channel - channel for transmitter
180 //!
181 //! @return Status Code
182 //
183 //*****************************************************************************
184 extern uint32_t am_util_ble_set_carrier_wave_ex(void *pHandle, uint8_t channel);
185 
186 //*****************************************************************************
187 //
188 //! @brief Manually enable/disable transmitter to output carrier wave signal
189 //! set ui8TxChannel as 0 to 0x27 for each transmit channel, 0xFF back to normal
190 //! modulate mode
191 //!
192 //! @param pHandle - pointer to BLE Handle
193 //! @param ui8TxChannel - channel for transmitter
194 //!
195 //! @return Status Code
196 //
197 //*****************************************************************************
198 extern uint32_t am_util_ble_transmitter_control_ex(void *pHandle,
199                                                    uint8_t ui8TxChannel);
200 
201 //*****************************************************************************
202 //
203 //! @brief to directly output constant modulation signal. change channel from 0 to 0x27.
204 //!
205 //! @param pHandle - pointer to BLE Handle
206 //! @param channel - channel for transmitter
207 //!
208 //! @return Status Code
209 //
210 //*****************************************************************************
211 extern uint32_t am_util_ble_set_constant_transmission_ex(void *pHandle,
212                                                          uint8_t channel);
213 
214 //*****************************************************************************
215 //
216 //! @brief read current modex value from BLEIP
217 //!
218 //! @param pHandle - pointer to BLE Handle
219 //!
220 //! @return Status Code
221 //
222 //*****************************************************************************
223 extern uint32_t am_util_ble_read_modex_value(void *pHandle);
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif // AM_UTIL_BLE_H
230 
231 //*****************************************************************************
232 //
233 // End Doxygen group.
234 //! @}
235 //
236 //*****************************************************************************
237 
238