Skip to content

Commit 5ba3bda

Browse files
authored
Merge pull request #331 from facchinm/giga_m4
Fix functionality on Giga CM4 core
2 parents dff9e41 + de0bcbb commit 5ba3bda

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

Diff for: src/local/BLELocalDevice.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ int BLELocalDevice::begin()
7272
#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
7373
// BT_REG_ON -> HIGH
7474
pinMode(BT_REG_ON, OUTPUT);
75+
digitalWrite(BT_REG_ON, LOW);
76+
delay(500);
7577
digitalWrite(BT_REG_ON, HIGH);
78+
delay(500);
7679
#elif defined(ARDUINO_PORTENTA_C33)
7780
#define NINA_GPIO0 (100)
7881
#define NINA_RESETN (101)

Diff for: src/utility/CordioHCICustomDriver.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#if defined(CORE_CM4)
2+
3+
#include "CyH4TransportDriver.h"
4+
5+
ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver()
6+
{
7+
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
8+
/* TX */ CYBSP_BT_UART_TX, /* RX */ CYBSP_BT_UART_RX,
9+
/* cts */ CYBSP_BT_UART_CTS, /* rts */ CYBSP_BT_UART_RTS, NC, DEF_BT_BAUD_RATE,
10+
CYBSP_BT_HOST_WAKE, CYBSP_BT_DEVICE_WAKE
11+
);
12+
return s_transport_driver;
13+
}
14+
15+
#define CUSTOM_HCI_DRIVER
16+
17+
#endif

Diff for: src/utility/HCICordioTransport.cpp

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

20-
#if defined(ARDUINO_ARCH_MBED) && !defined(TARGET_NANO_RP2040_CONNECT)
21-
20+
#if defined(ARDUINO_ARCH_MBED) && !defined(TARGET_NANO_RP2040_CONNECT) // && !defined(CORE_CM4)
2221
#include <Arduino.h>
2322
#include <mbed.h>
2423

@@ -53,6 +52,8 @@
5352
#define BLE_NAMESPACE ble::vendor::cordio
5453
#endif
5554

55+
#include "CordioHCICustomDriver.h"
56+
5657
extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver();
5758

5859
namespace BLE_NAMESPACE {
@@ -181,7 +182,7 @@ HCICordioTransportClass::~HCICordioTransportClass()
181182
{
182183
}
183184

184-
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
185+
#if (defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)) && !defined(CUSTOM_HCI_DRIVER)
185186
events::EventQueue eventQueue(10 * EVENTS_EVENT_SIZE);
186187
void scheduleMbedBleEvents(BLE::OnEventsToProcessCallbackContext *context) {
187188
eventQueue.call(mbed::Callback<void()>(&context->ble, &BLE::processEvents));
@@ -201,7 +202,8 @@ int HCICordioTransportClass::begin()
201202
init_wsf(bufPoolDesc);
202203
#endif
203204

204-
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
205+
#if (defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)) && !defined(CUSTOM_HCI_DRIVER)
206+
205207
BLE &ble = BLE::Instance();
206208
ble.onEventsToProcess(scheduleMbedBleEvents);
207209

Diff for: src/utility/HCIUartTransport.cpp

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

20-
#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT)
20+
#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4)
2121

2222
#include "HCIUartTransport.h"
2323

@@ -33,6 +33,8 @@
3333
#define SerialHCI Serial3
3434
#elif defined(ARDUINO_PORTENTA_C33)
3535
#define SerialHCI Serial5
36+
#elif defined(ARDUINO_GIGA)
37+
arduino::UART SerialHCI(CYBSP_BT_UART_TX, CYBSP_BT_UART_RX, CYBSP_BT_UART_RTS, CYBSP_BT_UART_CTS);
3638
#else
3739
#error "Unsupported board selected!"
3840
#endif

0 commit comments

Comments
 (0)