Skip to content

Commit 66c3385

Browse files
Merge pull request #4398 from maximmbed/max326xx_ble_update
MAX326xx: BLE updates, fixed sleep, open-drain LEDs
2 parents f08d5a4 + 3a41383 commit 66c3385

File tree

16 files changed

+58
-11
lines changed

16 files changed

+58
-11
lines changed

features/FEATURE_BLE/targets/TARGET_Maxim/MaximBLE.cpp

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
2+
* Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -52,35 +52,63 @@
5252
#include "hci_vs.h"
5353

5454
/* Number of WSF buffer pools */
55-
#define WSF_BUF_POOLS 4
55+
#define WSF_BUF_POOLS 5
5656

5757
/*! Free memory for pool buffers. */
58-
static uint8_t mainBufMem[768];
58+
static uint8_t mainBufMem[1040];
5959

6060
/*! Default pool descriptor. */
6161
static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
6262
{
6363
{ 16, 8 },
6464
{ 32, 4 },
6565
{ 64, 2 },
66-
{ 128, 2 }
66+
{ 128, 2 },
67+
{ 272, 1 }
6768
};
6869

70+
/* Store the Event signalling */
71+
bool isEventsSignaled = false;
72+
6973
/*! WSF handler ID */
7074
wsfHandlerId_t maximHandlerId;
7175
static volatile int reset_complete;
7276

77+
#ifdef BLE_HCI_UART
78+
static DigitalIn _rts(BT_CTS);
79+
static DigitalIn _cts(BT_RTS);
80+
static DigitalIn _clk(BT_CLK);
81+
static DigitalOut _shutdown(BT_RST, 0);
82+
static Serial _uart(BT_TX, BT_RX, 115200);
83+
#else
7384
/* Current mbed SPI API does not support HW slave selects. Configured in HCI driver. */
7485
static DigitalOut _csn(HCI_CSN, 1);
7586
static SPI _spi(HCI_MOSI, HCI_MISO, HCI_SCK, HCI_CSN);
7687
static DigitalOut _rst(HCI_RST, 0);
7788
static InterruptIn _irq(HCI_IRQ);
89+
#endif
7890

7991
/**
8092
* The singleton which represents the MaximBLE transport for the BLE.
8193
*/
8294
static MaximBLE deviceInstance;
8395

96+
extern "C" {
97+
98+
/*
99+
* This function will signal to the user code by calling signalEventsToProcess.
100+
* It is registered and called into the Wsf Stack.
101+
*/
102+
void wsf_mbed_ble_signal_event(void)
103+
{
104+
if (isEventsSignaled == false) {
105+
isEventsSignaled = true;
106+
deviceInstance.signalEventsToProcess(::BLE::DEFAULT_INSTANCE);
107+
}
108+
}
109+
110+
}
111+
84112
/**
85113
* BLE-API requires an implementation of the following function in order to
86114
* obtain its transport handle.
@@ -240,16 +268,20 @@ ble_error_t MaximBLE::init(BLE::InstanceID_t instanceID, FunctionPointerWithCont
240268
maximHandlerId = WsfOsSetNextHandler(maximHandler);
241269

242270
/* init HCI */
271+
#ifdef BLE_HCI_UART
272+
hciDrvInit(BT_TX, BT_RST, BT_CLK);
273+
#else
243274
_irq.disable_irq();
244275
_irq.rise(hciDrvIsr);
245276
_irq.fall(NULL);
246277
hciDrvInit(HCI_CSN, HCI_RST, HCI_IRQ);
278+
#endif
247279

248280
/* Register for stack callbacks */
249281
DmRegister(DmCback);
250282
DmConnRegister(DM_CLIENT_ID_APP, DmCback);
251283
AttConnRegister(AppServerConnCback);
252-
284+
253285
/* Reset the device */
254286
reset_complete = 0;
255287
DmDevReset();
@@ -301,12 +333,15 @@ void MaximBLE::waitForEvent(void)
301333

302334
void MaximBLE::processEvents()
303335
{
304-
callDispatcher();
336+
if (isEventsSignaled) {
337+
isEventsSignaled = false;
338+
callDispatcher();
339+
}
305340
}
306341

307342
void MaximBLE::timeoutCallback(void)
308343
{
309-
// do nothing. just an interrupt for wake up.
344+
wsf_mbed_ble_signal_event();
310345
}
311346

312347
void MaximBLE::callDispatcher(void)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

targets/TARGET_Maxim/TARGET_MAX32620/sleep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void hal_deepsleep(void)
115115

116116
// Deep Sleep is not working properly on Revisions A3 and earlier
117117
if (part_rev <= REVISION_A3) {
118-
sleep();
118+
hal_sleep();
119119
return;
120120
}
121121

@@ -128,7 +128,7 @@ void hal_deepsleep(void)
128128
// Do not enter Deep Sleep if connected to VBUS
129129
if (MXC_USB->dev_intfl & MXC_F_USB_DEV_INTFL_VBUS_ST) {
130130
__enable_irq();
131-
sleep();
131+
hal_sleep();
132132
return;
133133
}
134134

targets/TARGET_Maxim/TARGET_MAX32630/TARGET_MAX32630FTHR/PinNames.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
2+
* Copyright (C) 2016-2017 Maxim Integrated Products, Inc., All Rights Reserved.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -144,6 +144,10 @@ typedef enum {
144144
OWM = P4_0,
145145

146146
// BTLE Module hardwired
147+
BT_TX = P0_0,
148+
BT_RX = P0_1,
149+
BT_RTS = P0_2,
150+
BT_CTS = P0_3,
147151
BT_RST = P1_6,
148152
BT_CLK = P1_7,
149153

Binary file not shown.
Binary file not shown.
Binary file not shown.

targets/TARGET_Maxim/TARGET_MAX32630/gpio_api.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ void gpio_init(gpio_t *obj, PinName name)
6767

6868
void gpio_mode(gpio_t *obj, PinMode mode)
6969
{
70+
#ifdef OPEN_DRAIN_LEDS
71+
if ((obj->name == LED1) || (obj->name == LED2) ||
72+
(obj->name == LED3) || (obj->name == LED4)) {
73+
mode = OpenDrain;
74+
}
75+
#endif
76+
7077
obj->mode = mode;
7178
pin_mode(obj->name, mode);
7279
}

targets/targets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,10 +2304,11 @@
23042304
"MAX32630FTHR": {
23052305
"inherits": ["Target"],
23062306
"core": "Cortex-M4F",
2307-
"macros": ["__SYSTEM_HFX=96000000", "TARGET=MAX32630", "TARGET_REV=0x4132"],
2307+
"macros": ["__SYSTEM_HFX=96000000", "TARGET=MAX32630", "TARGET_REV=0x4132", "BLE_HCI_UART", "OPEN_DRAIN_LEDS"],
23082308
"extra_labels": ["Maxim", "MAX32630"],
23092309
"supported_toolchains": ["GCC_ARM", "IAR", "ARM"],
23102310
"device_has": ["ANALOGIN", "ERROR_RED", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "STDIO_MESSAGES"],
2311+
"features": ["BLE"],
23112312
"release_versions": ["2", "5"]
23122313
},
23132314
"EFM32": {

0 commit comments

Comments
 (0)