BLE_API wrapper library for STMicroelectronics' BlueNRG Bluetooth Low Energy expansion board shield (Component)

Dependents:   Nucleo_Zumo_BLE_IDB04A1 contest_IOT5 contest_IOT6 contest_IOT_10 ... more

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bluenrg_hal_aci.h Source File

bluenrg_hal_aci.h

00001 /******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
00002 * File Name          : bluenrg_hal_aci.h
00003 * Author             : AMS - AAS
00004 * Version            : V1.0.0
00005 * Date               : 26-Jun-2014
00006 * Description        : Header file with HCI commands for BlueNRG FW6.3.
00007 ********************************************************************************
00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00014 *******************************************************************************/
00015 
00016 #ifndef __BLUENRG_HAL_ACI_H__
00017 #define __BLUENRG_HAL_ACI_H__
00018 
00019 /**
00020  *@addtogroup HAL HAL
00021  *@brief Hardware Abstraction Layer.
00022  *@{
00023  */
00024 
00025 /**
00026  * @defgroup HAL_Functions HAL functions
00027  * @brief API for BlueNRG HAL layer.
00028  * @{
00029  */
00030 
00031 /**
00032  * @brief This command writes a value to a low level configure data structure.
00033  * @note  It is useful to setup directly some low level parameters for the system at runtime.
00034  * @param offset Offset in the data structure. The starting member in the data structure will have an offset 0.\n
00035  *               See @ref Config_vals.
00036  *
00037  * @param len Length of data to be written
00038  * @param[out] val Data to be written
00039  * @return Value indicating success or error code.
00040  */
00041 tBleStatus aci_hal_write_config_data(uint8_t offset, 
00042                                     uint8_t len,
00043                                     const uint8_t *val);
00044 
00045 /**
00046  * @brief This command requests the value in the low level configure data structure.
00047  *        The number of read bytes changes for different Offset.
00048  * @param offset Offset in the data structure. The starting member in the data structure will have an offset 0.\n
00049  *               See @ref Config_vals.
00050  * @param data_len Length of the data buffer
00051  * @param[out] data_len_out_p length of the data returned by the read.
00052  * @param[out] data Read data
00053  * @return Value indicating success or error code.
00054  */
00055 tBleStatus aci_hal_read_config_data(uint8_t offset, uint16_t data_len, uint8_t *data_len_out_p, uint8_t *data);
00056 
00057 /**
00058  * @brief This command sets the TX power level of the BlueNRG.
00059  * @note  By controlling the EN_HIGH_POWER and the PA_LEVEL, the combination of the 2 determines
00060  *        the output power level (dBm).
00061  *        When the system starts up or reboots, the default TX power level will be used, which is
00062  *        the maximum value of 8dBm. Once this command is given, the output power will be changed
00063  *        instantly, regardless if there is Bluetooth communication going on or not. For example,
00064  *        for debugging purpose, the BlueNRG can be set to advertise all the time and use this
00065  *        command to observe the signal strength changing. The system will keep the last received
00066  *        TX power level from the command, i.e. the 2nd command overwrites the previous TX power
00067  *        level. The new TX power level remains until another Set TX Power command, or the system
00068  *        reboots.\n
00069  * @param en_high_power Can be only 0 or 1. Set high power bit on or off. It is strongly adviced to use the
00070  *                      right value, depending on the selected hardware configuration for the RF network:
00071  *                      normal mode or high power mode.
00072  * @param pa_level Can be from 0 to 7. Set the PA level value.
00073  * @return Value indicating success or error code.
00074  */
00075 tBleStatus aci_hal_set_tx_power_level(uint8_t en_high_power, uint8_t pa_level);
00076 
00077 /**
00078  * @brief This command returns the number of packets sent in Direct Test Mode.
00079  * @note  When the Direct TX test is started, a 32-bit counter is used to count how many packets
00080  *        have been transmitted. This command can be used to check how many packets have been sent
00081  *        during the Direct TX test.\n
00082  *        The counter starts from 0 and counts upwards. The counter can wrap and start from 0 again.
00083  *        The counter is not cleared until the next Direct TX test starts.
00084  * @param[out] number_of_packets Number of packets sent during the last Direct TX test.
00085  * @return Value indicating success or error code.
00086  */
00087 tBleStatus aci_hal_le_tx_test_packet_number(uint32_t *number_of_packets);
00088 
00089 /**
00090  * @brief Put the device in standby mode.
00091  * @note Normally the BlueNRG will automatically enter sleep mode to save power. This command puts the
00092  *       device into the Standby mode instead of the sleep mode. The difference is that, in sleep mode,
00093  *       the device can still wake up itself with the internal timer. But in standby mode, this timer is
00094  *       disabled. So the only possibility to wake up the device is by external signals, e.g. a HCI command
00095  *       sent via SPI bus.
00096  *       The command is only accepted when there is no other Bluetooth activity. Otherwise an error code
00097  *       ERR_COMMAND_DISALLOWED will be returned.
00098  *
00099  * @return Value indicating success or error code.
00100  */
00101 tBleStatus aci_hal_device_standby(void);
00102 
00103 /**
00104  * @brief This command starts a carrier frequency, i.e. a tone, on a specific channel.
00105  * @note  The frequency sine wave at the specific channel may be used for test purpose only.
00106  *        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.
00107  *        This command shouldn't be used when normal Bluetooth activities are ongoing.
00108  *        The tone should be stopped by aci_hal_tone_stop() command.
00109  *
00110  * @param rf_channel BLE Channel ID, from 0 to 39 meaning (2.402 + 2*N) GHz. Actually the tone will be emitted at the
00111  *                   channel central frequency minus 250 kHz.
00112  * @return Value indicating success or error code.
00113  */
00114 tBleStatus aci_hal_tone_start(uint8_t rf_channel);
00115 
00116 /**
00117  * This command is used to stop the previously started aci_hal_tone_start() command.
00118  * @return Value indicating success or error code.
00119  */
00120 tBleStatus aci_hal_tone_stop(void);
00121 
00122 /**
00123  * @}
00124  */
00125 
00126 /**
00127  * @defgroup Config_vals Offsets and lengths for configuration values.
00128  * @brief Offsets and lengths for configuration values.
00129  *        See aci_hal_write_config_data().
00130  * @{
00131  */
00132 
00133 /**
00134  * @name Configuration values.
00135  * See @ref aci_hal_write_config_data().
00136  * @{
00137  */
00138 #define CONFIG_DATA_PUBADDR_OFFSET          (0x00) /**< Bluetooth public address */
00139 #define CONFIG_DATA_DIV_OFFSET              (0x06) /**< DIV used to derive CSRK */
00140 #define CONFIG_DATA_ER_OFFSET               (0x08) /**< Encryption root key used to derive LTK and CSRK */
00141 #define CONFIG_DATA_IR_OFFSET               (0x18) /**< Identity root key used to derive LTK and CSRK */
00142 #define CONFIG_DATA_LL_WITHOUT_HOST         (0x2C) /**< Switch on/off Link Layer only mode. Set to 1 to disable Host.
00143                                                      It can be written only if aci_hal_write_config_data() is the first command
00144                                                      after reset. */
00145 
00146 #define CONFIG_DATA_RANDOM_ADDRESS_IDB05A1  (0x80) /**< Stored static random address. Read-only (IDB05A1 only) */
00147 
00148 /**
00149  * Select the BlueNRG roles and mode configurations.\n
00150  * @li Mode 1: slave or master, 1 connection, RAM1 only (small GATT DB)
00151  * @li Mode 2: slave or master, 1 connection, RAM1 and RAM2 (large GATT DB)
00152  * @li Mode 3: master only, 8 connections, RAM1 and RAM2.
00153  */
00154 #define CONFIG_DATA_ROLE                    (0x2D)
00155 /**
00156  * @}
00157  */
00158 
00159 /**
00160  * @name Length for configuration values.
00161  * See @ref aci_hal_write_config_data().
00162  * @{
00163  */
00164 #define CONFIG_DATA_PUBADDR_LEN             (6)
00165 #define CONFIG_DATA_DIV_LEN                 (2)
00166 #define CONFIG_DATA_ER_LEN                  (16)
00167 #define CONFIG_DATA_IR_LEN                  (16)
00168 #define CONFIG_DATA_LL_WITHOUT_HOST_LEN     (1)
00169 #define CONFIG_DATA_ROLE_LEN                (1)
00170 /**
00171  * @}
00172  */
00173 
00174 /**
00175  * @}
00176  */
00177 
00178 /**
00179  * @}
00180  */
00181 
00182 
00183 #endif /* __BLUENRG_HAL_ACI_H__ */