-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbluenrg_hal_aci.h
176 lines (157 loc) · 7.07 KB
/
bluenrg_hal_aci.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
* File Name : bluenrg_hal_aci.h
* Author : AMS - AAS
* Version : V1.0.0
* Date : 26-Jun-2014
* Description : Header file with HCI commands for BlueNRG FW6.3.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __BLUENRG_HAL_ACI_H__
#define __BLUENRG_HAL_ACI_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
*@addtogroup HAL HAL
*@brief Hardware Abstraction Layer.
*@{
*/
/**
* @defgroup HAL_Functions HAL functions
* @brief API for BlueNRG HAL layer.
* @{
*/
/**
* @brief This command writes a value to a low level configure data structure.
* @note It is useful to setup directly some low level parameters for the system at runtime.
* @param offset Offset in the data structure. The starting member in the data structure will have an offset 0.\n
* See @ref Config_vals.
*
* @param len Length of data to be written
* @param[out] val Data to be written
* @return Value indicating success or error code.
*/
tBleStatus aci_hal_write_config_data(uint8_t offset,
uint8_t len,
const uint8_t *val);
/**
* @brief This command sets the TX power level of the BlueNRG.
* @note By controlling the EN_HIGH_POWER and the PA_LEVEL, the combination of the 2 determines
* the output power level (dBm).
* When the system starts up or reboots, the default TX power level will be used, which is
* the maximum value of 8dBm. Once this command is given, the output power will be changed
* instantly, regardless if there is Bluetooth communication going on or not. For example,
* for debugging purpose, the BlueNRG can be set to advertise all the time and use this
* command to observe the signal strength changing. The system will keep the last received
* TX power level from the command, i.e. the 2nd command overwrites the previous TX power
* level. The new TX power level remains until another Set TX Power command, or the system
* reboots.\n
* @param en_high_power Can be only 0 or 1. Set high power bit on or off. It is strongly adviced to use the
* right value, depending on the selected hardware configuration for the RF network:
* normal mode or high power mode.
* @param pa_level Can be from 0 to 7. Set the PA level value.
* @return Value indicating success or error code.
*/
tBleStatus aci_hal_set_tx_power_level(uint8_t en_high_power, uint8_t pa_level);
/**
* @brief This command returns the number of packets sent in Direct Test Mode.
* @note When the Direct TX test is started, a 32-bit counter is used to count how many packets
* have been transmitted. This command can be used to check how many packets have been sent
* during the Direct TX test.\n
* The counter starts from 0 and counts upwards. The counter can wrap and start from 0 again.
* The counter is not cleared until the next Direct TX test starts.
* @param[out] number_of_packets Number of packets sent during the last Direct TX test.
* @return Value indicating success or error code.
*/
tBleStatus aci_hal_le_tx_test_packet_number(uint32_t *number_of_packets);
/**
* @brief Put the device in standby mode.
* @note Normally the BlueNRG will automatically enter sleep mode to save power. This command puts the
* device into the Standby mode instead of the sleep mode. The difference is that, in sleep mode,
* the device can still wake up itself with the internal timer. But in standby mode, this timer is
* disabled. So the only possibility to wake up the device is by external signals, e.g. a HCI command
* sent via SPI bus.
* The command is only accepted when there is no other Bluetooth activity. Otherwise an error code
* ERR_COMMAND_DISALLOWED will be returned.
*
* @return Value indicating success or error code.
*/
tBleStatus aci_hal_device_standby(void);
/**
* @brief This command starts a carrier frequency, i.e. a tone, on a specific channel.
* @note The frequency sine wave at the specific channel may be used for test purpose only.
* The channel ID is a parameter from 0 to 39 for the 40 BLE channels, e.g. 0 for 2.402GHz, 1 for 2.404GHz etc.
* This command shouldn't be used when normal Bluetooth activities are ongoing.
* The tone should be stopped by aci_hal_tone_stop() command.
*
* @param rf_channel BLE Channel ID, from 0 to 39 meaning (2.402 + 2*N) GHz. Actually the tone will be emitted at the
* channel central frequency minus 250 kHz.
* @return Value indicating success or error code.
*/
tBleStatus aci_hal_tone_start(uint8_t rf_channel);
/**
* This command is used to stop the previously started aci_hal_tone_start() command.
* @return Value indicating success or error code.
*/
tBleStatus aci_hal_tone_stop(void);
/**
* @}
*/
/**
* @defgroup Config_vals Offsets and lengths for configuration values.
* @brief Offsets and lengths for configuration values.
* See aci_hal_write_config_data().
* @{
*/
/**
* @name Configuration values.
* See @ref aci_hal_write_config_data().
* @{
*/
#define CONFIG_DATA_PUBADDR_OFFSET (0x00) /**< Bluetooth public address */
#define CONFIG_DATA_DIV_OFFSET (0x06) /**< DIV used to derive CSRK */
#define CONFIG_DATA_ER_OFFSET (0x08) /**< Encryption root key used to derive LTK and CSRK */
#define CONFIG_DATA_IR_OFFSET (0x18) /**< Identity root key used to derive LTK and CSRK */
#define CONFIG_DATA_LL_WITHOUT_HOST (0x2C) /**< Switch on/off Link Layer only mode. Set to 1 to disable Host.
It can be written only if aci_hal_write_config_data() is the first command
after reset. */
/**
* Select the BlueNRG roles and mode configurations.\n
* @li Mode 1: slave or master, 1 connection, RAM1 only (small GATT DB)
* @li Mode 2: slave or master, 1 connection, RAM1 and RAM2 (large GATT DB)
* @li Mode 3: master only, 8 connections, RAM1 and RAM2.
*/
#define CONFIG_DATA_ROLE (0x2D)
/**
* @}
*/
/**
* @name Length for configuration values.
* See @ref aci_hal_write_config_data().
* @{
*/
#define CONFIG_DATA_PUBADDR_LEN (6)
#define CONFIG_DATA_DIV_LEN (2)
#define CONFIG_DATA_ER_LEN (16)
#define CONFIG_DATA_IR_LEN (16)
#define CONFIG_DATA_LL_WITHOUT_HOST_LEN (1)
#define CONFIG_DATA_ROLE_LEN (1)
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __BLUENRG_HAL_ACI_H__ */