-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path0020-PortentaH7-add-BLE-support.patch
142 lines (139 loc) · 5.66 KB
/
0020-PortentaH7-add-BLE-support.patch
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
From fa652a626c40a7ea540a8076fdab5dec8c3cf3fc Mon Sep 17 00:00:00 2001
From: Martino Facchin <m.facchin@arduino.cc>
Date: Wed, 28 Oct 2020 15:01:53 +0100
Subject: [PATCH 20/87] PortentaH7: add BLE support
---
.../TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp | 105 ++++++++++++++++++
targets/targets.json | 6 +
2 files changed, 111 insertions(+)
create mode 100644 connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp
diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp
new file mode 100644
index 0000000000..2d668fed9c
--- /dev/null
+++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/TARGET_PORTENTA_H7/cy_bt_cordio_cfg.cpp
@@ -0,0 +1,105 @@
+/*******************************************************************************
+* \file cy_bt_cordio_cfg.cpp
+* \version 1.0
+*
+*
+* Low Power Assist BT Pin configuration implementation.
+*
+********************************************************************************
+* \copyright
+* Copyright 2019 Cypress Semiconductor Corporation
+* SPDX-License-Identifier: Apache-2.0
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*******************************************************************************/
+
+#include <stdio.h>
+#include "ble/driver/CordioHCIDriver.h"
+#include "hci_api.h"
+#include "hci_cmd.h"
+#include "hci_core.h"
+#include "bstream.h"
+#include "assert.h"
+#include <stdbool.h>
+#include "hci_mbed_os_adaptation.h"
+#include "CyH4TransportDriver.h"
+
+#define cyhal_gpio_to_rtos(x) (x)
+#define CYCFG_BT_LP_ENABLED (1)
+#define CYCFG_BT_HOST_WAKE_IRQ_EVENT WAKE_EVENT_ACTIVE_LOW
+#define CYCFG_BT_DEV_WAKE_POLARITY WAKE_EVENT_ACTIVE_LOW
+
+/*******************************************************************************
+* Function Name: ble_cordio_get_h4_transport_driver
+********************************************************************************
+*
+* Strong implementation of function which calls CyH4TransportDriver constructor and return it
+*
+* \param none
+*
+* \return
+* Returns the transport driver object
+*******************************************************************************/
+ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver()
+{
+#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
+
+#if (defined(CYCFG_BT_LP_ENABLED))
+ if (CYCFG_BT_LP_ENABLED) {
+ static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
+ /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
+ /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
+ /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
+ /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
+ /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
+ DEF_BT_BAUD_RATE,
+ cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE),
+ cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE),
+ CYCFG_BT_HOST_WAKE_IRQ_EVENT,
+ CYCFG_BT_DEV_WAKE_POLARITY
+ );
+ return s_transport_driver;
+ } else { /* CYCFG_BT_LP_ENABLED */
+ static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
+ /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
+ /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
+ /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
+ /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
+ /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
+ DEF_BT_BAUD_RATE);
+ return s_transport_driver;
+ }
+#else /* (defined(CYCFG_BT_LP_ENABLED)) */
+ static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
+ /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
+ /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
+ /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
+ /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
+ /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
+ DEF_BT_BAUD_RATE),
+ cyhal_gpio_to_rtos(CYBSP_BT_HOST_WAKE), cyhal_gpio_to_rtos(CYBSP_BT_DEVICE_WAKE)
+ );
+ return s_transport_driver;
+#endif /* (defined(CYCFG_BT_LP_ENABLED)) */
+
+#else /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
+ static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
+ /* TX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_TX),
+ /* RX */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RX),
+ /* cts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_CTS),
+ /* rts */ cyhal_gpio_to_rtos(CYBSP_BT_UART_RTS),
+ /* power */ cyhal_gpio_to_rtos(CYBSP_BT_POWER),
+ DEF_BT_BAUD_RATE);
+ return s_transport_driver;
+#endif /* (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER) */
+}
diff --git a/targets/targets.json b/targets/targets.json
index 5cd2d47156..227e5b3438 100644
--- a/targets/targets.json
+++ b/targets/targets.json
@@ -3169,6 +3169,12 @@
"4343W_FS",
"CYW43XXX"
],
+ "extra_labels_add": [
+ "CORDIO"
+ ],
+ "features": [
+ "BLE"
+ ],
"device_has_add": [
"USBDEVICE",
"EMAC",
--
2.30.2