From c0cd781374c36bf1309529d09ad88c098fdbf45a Mon Sep 17 00:00:00 2001 From: Giampaolo Mancini Date: Thu, 24 Aug 2023 11:49:50 +0200 Subject: [PATCH] Add support for OPTA --- library.properties | 2 +- src/local/BLELocalDevice.cpp | 6 +++--- src/utility/HCICordioTransport.cpp | 6 +++--- src/utility/HCIUartTransport.cpp | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/library.properties b/library.properties index a08e251c..929fa0fd 100644 --- a/library.properties +++ b/library.properties @@ -6,5 +6,5 @@ sentence=Enables Bluetooth® Low Energy connectivity on the Arduino MKR WiFi 101 paragraph=This library supports creating a Bluetooth® Low Energy peripheral & central mode. category=Communication url=https://www.arduino.cc/en/Reference/ArduinoBLE -architectures=samd,megaavr,mbed,apollo3,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_giga,renesas,renesas_portenta +architectures=samd,megaavr,mbed,apollo3,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_giga,renesas,renesas_portenta,mbed_opta includes=ArduinoBLE.h diff --git a/src/local/BLELocalDevice.cpp b/src/local/BLELocalDevice.cpp index 79e43bf5..146d99b9 100644 --- a/src/local/BLELocalDevice.cpp +++ b/src/local/BLELocalDevice.cpp @@ -25,7 +25,7 @@ #include "BLELocalDevice.h" -#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) +#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA) #ifndef BT_REG_ON #define BT_REG_ON PJ_12 #endif @@ -69,7 +69,7 @@ int BLELocalDevice::begin() delay(100); digitalWrite(NINA_RESETN, HIGH); delay(750); -#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) +#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, HIGH); @@ -219,7 +219,7 @@ void BLELocalDevice::end() #elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT) // disable the NINA digitalWrite(NINA_RESETN, LOW); -#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) +#elif defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) digitalWrite(BT_REG_ON, LOW); #endif } diff --git a/src/utility/HCICordioTransport.cpp b/src/utility/HCICordioTransport.cpp index e78a44ea..947378cf 100644 --- a/src/utility/HCICordioTransport.cpp +++ b/src/utility/HCICordioTransport.cpp @@ -25,7 +25,7 @@ #include #include -#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) +#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) #include "ble/BLE.h" #include #endif @@ -181,7 +181,7 @@ HCICordioTransportClass::~HCICordioTransportClass() { } -#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) +#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) events::EventQueue eventQueue(10 * EVENTS_EVENT_SIZE); void scheduleMbedBleEvents(BLE::OnEventsToProcessCallbackContext *context) { eventQueue.call(mbed::Callback(&context->ble, &BLE::processEvents)); @@ -201,7 +201,7 @@ 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) +#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_GIGA) || defined(ARDUINO_OPTA) BLE &ble = BLE::Instance(); ble.onEventsToProcess(scheduleMbedBleEvents); diff --git a/src/utility/HCIUartTransport.cpp b/src/utility/HCIUartTransport.cpp index 1cd44495..3219268d 100644 --- a/src/utility/HCIUartTransport.cpp +++ b/src/utility/HCIUartTransport.cpp @@ -29,6 +29,8 @@ // SerialHCI is already defined in the variant #elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) #define SerialHCI Serial2 +#elif defined(ARDUINO_OPTA) +#define SerialHCI Serial3 #elif defined(ARDUINO_PORTENTA_C33) #define SerialHCI Serial5 #else