Skip to content

Commit 8a49b8c

Browse files
committed
Adapt to Portenta H7 via HCI
1 parent e83c3ce commit 8a49b8c

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

src/local/BLELocalDevice.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525

2626
#include "BLELocalDevice.h"
2727

28+
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
29+
#ifndef BT_REG_ON
30+
#define BT_REG_ON PJ_12
31+
#endif
32+
#endif
33+
2834
BLELocalDevice::BLELocalDevice()
2935
{
3036
}
@@ -54,6 +60,10 @@ int BLELocalDevice::begin()
5460
delay(100);
5561
digitalWrite(NINA_RESETN, HIGH);
5662
delay(750);
63+
#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
64+
// BT_REG_ON -> HIGH
65+
pinMode(BT_REG_ON, OUTPUT);
66+
digitalWrite(BT_REG_ON, HIGH);
5767
#endif
5868

5969

@@ -123,6 +133,9 @@ void BLELocalDevice::end()
123133
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
124134
// disable the NINA
125135
digitalWrite(NINA_RESETN, LOW);
136+
#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
137+
// BT_REG_ON -> LOW
138+
digitalWrite(BT_REG_ON, LOW);
126139
#endif
127140
}
128141

src/utility/ATT.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
#define ATT_CID 0x0004
2828

29-
#ifdef DM_CONN_MAX
29+
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
30+
#define ATT_MAX_PEERS 7
31+
#elif DM_CONN_MAX
3032
#define ATT_MAX_PEERS DM_CONN_MAX // Mbed + Cordio
3133
#else
3234
#define ATT_MAX_PEERS 3

src/utility/HCICordioTransport.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#ifdef ARDUINO_ARCH_MBED
20+
#if defined(ARDUINO_ARCH_MBED) && defined(CORDIO_ZERO_COPY_HCI)
2121

2222
#include <driver/CordioHCITransportDriver.h>
2323
#include <driver/CordioHCIDriver.h>
2424

25-
#include <mbed_config.h>
25+
#include <mbed.h>
2626

2727
// Parts of this file are based on: https://github.com/ARMmbed/mbed-os-cordio-hci-passthrough/pull/2
2828
// With permission from the Arm Mbed team to re-license
@@ -155,7 +155,7 @@ static void bleLoop()
155155
}
156156
#else
157157
while(true) {
158-
rtos::Thread::wait(osWaitForever);
158+
rtos::ThisThread::sleep_for(osWaitForever);
159159
}
160160
#endif // CORDIO_ZERO_COPY_HCI
161161
}
@@ -242,7 +242,7 @@ size_t HCICordioTransportClass::write(const uint8_t* data, size_t length)
242242

243243
return CordioHCIHook::getTransportDriver().write(packetType, packetLength, packet);
244244
#else
245-
return CordioHCIHook::.getTransportDriver().write(packetType, packetLength, &data[1]);
245+
return CordioHCIHook::getTransportDriver().write(packetType, packetLength, (uint8_t*)&data[1]);
246246
#endif
247247
}
248248

src/utility/HCIUartTransport.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#ifndef ARDUINO_ARCH_MBED
20+
#if !defined(ARDUINO_ARCH_MBED) || defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
2121

2222
#include "HCIUartTransport.h"
2323

2424
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_AVR_UNO_WIFI_REV2)
2525
#define SerialHCI Serial2
2626
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
2727
// SerialHCI is already defined in the variant
28+
#elif defined(ARDUINO_PORTENTA_H7_M4)
29+
// SerialHCI is already defined in the variant
30+
#elif defined(ARDUINO_PORTENTA_H7_M7)
31+
#define SerialHCI Serial2
2832
#else
2933
#error "Unsupported board selected!"
3034
#endif
@@ -91,6 +95,8 @@ size_t HCIUartTransportClass::write(const uint8_t* data, size_t length)
9195

9296
#ifdef ARDUINO_AVR_UNO_WIFI_REV2
9397
HCIUartTransportClass HCIUartTransport(SerialHCI, 119600);
98+
#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
99+
HCIUartTransportClass HCIUartTransport(SerialHCI, 115200);
94100
#else
95101
HCIUartTransportClass HCIUartTransport(SerialHCI, 912600);
96102
#endif

0 commit comments

Comments
 (0)