Skip to content

Commit

Permalink
Fix functionality on Giga CM4 core
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Oct 26, 2023
1 parent dff9e41 commit de0bcbb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/local/BLELocalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ int BLELocalDevice::begin()
#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
// BT_REG_ON -> HIGH
pinMode(BT_REG_ON, OUTPUT);
digitalWrite(BT_REG_ON, LOW);
delay(500);
digitalWrite(BT_REG_ON, HIGH);
delay(500);
#elif defined(ARDUINO_PORTENTA_C33)
#define NINA_GPIO0 (100)
#define NINA_RESETN (101)
Expand Down
17 changes: 17 additions & 0 deletions src/utility/CordioHCICustomDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#if defined(CORE_CM4)

#include "CyH4TransportDriver.h"

ble::vendor::cypress_ble::CyH4TransportDriver& ble_cordio_get_h4_transport_driver()
{
static ble::vendor::cypress_ble::CyH4TransportDriver s_transport_driver(
/* TX */ CYBSP_BT_UART_TX, /* RX */ CYBSP_BT_UART_RX,
/* cts */ CYBSP_BT_UART_CTS, /* rts */ CYBSP_BT_UART_RTS, NC, DEF_BT_BAUD_RATE,
CYBSP_BT_HOST_WAKE, CYBSP_BT_DEVICE_WAKE
);
return s_transport_driver;
}

#define CUSTOM_HCI_DRIVER

#endif
10 changes: 6 additions & 4 deletions src/utility/HCICordioTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#if defined(ARDUINO_ARCH_MBED) && !defined(TARGET_NANO_RP2040_CONNECT)

#if defined(ARDUINO_ARCH_MBED) && !defined(TARGET_NANO_RP2040_CONNECT) // && !defined(CORE_CM4)
#include <Arduino.h>
#include <mbed.h>

Expand Down Expand Up @@ -53,6 +52,8 @@
#define BLE_NAMESPACE ble::vendor::cordio
#endif

#include "CordioHCICustomDriver.h"

extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver();

namespace BLE_NAMESPACE {
Expand Down Expand Up @@ -181,7 +182,7 @@ HCICordioTransportClass::~HCICordioTransportClass()
{
}

#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
#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)
events::EventQueue eventQueue(10 * EVENTS_EVENT_SIZE);
void scheduleMbedBleEvents(BLE::OnEventsToProcessCallbackContext *context) {
eventQueue.call(mbed::Callback<void()>(&context->ble, &BLE::processEvents));
Expand All @@ -201,7 +202,8 @@ int HCICordioTransportClass::begin()
init_wsf(bufPoolDesc);
#endif

#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA)
#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)

BLE &ble = BLE::Instance();
ble.onEventsToProcess(scheduleMbedBleEvents);

Expand Down
4 changes: 3 additions & 1 deletion src/utility/HCIUartTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT)
#if !defined(ARDUINO_ARCH_MBED) && !defined(ESP32) && !defined(ARDUINO_UNOR4_WIFI) || defined(TARGET_NANO_RP2040_CONNECT) //|| defined(CORE_CM4)

#include "HCIUartTransport.h"

Expand All @@ -33,6 +33,8 @@
#define SerialHCI Serial3
#elif defined(ARDUINO_PORTENTA_C33)
#define SerialHCI Serial5
#elif defined(ARDUINO_GIGA)
arduino::UART SerialHCI(CYBSP_BT_UART_TX, CYBSP_BT_UART_RX, CYBSP_BT_UART_RTS, CYBSP_BT_UART_CTS);
#else
#error "Unsupported board selected!"
#endif
Expand Down

0 comments on commit de0bcbb

Please sign in to comment.