diff --git a/features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp b/features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp index 5d442d7..439001b 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 @@ { 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 @@ 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::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/hci_drv.h b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_drv.h new file mode 100644 index 0000000..6623cc1 --- /dev/null +++ b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_drv.h @@ -0,0 +1,114 @@ +/*************************************************************************************************/ +/*! + * \file hci_drv.h + * + * \brief HCI driver interface. + * + * $Date: 2013-01-02 22:19:17 -0800 (Wed, 02 Jan 2013) $ + * $Revision: 405 $ + * + * Copyright (c) 2012-2016 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: LicenseRef-PBL + * + * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the License at + * + * https://www.mbed.com/licenses/PBL-1.0 + * + * See the License for the specific language governing permissions and limitations under the License. + */ +/*************************************************************************************************/ +#ifndef HCI_DRV_H +#define HCI_DRV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "PinNames.h" + +/************************************************************************************************** + Function Declarations +**************************************************************************************************/ + +/*************************************************************************************************/ +/*! + * \fn hciDrvInit + * + * \brief Initialize the driver. + * + * \param csn name of the pin connected to CSN + * \param irq name of the pin conntected to IRQ + */ +/*************************************************************************************************/ +void hciDrvInit(PinName csn, PinName rst, PinName irq); + +/*************************************************************************************************/ +/*! + * \fn hciDrvWrite + * + * \brief Write data to the driver. + * + * \param type HCI packet type + * \param len Number of bytes to write. + * \param pData Byte array to write. + * + * \return Return actual number of data bytes written. + * + * \note The type parameter allows the driver layer to prepend the data with a header on the + * same write transaction. + */ +/*************************************************************************************************/ +uint16_t hciDrvWrite(uint8_t type, uint16_t len, uint8_t *pData); + +/*************************************************************************************************/ +/*! + * \fn hciDrvRead + * + * \brief Read data bytes from the driver. + * + * \param len Number of bytes to read. + * \param pData Byte array to store data. + * + * \return Return actual number of data bytes read. + */ +/*************************************************************************************************/ +uint16_t hciDrvRead(uint16_t len, uint8_t *pData, bool_t last); + +/*************************************************************************************************/ +/*! + * \fn hciDrvIsr + * + * \brief Interrupt service routine for IRQ + */ +/*************************************************************************************************/ +void hciDrvIsr(void); + +/*************************************************************************************************/ +/*! + * \fn hciDrvReadyToSleep + * + * \brief Returns TRUE if driver allows MCU to enter low power sleep mode. + * + * \return TRUE if ready to sleep, FALSE otherwise. + */ +/*************************************************************************************************/ +bool_t hciDrvReadyToSleep(void); + +void hciDrvResume(void); + +/*************************************************************************************************/ +/*! + * \fn hciDrvReset + * + * \brief Resets the controller + */ +/*************************************************************************************************/ +void hciDrvReset(void); + +#ifdef __cplusplus +}; +#endif + +#endif /* HCI_DRV_H */ diff --git a/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_vs.h b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_vs.h new file mode 100644 index 0000000..36abb15 --- /dev/null +++ b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/hci_vs.h @@ -0,0 +1,59 @@ +/*************************************************************************************************/ +/*! + * \file hci_drv.h + * + * \brief HCI vendor specific functions for EM Microelectronic. + * + * $Date: 2013-01-02 22:19:17 -0800 (Wed, 02 Jan 2013) $ + * $Revision: 405 $ + * + * Copyright (c) 2012-2016 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: LicenseRef-PBL + * + * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the License at + * + * https://www.mbed.com/licenses/PBL-1.0 + * + * See the License for the specific language governing permissions and limitations under the License. + */ +/*************************************************************************************************/ +#ifndef HCI_VS_H +#define HCI_VS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************************************************/ +/*! + * \fn HciVsSetPublicAddr + * + * \brief Vendor-specific set public address function. + * + * \param param public address + * + * \return None. + */ +/*************************************************************************************************/ +void HciVsSetPublicAddr(uint8_t *bdAddr); + +/*************************************************************************************************/ +/*! + * \fn HciVsSetTxPower + * + * \brief Vendor-specific set RF output power function + * + * \param param output power in dB + * + * \return None. + */ +/*************************************************************************************************/ +void HciVsSetTxPower(int txPower); + +#ifdef __cplusplus +}; +#endif + +#endif /* HCI_VS_H */ diff --git a/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_drv.h b/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_drv.h deleted file mode 100644 index 6623cc1..0000000 --- a/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_drv.h +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************************************/ -/*! - * \file hci_drv.h - * - * \brief HCI driver interface. - * - * $Date: 2013-01-02 22:19:17 -0800 (Wed, 02 Jan 2013) $ - * $Revision: 405 $ - * - * Copyright (c) 2012-2016 ARM Limited. All rights reserved. - * - * SPDX-License-Identifier: LicenseRef-PBL - * - * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the License at - * - * https://www.mbed.com/licenses/PBL-1.0 - * - * See the License for the specific language governing permissions and limitations under the License. - */ -/*************************************************************************************************/ -#ifndef HCI_DRV_H -#define HCI_DRV_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "PinNames.h" - -/************************************************************************************************** - Function Declarations -**************************************************************************************************/ - -/*************************************************************************************************/ -/*! - * \fn hciDrvInit - * - * \brief Initialize the driver. - * - * \param csn name of the pin connected to CSN - * \param irq name of the pin conntected to IRQ - */ -/*************************************************************************************************/ -void hciDrvInit(PinName csn, PinName rst, PinName irq); - -/*************************************************************************************************/ -/*! - * \fn hciDrvWrite - * - * \brief Write data to the driver. - * - * \param type HCI packet type - * \param len Number of bytes to write. - * \param pData Byte array to write. - * - * \return Return actual number of data bytes written. - * - * \note The type parameter allows the driver layer to prepend the data with a header on the - * same write transaction. - */ -/*************************************************************************************************/ -uint16_t hciDrvWrite(uint8_t type, uint16_t len, uint8_t *pData); - -/*************************************************************************************************/ -/*! - * \fn hciDrvRead - * - * \brief Read data bytes from the driver. - * - * \param len Number of bytes to read. - * \param pData Byte array to store data. - * - * \return Return actual number of data bytes read. - */ -/*************************************************************************************************/ -uint16_t hciDrvRead(uint16_t len, uint8_t *pData, bool_t last); - -/*************************************************************************************************/ -/*! - * \fn hciDrvIsr - * - * \brief Interrupt service routine for IRQ - */ -/*************************************************************************************************/ -void hciDrvIsr(void); - -/*************************************************************************************************/ -/*! - * \fn hciDrvReadyToSleep - * - * \brief Returns TRUE if driver allows MCU to enter low power sleep mode. - * - * \return TRUE if ready to sleep, FALSE otherwise. - */ -/*************************************************************************************************/ -bool_t hciDrvReadyToSleep(void); - -void hciDrvResume(void); - -/*************************************************************************************************/ -/*! - * \fn hciDrvReset - * - * \brief Resets the controller - */ -/*************************************************************************************************/ -void hciDrvReset(void); - -#ifdef __cplusplus -}; -#endif - -#endif /* 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/maxwsn/hci_vs.h deleted file mode 100644 index 36abb15..0000000 --- a/features/FEATURE_BLE/targets/TARGET_Maxim/exactLE/hci/maxwsn/hci_vs.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************************************/ -/*! - * \file hci_drv.h - * - * \brief HCI vendor specific functions for EM Microelectronic. - * - * $Date: 2013-01-02 22:19:17 -0800 (Wed, 02 Jan 2013) $ - * $Revision: 405 $ - * - * Copyright (c) 2012-2016 ARM Limited. All rights reserved. - * - * SPDX-License-Identifier: LicenseRef-PBL - * - * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the License at - * - * https://www.mbed.com/licenses/PBL-1.0 - * - * See the License for the specific language governing permissions and limitations under the License. - */ -/*************************************************************************************************/ -#ifndef HCI_VS_H -#define HCI_VS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*************************************************************************************************/ -/*! - * \fn HciVsSetPublicAddr - * - * \brief Vendor-specific set public address function. - * - * \param param public address - * - * \return None. - */ -/*************************************************************************************************/ -void HciVsSetPublicAddr(uint8_t *bdAddr); - -/*************************************************************************************************/ -/*! - * \fn HciVsSetTxPower - * - * \brief Vendor-specific set RF output power function - * - * \param param output power in dB - * - * \return None. - */ -/*************************************************************************************************/ -void HciVsSetTxPower(int txPower); - -#ifdef __cplusplus -}; -#endif - -#endif /* 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 3df62ab..697a33c 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_ARM_STD/libexactLE.ar +++ b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_ARM_STD/libexactLE.ar Binary files 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 7ac5141..f0cd46a 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_GCC_ARM/libexactLE.a +++ b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_GCC_ARM/libexactLE.a Binary files differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a index 7079471..5693303 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a +++ b/targets/TARGET_Maxim/TARGET_MAX32610/TOOLCHAIN_IAR/libexactLE.a Binary files 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 f05e395..ee46578 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_ARM_STD/libexactLE.ar +++ b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_ARM_STD/libexactLE.ar Binary files 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 ecc6df5..5bdf647 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_GCC_ARM/libexactLE.a +++ b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_GCC_ARM/libexactLE.a Binary files differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a index e4728cc..0505739 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a +++ b/targets/TARGET_Maxim/TARGET_MAX32620/TOOLCHAIN_IAR/libexactLE.a Binary files differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c b/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c index 2d531e3..35c3d72 100644 --- a/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c +++ b/targets/TARGET_Maxim/TARGET_MAX32620/sleep.c @@ -115,7 +115,7 @@ // Deep Sleep is not working properly on Revisions A3 and earlier if (part_rev <= REVISION_A3) { - sleep(); + hal_sleep(); return; } @@ -128,7 +128,7 @@ // 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 1b57195..adb5c9d 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 @@ 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 0000000..e27f50d --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_ARM_STD/libexactLE.ar Binary files 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 0000000..c61dae9 --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_GCC_ARM/libexactLE.a Binary files 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 0000000..2626cf0 --- /dev/null +++ b/targets/TARGET_Maxim/TARGET_MAX32630/TOOLCHAIN_IAR/libexactLE.a Binary files differ diff --git a/targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c b/targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c index 2b5bb5e..c59a879 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_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 2dd940b..f0de60f 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -2060,10 +2060,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": {