summaryrefslogtreecommitdiff
path: root/include/bluetooth_le_ll.h
diff options
context:
space:
mode:
authorMyles Watson <mylesgw@chromium.org>2015-02-02 14:44:27 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-08-08 01:48:43 -0700
commit9ee1b4a767daaf23b278c9f33b0fe30bf9d91adf (patch)
treebbcce34eeaaecbd2de74636c526d33226a8bc828 /include/bluetooth_le_ll.h
parent73701c46370cd562d311feeb80b2de8ea696935c (diff)
downloadchrome-ec-9ee1b4a767daaf23b278c9f33b0fe30bf9d91adf.tar.gz
btle: Add common link layer code
BUG=None BRANCH=None TEST=make BOARD=hadoken Add a task that is responsible for the state of the link layer. Change-Id: Ifc79bf1e4c57f5de448ab05b3a8d3a1aca5a58e2 Signed-off-by: Myles Watson <mylesgw@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362144 Commit-Ready: Dan Shi <dshi@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/bluetooth_le_ll.h')
-rw-r--r--include/bluetooth_le_ll.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/include/bluetooth_le_ll.h b/include/bluetooth_le_ll.h
new file mode 100644
index 0000000000..14520f1139
--- /dev/null
+++ b/include/bluetooth_le_ll.h
@@ -0,0 +1,120 @@
+/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "btle_hci_int.h"
+
+enum ll_state_t {
+ UNINITIALIZED,
+ STANDBY,
+ SCANNING,
+ ADVERTISING,
+ INITIATING,
+ CONNECTION,
+ TEST_RX,
+ TEST_TX,
+};
+
+#define LL_ADV_INTERVAL_UNIT_US 625
+#define LL_ADV_TIMEOUT_UNIT_US 1000000
+
+#define LL_ADV_DIRECT_INTERVAL_US 3750 /* 3.75 ms */
+#define LL_ADV_DIRECT_TIMEOUT_US 1280000 /* 1.28 s */
+
+#define LL_MAX_DATA_PACKET_LENGTH 27
+#define LL_MAX_DATA_PACKETS 4
+
+#define LL_MAX_BUFFER_SIZE (LL_MAX_DATA_PACKET_LENGTH * LL_MAX_DATA_PACKETS)
+
+#define LL_SUPPORTED_FEATURES (HCI_LE_FTR_ENCRYPTION | \
+ HCI_LE_FTR_CONNECTION_PARAMETERS_REQUEST | \
+ HCI_LE_FTR_EXTENDED_REJECT_INDICATION | \
+ HCI_LE_FTR_SLAVE_INITIATED_FEATURES_EXCHANGE)
+
+#define LL_SUPPORTED_STATES (HCI_LE_STATE_NONCON_ADV | \
+ HCI_LE_STATE_SCANNABLE_ADV | \
+ HCI_LE_STATE_CONNECTABLE_ADV | \
+ HCI_LE_STATE_DIRECT_ADV | \
+ HCI_LE_STATE_PASSIVE_SCAN | \
+ HCI_LE_STATE_ACTIVE_SCAN | \
+ HCI_LE_STATE_INITIATE | \
+ HCI_LE_STATE_SLAVE)
+
+/*
+ * 4.6.1 LE Encryption
+ * A controller that supports LE Encryption shall support the following sections
+ * within this document:
+ * - LL_ENC_REQ (Section 2.4.2.4)
+ * - LL_ENC_RSP (Section 2.4.2.5)
+ * - LL_START_ENC_REQ (Section 2.4.2.6)
+ * - LL_START_ENC_RSP (Section 2.4.2.7)
+ * - LL_PAUSE_ENC_REQ (Section 2.4.2.11)
+ * - LL_PAUSE_ENC_RSP (Section 2.4.2.12)
+ * - Encryption Start Procedure (Section 5.1.3.1)
+ * - Encryption Pause Procedure (Section 5.1.3.2)
+ */
+
+/*Link Layer Control PDU Opcodes */
+#define LL_CONNECTION_UPDATE_REQ 0x00
+#define LL_CHANNEL_MAP_REQ 0x01
+#define LL_TERMINATE_IND 0x02
+#define LL_ENC_REQ 0x03
+#define LL_ENC_RSP 0x04
+#define LL_START_ENC_REQ 0x05
+#define LL_START_ENC_RSP 0x06
+#define LL_UNKNOWN_RSP 0x07
+#define LL_FEATURE_REQ 0x08
+#define LL_FEATURE_RSP 0x09
+#define LL_PAUSE_ENC_REQ 0x0A
+#define LL_PAUSE_ENC_RSP 0x0B
+#define LL_VERSION_IND 0x0C
+#define LL_REJECT_IND 0x0D
+#define LL_SLAVE_FEATURE_REQ 0x0E
+#define LL_CONNECTION_PARAM_REQ 0x0F
+#define LL_CONNECTION_PARAM_RSP 0x10
+#define LL_REJECT_IND_EXT 0x11
+#define LL_PING_REQ 0x12
+#define LL_PING_RSP 0x13
+
+uint8_t ll_reset(void);
+
+uint8_t ll_set_tx_power(uint8_t *params);
+
+
+/* LE Information */
+uint8_t ll_read_buffer_size(uint8_t *return_params);
+uint8_t ll_read_local_supported_features(uint8_t *return_params);
+uint8_t ll_read_supported_states(uint8_t *return_params);
+uint8_t ll_set_host_channel_classification(uint8_t *params);
+
+/* Advertising */
+uint8_t ll_set_advertising_params(uint8_t *params);
+uint8_t ll_read_tx_power(void);
+uint8_t ll_set_adv_data(uint8_t *params);
+uint8_t ll_set_scan_response_data(uint8_t *params);
+uint8_t ll_set_advertising_enable(uint8_t *params);
+
+uint8_t ll_set_random_address(uint8_t *params);
+
+/* Scanning */
+uint8_t ll_set_scan_enable(uint8_t *params);
+uint8_t ll_set_scan_params(uint8_t *params);
+
+/* White List */
+uint8_t ll_clear_white_list(void);
+uint8_t ll_read_white_list_size(uint8_t *return_params);
+uint8_t ll_add_device_to_white_list(uint8_t *params);
+uint8_t ll_remove_device_from_white_list(uint8_t *params);
+
+/* Connections */
+uint8_t ll_read_remote_used_features(uint8_t *params);
+
+/* RF Phy Testing */
+uint8_t ll_receiver_test(uint8_t *params);
+uint8_t ll_transmitter_test(uint8_t *params);
+uint8_t ll_test_end(uint8_t *return_params);
+
+void ll_ble_test_rx(void);
+void ll_ble_test_rx(void);