char res[20];

Dependents:   BMC

Committer:
Wolfgang Betz
Date:
Wed Oct 07 08:39:04 2015 +0200
Revision:
132:51056160fa4a
Child:
229:9981f62cdb1a
Andrea's version as of mail from 10/06/2015 05:56 PM

From: Andrea PALMIERI <andrea.palmieri@st.com>
To: Wolfgang BETZ <wolfgang.betz@st.com>, Rohit Grover <rohit.grover@arm.com>,
Antonio VILEI <antonio.vilei@st.com>, Mihail Stoyanov
<Mihail.Stoyanov@arm.com>
CC: Nicola CAPOVILLA <nicola.capovilla@st.com>, Silvio Lucio OLIVA
<silvio.oliva@st.com>, "jonathan.austin@arm.com" <jonathan.austin@arm.com>
Content-Class: urn:content-classes:message
Date: Tue, 6 Oct 2015 17:56:34 +0200
Subject: RE: Arduino Compatibility of X-NUCLEO-IDB04A1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 132:51056160fa4a 1 /******************** (C) COPYRIGHT 2012 STMicroelectronics ********************
Wolfgang Betz 132:51056160fa4a 2 * File Name : hci.h
Wolfgang Betz 132:51056160fa4a 3 * Author : AMS - HEA&RF BU
Wolfgang Betz 132:51056160fa4a 4 * Version : V1.0.0
Wolfgang Betz 132:51056160fa4a 5 * Date : 19-July-2012
Wolfgang Betz 132:51056160fa4a 6 * Description : Constants and functions for HCI layer. See Bluetooth Core
Wolfgang Betz 132:51056160fa4a 7 * v 4.0, Vol. 2, Part E.
Wolfgang Betz 132:51056160fa4a 8 ********************************************************************************
Wolfgang Betz 132:51056160fa4a 9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
Wolfgang Betz 132:51056160fa4a 10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
Wolfgang Betz 132:51056160fa4a 11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
Wolfgang Betz 132:51056160fa4a 12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
Wolfgang Betz 132:51056160fa4a 13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
Wolfgang Betz 132:51056160fa4a 14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
Wolfgang Betz 132:51056160fa4a 15 *******************************************************************************/
Wolfgang Betz 132:51056160fa4a 16
Wolfgang Betz 132:51056160fa4a 17 #ifndef __HCI_H_
Wolfgang Betz 132:51056160fa4a 18 #define __HCI_H_
Wolfgang Betz 132:51056160fa4a 19
Wolfgang Betz 132:51056160fa4a 20 #include "hal_types.h"
Wolfgang Betz 132:51056160fa4a 21 #include "link_layer.h"
Wolfgang Betz 132:51056160fa4a 22 #include <list.h>
Wolfgang Betz 132:51056160fa4a 23
Wolfgang Betz 132:51056160fa4a 24 #define HCI_READ_PACKET_SIZE 128 //71
Wolfgang Betz 132:51056160fa4a 25
Wolfgang Betz 132:51056160fa4a 26 /*** Data types ***/
Wolfgang Betz 132:51056160fa4a 27
Wolfgang Betz 132:51056160fa4a 28 /* structure used to read received data */
Wolfgang Betz 132:51056160fa4a 29 typedef struct _tHciDataPacket
Wolfgang Betz 132:51056160fa4a 30 {
Wolfgang Betz 132:51056160fa4a 31 tListNode currentNode;
Wolfgang Betz 132:51056160fa4a 32 uint8_t dataBuff[HCI_READ_PACKET_SIZE];
Wolfgang Betz 132:51056160fa4a 33 uint8_t data_len;
Wolfgang Betz 132:51056160fa4a 34 } tHciDataPacket;
Wolfgang Betz 132:51056160fa4a 35
Wolfgang Betz 132:51056160fa4a 36 typedef enum
Wolfgang Betz 132:51056160fa4a 37 {
Wolfgang Betz 132:51056160fa4a 38 BUSY,
Wolfgang Betz 132:51056160fa4a 39 AVAILABLE
Wolfgang Betz 132:51056160fa4a 40 } HCI_CMD_STATUS_t;
Wolfgang Betz 132:51056160fa4a 41
Wolfgang Betz 132:51056160fa4a 42 /**
Wolfgang Betz 132:51056160fa4a 43 * @defgroup HCI_Error_codes HCI Error codes
Wolfgang Betz 132:51056160fa4a 44 * @{
Wolfgang Betz 132:51056160fa4a 45 */
Wolfgang Betz 132:51056160fa4a 46 #define HCI_UNKNOWN_COMMAND 0x01
Wolfgang Betz 132:51056160fa4a 47 #define HCI_NO_CONNECTION 0x02
Wolfgang Betz 132:51056160fa4a 48 #define HCI_HARDWARE_FAILURE 0x03
Wolfgang Betz 132:51056160fa4a 49 #define HCI_PAGE_TIMEOUT 0x04
Wolfgang Betz 132:51056160fa4a 50 #define HCI_AUTHENTICATION_FAILURE 0x05
Wolfgang Betz 132:51056160fa4a 51 #define HCI_PIN_OR_KEY_MISSING 0x06
Wolfgang Betz 132:51056160fa4a 52 #define HCI_MEMORY_FULL 0x07
Wolfgang Betz 132:51056160fa4a 53 #define HCI_CONNECTION_TIMEOUT 0x08
Wolfgang Betz 132:51056160fa4a 54 #define HCI_MAX_NUMBER_OF_CONNECTIONS 0x09
Wolfgang Betz 132:51056160fa4a 55 #define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a
Wolfgang Betz 132:51056160fa4a 56 #define HCI_ACL_CONNECTION_EXISTS 0x0b
Wolfgang Betz 132:51056160fa4a 57 #define HCI_COMMAND_DISALLOWED 0x0c
Wolfgang Betz 132:51056160fa4a 58 #define HCI_REJECTED_LIMITED_RESOURCES 0x0d
Wolfgang Betz 132:51056160fa4a 59 #define HCI_REJECTED_SECURITY 0x0e
Wolfgang Betz 132:51056160fa4a 60 #define HCI_REJECTED_PERSONAL 0x0f
Wolfgang Betz 132:51056160fa4a 61 #define HCI_HOST_TIMEOUT 0x10
Wolfgang Betz 132:51056160fa4a 62 #define HCI_UNSUPPORTED_FEATURE 0x11
Wolfgang Betz 132:51056160fa4a 63 #define HCI_INVALID_PARAMETERS 0x12
Wolfgang Betz 132:51056160fa4a 64 #define HCI_OE_USER_ENDED_CONNECTION 0x13
Wolfgang Betz 132:51056160fa4a 65 #define HCI_OE_LOW_RESOURCES 0x14
Wolfgang Betz 132:51056160fa4a 66 #define HCI_OE_POWER_OFF 0x15
Wolfgang Betz 132:51056160fa4a 67 #define HCI_CONNECTION_TERMINATED 0x16
Wolfgang Betz 132:51056160fa4a 68 #define HCI_REPEATED_ATTEMPTS 0x17
Wolfgang Betz 132:51056160fa4a 69 #define HCI_PAIRING_NOT_ALLOWED 0x18
Wolfgang Betz 132:51056160fa4a 70 #define HCI_UNKNOWN_LMP_PDU 0x19
Wolfgang Betz 132:51056160fa4a 71 #define HCI_UNSUPPORTED_REMOTE_FEATURE 0x1a
Wolfgang Betz 132:51056160fa4a 72 #define HCI_SCO_OFFSET_REJECTED 0x1b
Wolfgang Betz 132:51056160fa4a 73 #define HCI_SCO_INTERVAL_REJECTED 0x1c
Wolfgang Betz 132:51056160fa4a 74 #define HCI_AIR_MODE_REJECTED 0x1d
Wolfgang Betz 132:51056160fa4a 75 #define HCI_INVALID_LMP_PARAMETERS 0x1e
Wolfgang Betz 132:51056160fa4a 76 #define HCI_UNSPECIFIED_ERROR 0x1f
Wolfgang Betz 132:51056160fa4a 77 #define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20
Wolfgang Betz 132:51056160fa4a 78 #define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21
Wolfgang Betz 132:51056160fa4a 79 #define HCI_LMP_RESPONSE_TIMEOUT 0x22
Wolfgang Betz 132:51056160fa4a 80 #define HCI_LMP_ERROR_TRANSACTION_COLLISION 0x23
Wolfgang Betz 132:51056160fa4a 81 #define HCI_LMP_PDU_NOT_ALLOWED 0x24
Wolfgang Betz 132:51056160fa4a 82 #define HCI_ENCRYPTION_MODE_NOT_ACCEPTED 0x25
Wolfgang Betz 132:51056160fa4a 83 #define HCI_UNIT_LINK_KEY_USED 0x26
Wolfgang Betz 132:51056160fa4a 84 #define HCI_QOS_NOT_SUPPORTED 0x27
Wolfgang Betz 132:51056160fa4a 85 #define HCI_INSTANT_PASSED 0x28
Wolfgang Betz 132:51056160fa4a 86 #define HCI_PAIRING_NOT_SUPPORTED 0x29
Wolfgang Betz 132:51056160fa4a 87 #define HCI_TRANSACTION_COLLISION 0x2a
Wolfgang Betz 132:51056160fa4a 88 #define HCI_QOS_UNACCEPTABLE_PARAMETER 0x2c
Wolfgang Betz 132:51056160fa4a 89 #define HCI_QOS_REJECTED 0x2d
Wolfgang Betz 132:51056160fa4a 90 #define HCI_CLASSIFICATION_NOT_SUPPORTED 0x2e
Wolfgang Betz 132:51056160fa4a 91 #define HCI_INSUFFICIENT_SECURITY 0x2f
Wolfgang Betz 132:51056160fa4a 92 #define HCI_PARAMETER_OUT_OF_RANGE 0x30
Wolfgang Betz 132:51056160fa4a 93 #define HCI_ROLE_SWITCH_PENDING 0x32
Wolfgang Betz 132:51056160fa4a 94 #define HCI_SLOT_VIOLATION 0x34
Wolfgang Betz 132:51056160fa4a 95 #define HCI_ROLE_SWITCH_FAILED 0x35
Wolfgang Betz 132:51056160fa4a 96 #define HCI_EIR_TOO_LARGE 0x36
Wolfgang Betz 132:51056160fa4a 97 #define HCI_SIMPLE_PAIRING_NOT_SUPPORTED 0x37
Wolfgang Betz 132:51056160fa4a 98 #define HCI_HOST_BUSY_PAIRING 0x38
Wolfgang Betz 132:51056160fa4a 99 #define HCI_CONN_REJ_NO_CH_FOUND 0x39
Wolfgang Betz 132:51056160fa4a 100 #define HCI_CONTROLLER_BUSY 0x3A
Wolfgang Betz 132:51056160fa4a 101 #define HCI_UNACCEPTABLE_CONN_INTERV 0x3B
Wolfgang Betz 132:51056160fa4a 102 #define HCI_DIRECTED_ADV_TIMEOUT 0x3C
Wolfgang Betz 132:51056160fa4a 103 #define HCI_CONN_TERM_MIC_FAIL 0x3D
Wolfgang Betz 132:51056160fa4a 104 #define HCI_CONN_FAIL_TO_BE_ESTABL 0x3E
Wolfgang Betz 132:51056160fa4a 105 #define HCI_MAC_CONN_FAILED 0x3F
Wolfgang Betz 132:51056160fa4a 106 /**
Wolfgang Betz 132:51056160fa4a 107 * @}
Wolfgang Betz 132:51056160fa4a 108 */
Wolfgang Betz 132:51056160fa4a 109
Wolfgang Betz 132:51056160fa4a 110
Wolfgang Betz 132:51056160fa4a 111 /*
Wolfgang Betz 132:51056160fa4a 112 * HCI library functions.
Wolfgang Betz 132:51056160fa4a 113 * Each function returns 0 in case of success, otherwise one of the error codes.
Wolfgang Betz 132:51056160fa4a 114 */
Wolfgang Betz 132:51056160fa4a 115
Wolfgang Betz 132:51056160fa4a 116 int hci_reset(void);
Wolfgang Betz 132:51056160fa4a 117
Wolfgang Betz 132:51056160fa4a 118 int hci_disconnect(uint16_t handle, uint8_t reason);
Wolfgang Betz 132:51056160fa4a 119
Wolfgang Betz 132:51056160fa4a 120 int hci_le_set_advertise_enable(uint8_t enable);
Wolfgang Betz 132:51056160fa4a 121
Wolfgang Betz 132:51056160fa4a 122 int hci_le_set_advertising_parameters(uint16_t min_interval, uint16_t max_interval, uint8_t advtype,
Wolfgang Betz 132:51056160fa4a 123 uint8_t own_bdaddr_type, uint8_t direct_bdaddr_type, const tBDAddr direct_bdaddr, uint8_t chan_map,
Wolfgang Betz 132:51056160fa4a 124 uint8_t filter);
Wolfgang Betz 132:51056160fa4a 125
Wolfgang Betz 132:51056160fa4a 126 int hci_le_set_scan_parameters(uint8_t type, uint16_t interval,
Wolfgang Betz 132:51056160fa4a 127 uint16_t window, uint8_t own_bdaddr_type,
Wolfgang Betz 132:51056160fa4a 128 uint8_t filter);
Wolfgang Betz 132:51056160fa4a 129
Wolfgang Betz 132:51056160fa4a 130 int hci_le_set_scan_enable(uint8_t enable, uint8_t filter_dup);
Wolfgang Betz 132:51056160fa4a 131
Wolfgang Betz 132:51056160fa4a 132 int hci_le_set_advertising_data(uint8_t length, const uint8_t data[]);
Wolfgang Betz 132:51056160fa4a 133
Wolfgang Betz 132:51056160fa4a 134 int hci_le_set_scan_resp_data(uint8_t length, const uint8_t data[]);
Wolfgang Betz 132:51056160fa4a 135
Wolfgang Betz 132:51056160fa4a 136 int hci_le_rand(uint8_t random_number[8]);
Wolfgang Betz 132:51056160fa4a 137
Wolfgang Betz 132:51056160fa4a 138 int hci_le_read_advertising_channel_tx_power(int8_t *tx_power_level);
Wolfgang Betz 132:51056160fa4a 139
Wolfgang Betz 132:51056160fa4a 140 int hci_acl_data(const uint8_t * data, uint16_t len);
Wolfgang Betz 132:51056160fa4a 141
Wolfgang Betz 132:51056160fa4a 142 int hci_le_set_random_address(tBDAddr bdaddr);
Wolfgang Betz 132:51056160fa4a 143
Wolfgang Betz 132:51056160fa4a 144 int hci_read_bd_addr(tBDAddr bdaddr);
Wolfgang Betz 132:51056160fa4a 145
Wolfgang Betz 132:51056160fa4a 146 int hci_le_read_white_list_size(uint8_t *size);
Wolfgang Betz 132:51056160fa4a 147
Wolfgang Betz 132:51056160fa4a 148 int hci_le_clear_white_list(void);
Wolfgang Betz 132:51056160fa4a 149
Wolfgang Betz 132:51056160fa4a 150 int hci_le_add_device_to_white_list(uint8_t bdaddr_type, tBDAddr bdaddr);
Wolfgang Betz 132:51056160fa4a 151
Wolfgang Betz 132:51056160fa4a 152 int hci_le_remove_device_from_white_list(uint8_t bdaddr_type, tBDAddr bdaddr);
Wolfgang Betz 132:51056160fa4a 153
Wolfgang Betz 132:51056160fa4a 154 int hci_le_encrypt(uint8_t key[16], uint8_t plaintextData[16], uint8_t encryptedData[16]);
Wolfgang Betz 132:51056160fa4a 155
Wolfgang Betz 132:51056160fa4a 156 int hci_le_ltk_request_reply(uint8_t key[16]);
Wolfgang Betz 132:51056160fa4a 157
Wolfgang Betz 132:51056160fa4a 158 int hci_le_ltk_request_neg_reply(void);
Wolfgang Betz 132:51056160fa4a 159
Wolfgang Betz 132:51056160fa4a 160 int hci_le_read_buffer_size(uint16_t *pkt_len, uint8_t *max_pkt);
Wolfgang Betz 132:51056160fa4a 161
Wolfgang Betz 132:51056160fa4a 162 int hci_le_create_connection(uint16_t interval, uint16_t window, uint8_t initiator_filter, uint8_t peer_bdaddr_type,
Wolfgang Betz 132:51056160fa4a 163 const tBDAddr peer_bdaddr, uint8_t own_bdaddr_type, uint16_t min_interval, uint16_t max_interval,
Wolfgang Betz 132:51056160fa4a 164 uint16_t latency, uint16_t supervision_timeout, uint16_t min_ce_length, uint16_t max_ce_length);
Wolfgang Betz 132:51056160fa4a 165
Wolfgang Betz 132:51056160fa4a 166 int hci_read_transmit_power_level(uint16_t *conn_handle, uint8_t type, int8_t *tx_level);
Wolfgang Betz 132:51056160fa4a 167
Wolfgang Betz 132:51056160fa4a 168 int hci_read_rssi(uint16_t *conn_handle, int8_t *rssi);
Wolfgang Betz 132:51056160fa4a 169
Wolfgang Betz 132:51056160fa4a 170 int hci_le_read_local_supported_features(uint8_t *features);
Wolfgang Betz 132:51056160fa4a 171
Wolfgang Betz 132:51056160fa4a 172 int hci_le_read_channel_map(uint16_t conn_handle, uint8_t ch_map[5]);
Wolfgang Betz 132:51056160fa4a 173
Wolfgang Betz 132:51056160fa4a 174 int hci_le_read_supported_states(uint8_t states[8]);
Wolfgang Betz 132:51056160fa4a 175
Wolfgang Betz 132:51056160fa4a 176 int hci_le_receiver_test(uint8_t frequency);
Wolfgang Betz 132:51056160fa4a 177
Wolfgang Betz 132:51056160fa4a 178 int hci_le_transmitter_test(uint8_t frequency, uint8_t length, uint8_t payload);
Wolfgang Betz 132:51056160fa4a 179
Wolfgang Betz 132:51056160fa4a 180 int hci_le_test_end(uint16_t *num_pkts);
Wolfgang Betz 132:51056160fa4a 181
Wolfgang Betz 132:51056160fa4a 182 int hci_le_read_local_version(uint8_t *hci_version, uint16_t *hci_revision, uint8_t *lmp_pal_version,
Wolfgang Betz 132:51056160fa4a 183 uint16_t *manufacturer_name, uint16_t *lmp_pal_subversion);
Wolfgang Betz 132:51056160fa4a 184
Wolfgang Betz 132:51056160fa4a 185 /**
Wolfgang Betz 132:51056160fa4a 186 * This function must be used to pass the packet received from the HCI
Wolfgang Betz 132:51056160fa4a 187 * interface to the BLE Stack HCI state machine.
Wolfgang Betz 132:51056160fa4a 188 *
Wolfgang Betz 132:51056160fa4a 189 * @param[in] hciReadPacket The packet that is received from HCI interface.
Wolfgang Betz 132:51056160fa4a 190 *
Wolfgang Betz 132:51056160fa4a 191 */
Wolfgang Betz 132:51056160fa4a 192 void HCI_Input(tHciDataPacket *hciReadPacket);
Wolfgang Betz 132:51056160fa4a 193
Wolfgang Betz 132:51056160fa4a 194 /**
Wolfgang Betz 132:51056160fa4a 195 * Initialization function. Must be done before any data can be received from
Wolfgang Betz 132:51056160fa4a 196 * BLE controller.
Wolfgang Betz 132:51056160fa4a 197 */
Wolfgang Betz 132:51056160fa4a 198 void HCI_Init(void);
Wolfgang Betz 132:51056160fa4a 199
Wolfgang Betz 132:51056160fa4a 200 /**
Wolfgang Betz 132:51056160fa4a 201 * Callback used to pass events to application.
Wolfgang Betz 132:51056160fa4a 202 *
Wolfgang Betz 132:51056160fa4a 203 * @param[in] pckt The event.
Wolfgang Betz 132:51056160fa4a 204 *
Wolfgang Betz 132:51056160fa4a 205 */
Wolfgang Betz 132:51056160fa4a 206 extern void HCI_Event_CB(void *pckt);
Wolfgang Betz 132:51056160fa4a 207
Wolfgang Betz 132:51056160fa4a 208 /**
Wolfgang Betz 132:51056160fa4a 209 * Processing function that must be called after an event is received from
Wolfgang Betz 132:51056160fa4a 210 * HCI interface. Must be called outside ISR. It will call HCI_Event_CB if
Wolfgang Betz 132:51056160fa4a 211 * necessary.
Wolfgang Betz 132:51056160fa4a 212 */
Wolfgang Betz 132:51056160fa4a 213 void HCI_Process(void);
Wolfgang Betz 132:51056160fa4a 214
Wolfgang Betz 132:51056160fa4a 215 /**
Wolfgang Betz 132:51056160fa4a 216 * @brief Check if queue of HCI event is empty or not.
Wolfgang Betz 132:51056160fa4a 217 * @note This funtion can be used to check if the event queue from BlueNRG is empty. This
Wolfgang Betz 132:51056160fa4a 218 * is useful when checking if it is safe to go to sleep.
Wolfgang Betz 132:51056160fa4a 219 * @return TRUE if event queue is empty. FALSE otherwhise.
Wolfgang Betz 132:51056160fa4a 220 */
Wolfgang Betz 132:51056160fa4a 221 BOOL HCI_Queue_Empty(void);
Wolfgang Betz 132:51056160fa4a 222 /**
Wolfgang Betz 132:51056160fa4a 223 * Iterrupt service routine that must be called when the BlueNRG
Wolfgang Betz 132:51056160fa4a 224 * reports a packet received or an event to the host through the
Wolfgang Betz 132:51056160fa4a 225 * BlueNRG interrupt line.
Wolfgang Betz 132:51056160fa4a 226 */
Wolfgang Betz 132:51056160fa4a 227 #ifdef __DMA_LP__
Wolfgang Betz 132:51056160fa4a 228 void HCI_Isr(uint8_t *buffer, uint8_t event_payload_len);
Wolfgang Betz 132:51056160fa4a 229 void HCI_Process_Notification_Request(void);
Wolfgang Betz 132:51056160fa4a 230 void HCI_Cmd_Status(HCI_CMD_STATUS_t Hci_Cmd_Status);
Wolfgang Betz 132:51056160fa4a 231 void HCI_Wait_For_Response(void);
Wolfgang Betz 132:51056160fa4a 232 #else
Wolfgang Betz 132:51056160fa4a 233 void HCI_Isr(void);
Wolfgang Betz 132:51056160fa4a 234 #endif /* __DMA_LP__ */
Wolfgang Betz 132:51056160fa4a 235
Wolfgang Betz 132:51056160fa4a 236 extern tListNode hciReadPktPool;
Wolfgang Betz 132:51056160fa4a 237 extern tListNode hciReadPktRxQueue;
Wolfgang Betz 132:51056160fa4a 238
Wolfgang Betz 132:51056160fa4a 239 #endif /* __HCI_H_ */