diff --git a/features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp b/features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp index 5d442d70c3..439001b79c 100644 --- a/features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp +++ b/features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -52,10 +52,10 @@ #include "hci_vs.h" /* Number of WSF buffer pools */ -#define WSF_BUF_POOLS 4 +#define WSF_BUF_POOLS 5 /*! Free memory for pool buffers. */ -static uint8_t mainBufMem[768]; +static uint8_t mainBufMem[1040]; /*! Default pool descriptor. */ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = @@ -63,24 +63,52 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = { 16, 8 }, { 32, 4 }, { 64, 2 }, - { 128, 2 } + { 128, 2 }, + { 272, 1 } }; +/* Store the Event signalling */ +bool isEventsSignaled = false; + /*! WSF handler ID */ wsfHandlerId_t maximHandlerId; static volatile int reset_complete; +#ifdef BLE_HCI_UART +static DigitalIn _rts(BT_CTS); +static DigitalIn _cts(BT_RTS); +static DigitalIn _clk(BT_CLK); +static DigitalOut _shutdown(BT_RST, 0); +static Serial _uart(BT_TX, BT_RX, 115200); +#else /* Current mbed SPI API does not support HW slave selects. Configured in HCI driver. */ static DigitalOut _csn(HCI_CSN, 1); static SPI _spi(HCI_MOSI, HCI_MISO, HCI_SCK, HCI_CSN); static DigitalOut _rst(HCI_RST, 0); static InterruptIn _irq(HCI_IRQ); +#endif /** * The singleton which represents the MaximBLE transport for the BLE. */ static MaximBLE deviceInstance; +extern "C" { + +/* + * This function will signal to the user code by calling signalEventsToProcess. + * It is registered and called into the Wsf Stack. + */ +void wsf_mbed_ble_signal_event(void) +{ + if (isEventsSignaled == false) { + isEventsSignaled = true; + deviceInstance.signalEventsToProcess(::BLE::DEFAULT_INSTANCE); + } +} + +} + /** * BLE-API requires an implementation of the following function in order to * obtain its transport handle. @@ -240,16 +268,20 @@ ble_error_t MaximBLE::init(BLE::InstanceID_t instanceID, FunctionPointerWithCont maximHandlerId = WsfOsSetNextHandler(maximHandler); /* init HCI */ +#ifdef BLE_HCI_UART + hciDrvInit(BT_TX, BT_RST, BT_CLK); +#else _irq.disable_irq(); _irq.rise(hciDrvIsr); _irq.fall(NULL); hciDrvInit(HCI_CSN, HCI_RST, HCI_IRQ); +#endif /* Register for stack callbacks */ DmRegister(DmCback); DmConnRegister(DM_CLIENT_ID_APP, DmCback); AttConnRegister(AppServerConnCback); - + /* Reset the device */ reset_complete = 0; DmDevReset(); @@ -301,12 +333,15 @@ void MaximBLE::waitForEvent(void) void MaximBLE::processEvents() { - callDispatcher(); + if (isEventsSignaled) { + isEventsSignaled = false; + callDispatcher(); + } } void MaximBLE::timeoutCallback(void) { - // do nothing. just an interrupt for wake up. + wsf_mbed_ble_signal_event(); } void MaximBLE::callDispatcher(void) diff --git a/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_drv.h b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_drv.h similarity index 100% rename from features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_drv.h rename to features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_drv.h diff --git a/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_vs.h b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_vs.h similarity index 100% rename from features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_vs.h rename to features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_vs.h diff --git a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_ARM_STD/libexactLE.ar b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_ARM_STD/libexactLE.ar index 3df62abfba..697a33c2f1 100644 Binary files a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_ARM_STD/libexactLE.ar and b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_ARM_STD/libexactLE.ar differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_GCC_ARM/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_GCC_ARM/libexactLE.a index 7ac5141b89..f0cd46aff5 100644 Binary files a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_GCC_ARM/libexactLE.a and b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_GCC_ARM/libexactLE.a differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a index 707947146e..56933038c6 100644 Binary files a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a and b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_ARM_STD/libexactLE.ar b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_ARM_STD/libexactLE.ar index f05e395dfd..ee465787e0 100644 Binary files a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_ARM_STD/libexactLE.ar and b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_ARM_STD/libexactLE.ar differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_GCC_ARM/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_GCC_ARM/libexactLE.a index ecc6df531e..5bdf6476c7 100644 Binary files a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_GCC_ARM/libexactLE.a and b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_GCC_ARM/libexactLE.a differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a index e4728cce3a..050573918a 100644 Binary files a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a and b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c b/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c index 2d531e35f6..35c3d72936 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c +++ b/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c @@ -115,7 +115,7 @@ void hal_deepsleep(void) // Deep Sleep is not working properly on Revisions A3 and earlier if (part_rev <= REVISION_A3) { - sleep(); + hal_sleep(); return; } @@ -128,7 +128,7 @@ void hal_deepsleep(void) // Do not enter Deep Sleep if connected to VBUS if (MXC_USB->dev_intfl & MXC_F_USB_DEV_INTFL_VBUS_ST) { __enable_irq(); - sleep(); + hal_sleep(); return; } diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/TARGET_MAX32630FTHR/PinNames.h b/targets/TARGET_Maxim/TARGET_MAX32630/TARGET_MAX32630FTHR/PinNames.h index 1b5719533a..adb5c9dac1 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32630/TARGET_MAX32630FTHR/PinNames.h +++ b/targets/TARGET_Maxim/TARGET_MAX32630/TARGET_MAX32630FTHR/PinNames.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + * Copyright (C) 2016-2017 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -144,6 +144,10 @@ typedef enum { OWM = P4_0, // BTLE Module hardwired + BT_TX = P0_0, + BT_RX = P0_1, + BT_RTS = P0_2, + BT_CTS = P0_3, BT_RST = P1_6, BT_CLK = P1_7, diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_ARM_STD/libexactLE.ar b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_ARM_STD/libexactLE.ar new file mode 100644 index 0000000000..e27f50d955 Binary files /dev/null and b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_ARM_STD/libexactLE.ar differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_GCC_ARM/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_GCC_ARM/libexactLE.a new file mode 100644 index 0000000000..c61dae9aa2 Binary files /dev/null and b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_GCC_ARM/libexactLE.a differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_IAR/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_IAR/libexactLE.a new file mode 100644 index 0000000000..2626cf0774 Binary files /dev/null and b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_IAR/libexactLE.a differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c b/targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c index 2b5bb5e41b..c59a879a2b 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c +++ b/targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c @@ -67,6 +67,13 @@ void gpio_init(gpio_t *obj, PinName name) void gpio_mode(gpio_t *obj, PinMode mode) { +#ifdef OPEN_DRAIN_LEDS + if ((obj->name == LED1) || (obj->name == LED2) || + (obj->name == LED3) || (obj->name == LED4)) { + mode = OpenDrain; + } +#endif + obj->mode = mode; pin_mode(obj->name, mode); } diff --git a/targets/targets.json b/targets/targets.json index bfb9455de3..b6b1d8b22e 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -2304,10 +2304,11 @@ "MAX32630FTHR": { "inherits": ["Target"], "core": "Cortex-M4F", - "macros": ["__SYSTEM_HFX=96000000", "TARGET=MAX32630", "TARGET_REV=0x4132"], + "macros": ["__SYSTEM_HFX=96000000", "TARGET=MAX32630", "TARGET_REV=0x4132", "BLE_HCI_UART", "OPEN_DRAIN_LEDS"], "extra_labels": ["Maxim", "MAX32630"], "supported_toolchains": ["GCC_ARM", "IAR", "ARM"], "device_has": ["ANALOGIN", "ERROR_RED", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "STDIO_MESSAGES"], + "features": ["BLE"], "release_versions": ["2", "5"] }, "EFM32": {