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

0 commit comments

Comments
 (0)