Update BLE, fix sleep and open-drain LEDs in MAX326xx

MAX32630FTHR gets BLE, uses timer peripheral 5 for HCI timing
libexactLE update for 610,620
Fixup hal_sleep and hal_deepsleep for 620
LEDn outputs now forced to open-drain
pull/4398/head
Jesse Marroquin 2017-06-13 19:26:03 -05:00
parent 692d9055b1
commit 3a4138369d
16 changed files with 58 additions and 11 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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,

View File

@ -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);
}

View File

@ -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": {