1 /*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/1.32a-lca02/firmware/public_inc/ll_intf_cmn.h#1 $*/
2 /**
3  ********************************************************************************
4  * @file    ll_intf_cmn.h
5  * @brief   This file includes declaration of common interfaces of MAC only and BLE/COEXISTENCE APIs.
6  ******************************************************************************
7   * @copy
8  * This Synopsys DWC Bluetooth Low Energy Combo Link Layer/MAC software and
9  * associated documentation ( hereinafter the "Software") is an unsupported
10  * proprietary work of Synopsys, Inc. unless otherwise expressly agreed to in
11  * writing between Synopsys and you. The Software IS NOT an item of Licensed
12  * Software or a Licensed Product under any End User Software License Agreement
13  * or Agreement for Licensed Products with Synopsys or any supplement thereto.
14  * Synopsys is a registered trademark of Synopsys, Inc. Other names included in
15  * the SOFTWARE may be the trademarks of their respective owners.
16  *
17  * Synopsys MIT License:
18  * Copyright (c) 2020-Present Synopsys, Inc
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining a copy of
21  * the Software), to deal in the Software without restriction, including without
22  * limitation the rights to use, copy, modify, merge, publish, distribute,
23  * sublicense, and/or sell copies of the Software, and to permit persons to whom
24  * the Software is furnished to do so, subject to the following conditions:
25  *
26  * The above copyright notice and this permission notice shall be included in all
27  * copies or substantial portions of the Software.
28  *
29  * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30  * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31  * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE ARISING FROM,
34  * OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  * */
37 
38 #ifndef INCLUDE_LL_INTF_CMN_H_
39 #define INCLUDE_LL_INTF_CMN_H_
40 
41 #include "common_types.h"
42 
43 
44 /*========================================================================================================*/
45 /*================================  Configure LL Context Control Command =================================*/
46 /*========================================================================================================*/
47 
48 /**
49  * @brief Used to configure the LL contexts, where:
50  * 			1. For bare-metal:
51  * 			- High ISR is executed in the ISR context
52  * 			- Low ISR can be executed in the high ISR context, or switched to low ISR context
53  * 			2. For RTOS:
54  * 			- High ISR is executed in the ISR context
55  * 			- Low ISR is executed in the thread of the "linkLayerHighPrioTask"
56  *
57  * @param allow_low_isr : [in] Configuration parameter for the context of the low ISR in the bare-metal model. Range is [0,1].
58  * 								0: Low ISR code is executed in the same context of the high ISR.
59  * 								1: Low ISR code is executed in the context of the low ISR (by configuring a low priority interrupt that is triggered by FW).
60  * @param run_post_evnt_frm_isr : [in] Configuration parameter to decide whether the scheduling of the next BLE event is done in the low ISR context or to be handled by the LL main thread. Range is [0,1].
61  * 								0: BLE next event scheduling is handled in the LL main thread.
62  * 								1: BLE next event scheduling is handled in the low ISR context.
63  *
64  * @retval ble_state_t : Command status
65  */
66 ble_stat_t ll_intf_cmn_config_ll_ctx_params(uint8_t allow_low_isr, uint8_t run_post_evnt_frm_isr);
67 
68 
69 /*========================================================================================================*/
70 /*==================================  LE Select Sleep Clock Source =======================================*/
71 /*========================================================================================================*/
72 
73 #if (USE_NON_ACCURATE_32K_SLEEP_CLK)
74 /**
75  * @brief Used to select the source that drives the sleep clock, whether to use an external crystal oscillator or an integrated RC oscillator (RCO).
76  *
77  * @param  slp_clk_src 				: [in] Indicate which source to drive the sleep clock. 0: Crystal Oscillator (default). 1: RC0
78  * @param  ptr_slp_clk_freq_value 	: [out] Indicate the nominal frequency value of the sleep clock.
79  *
80  * @retval ble_stat_t : Command status to be sent to the Host.
81  */
82 ble_stat_t ll_intf_cmn_le_select_slp_clk_src(uint8_t slp_clk_src, uint16_t *ptr_slp_clk_freq_value);
83 
84 /*========================================================================================================*/
85 /*===============================  LE Set RCO Calibration Event Parameters ===============================*/
86 /*========================================================================================================*/
87 
88 /**
89  * @brief Used to configure the runtime RCO calibration event parameters.
90  *
91  * @param  rco_clbr_event_duration : [in] Indicate the number of sleep clock cycles for performing the RCO calibration process.
92  * @param  rco_clbr_event_interval : [in] Indicate the periodicity of running the runtime RCO calibration event.
93  *
94  * @retval None.
95  */
96 
97 ble_stat_t ll_intf_cmn_le_set_rco_clbr_evnt_params(uint8_t rco_clbr_event_duration, uint32_t rco_clbr_event_interval);
98 
99 #endif
100 
101 /*========================================================================================================*/
102 /*======================================  LE Select TX_Power Table =======================================*/
103 /*========================================================================================================*/
104 
105 /**
106  * @brief Used to specify the used power table and its size based on the selected TX_Power table ID.
107  *
108  * @param  tx_power_table_id : [in] Selected TX_Power table ID.
109  *
110  * @retval Status 		 : 0: SUCCESS. Otherwise: Error code.
111  */
112 uint8_t ll_intf_cmn_select_tx_power_table(uint8_t tx_power_table_id);
113 
114 
115 /**
116  * @brief flag to the LL the existence of a temperature sensor
117  * @retval None
118  */
119 void ll_intf_cmn_set_temperature_sensor_state(void);
120 
121 /**
122  * @brief set the current temperature
123  * @param temperature		:	The current temperature
124  * @retval None
125  */
126 uint32_t  ll_intf_cmn_set_temperature_value(uint32_t temperature);
127 
128 /*========================================================================================================*/
129 /*====================================  Random Number Generation Group ===================================*/
130 /*========================================================================================================*/
131 
132  /**
133   * @brief  Request new random number.
134   *
135   * @param  ptr_rnd	: Pointer to the output random bytes .
136   * @param  len	 	: Number of required random bytes.
137   *
138   * @retval Status.
139   */
140 
141 uint32_t ll_intf_cmn_gen_rnd_num(uint8_t *ptr_rnd, uint32_t len);
142 
143 /**
144  *
145  * @brief A common wrapper for BLE-ECB and MAC-CCM security modes
146  *
147  * @param	ptr_pckt		 : Pointer to the data buffer (variable length
148  *  in case of CCM mode, 16 bytes in case of ECB mode). The resulting
149  *  Encrypted/Decrypted data overwrites this buffer.
150  * @param	ptr_key[in]		 : Pointer to the security key buffer (16 bytes).
151  * @param	ptr_nonce[in]	 : Pointer to the security nonce buffer (13 bytes
152  *  in case of CCM mode, a Null pointer in case of ECB mode).
153  * @param	mic_len[in]		 : Length of MIC, supported values are 0, 4, 6,
154  *  8, 10, 12, 14, and 16 in case of CCM, 0 only in case of ECB.
155  * @param	ad_len[in]		 : Length of Data to be authenticated.
156  * @param	md_len[in]		 : Length of Data to be encrypted.
157  * @param	key_endian[in]	 : Represents the format of the security key.
158  * @param	data_endian[in]	 : Represents the endian format of the data.
159  * @param	security_mode[in]: Hardware security mode.
160  * @retval Status
161  */
162 uint32_t ll_intf_cmn_crypto(uint8_t *ptr_pckt, const uint8_t *ptr_key,
163 		uint8_t *ptr_nonce, uint32_t mic_len, uint32_t ad_len, uint32_t md_len,
164 		crypto_endian_enum_t key_endian, crypto_endian_enum_t data_endian,
165 		security_mode_enum_t security_mode);
166 
167 ble_stat_t ll_intf_cmn_le_set_dp_slp_mode(uint8_t dp_slp_mode);
168 
169 #endif /* INCLUDE_LL_INTF_CMN_H_ */
170