Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dc6398a
Check for mbed 5 support on export
theotherjimmy Aug 23, 2017
bce900d
Fix cellular APN_db.h lookup.
RobMeades Sep 4, 2017
58c9f4b
STM32 USBDevice: refactor files
bcostm Aug 24, 2017
211d201
STM32 USBDevice: add more supported targets
bcostm Aug 25, 2017
1d72b31
STM32 USBDevice: Remove disco-f429zi, clean-up nucleo-f103rb
bcostm Aug 28, 2017
e588011
STM32 USBDevice: Add USB_STM_HAL macro for disco-f469ni
bcostm Aug 28, 2017
9e3b509
STM32 USBDevice: Add NUCLEO_F446RE target
bcostm Aug 28, 2017
8f4b6e2
STM32 USBDevice: Add DISCO_F407VG target
bcostm Aug 28, 2017
52f8481
mts targets: fix debug() usage
0xc0170 Sep 6, 2017
f766f7d
Release deep sleep lock in destructor of Timer class
c1728p9 Sep 14, 2017
5a6aee4
PWMOut: lock deesleep addition
0xc0170 Sep 22, 2017
593fb3a
K66F: Update to SDK 2.2
mmahadevan108 Aug 25, 2017
d9a8c63
K66F: Use DSPI SDK driver API's in spi block read
mmahadevan108 Aug 25, 2017
c328902
Fix LPC54114 vector table size
c1728p9 Sep 25, 2017
c58d7de
BLE: Fix GattClient destructor by adding a virtual specifier.
pan- Sep 8, 2017
dd303b7
BLE: Add ArrayView in utilities.
pan- Sep 8, 2017
c022c4a
BLE: use common type ble::connection_handle_t as Handle_t.
pan- Sep 8, 2017
97995b8
BLE: Fix header inclusion of DiscoveredCharacteristicDescriptor.
pan- Sep 8, 2017
4416ef6
BLE: Add optionnal error_code CharacteristicDescriptorDiscovery::Term…
pan- Sep 8, 2017
1fd953e
BLE: Use shared type ble_attribute_handle_t in GattAttribute.
pan- Sep 8, 2017
85e88cc
BLE NRF: Fix wrong usage of designed initializer in cpp code.
pan- Sep 8, 2017
38bb6b4
BLE: Add error code management in Gatt read and write data structures.
pan- Sep 8, 2017
daaa5b1
BLE: Introduce GenericGattClient and platform abstraction over ATT/GATT.
pan- Sep 8, 2017
512dd8c
BLE: Add collection of basic BLE types shared accross all layers.
pan- Sep 8, 2017
aa0b5d5
BLE: Fix space
pan- Sep 8, 2017
75c9dfc
BLE: Add Cordio port.
pan- Sep 8, 2017
ecebb72
Merging changes from ATParser towards parser unification
Sep 26, 2017
4f1cafd
Merge pull request #5197 from c1728p9/fix_lpc54114
theotherjimmy Sep 27, 2017
6cecd09
Merge pull request #4961 from theotherjimmy/check-rtos-export
theotherjimmy Sep 27, 2017
b562e4e
Merge pull request #4979 from bcostm/usbdevice_clean-up
theotherjimmy Sep 27, 2017
760fc33
Merge pull request #4982 from NXPmicro/Update_K66_SDK22
theotherjimmy Sep 27, 2017
908a05b
Merge pull request #5016 from u-blox/apndb_fix
theotherjimmy Sep 27, 2017
c24fed1
Merge pull request #5032 from 0xc0170/fix_mts_debug
theotherjimmy Sep 27, 2017
fb5241c
Merge pull request #5060 from pan-/cordio_port
theotherjimmy Sep 27, 2017
8508d26
Merge pull request #5095 from c1728p9/timer_sleep_lock_fix
theotherjimmy Sep 27, 2017
ddb6b66
Merge pull request #5177 from 0xc0170/fix_pwmout_sleep
theotherjimmy Sep 27, 2017
0b70eba
Merging changes from ATParser towards parser unification
Sep 26, 2017
18b49b8
Merge branch 'sen_ATCmdParserChanges' of https://github.com/SenRamakr…
SenRamakri Sep 27, 2017
5b59b7f
Merging changes from ATParser towards parser unification
SenRamakri Sep 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion drivers/PwmOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#if defined (DEVICE_PWMOUT) || defined(DOXYGEN_ONLY)
#include "hal/pwmout_api.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_sleep.h"

namespace mbed {
/** \addtogroup drivers */
Expand Down Expand Up @@ -56,12 +57,18 @@ class PwmOut {
*
* @param pin PwmOut pin to connect to
*/
PwmOut(PinName pin) {
PwmOut(PinName pin) : _deep_sleep_locked(false) {
core_util_critical_section_enter();
pwmout_init(&_pwm, pin);
core_util_critical_section_exit();
}

~PwmOut() {
core_util_critical_section_enter();
unlock_deep_sleep();
core_util_critical_section_exit();
}

/** Set the ouput duty-cycle, specified as a percentage (float)
*
* @param value A floating-point value representing the output duty-cycle,
Expand All @@ -71,6 +78,7 @@ class PwmOut {
*/
void write(float value) {
core_util_critical_section_enter();
lock_deep_sleep();
pwmout_write(&_pwm, value);
core_util_critical_section_exit();
}
Expand Down Expand Up @@ -177,7 +185,24 @@ class PwmOut {
}

protected:
/** Lock deep sleep only if it is not yet locked */
void lock_deep_sleep() {
if (_deep_sleep_locked == false) {
sleep_manager_lock_deep_sleep();
_deep_sleep_locked = true;
}
}

/** Unlock deep sleep in case it is locked */
void unlock_deep_sleep() {
if (_deep_sleep_locked == true) {
sleep_manager_unlock_deep_sleep();
_deep_sleep_locked = false;
}
}

pwmout_t _pwm;
bool _deep_sleep_locked;
};

} // namespace mbed
Expand Down
9 changes: 9 additions & 0 deletions drivers/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker
reset();
}

Timer::~Timer() {
core_util_critical_section_enter();
if (_running) {
sleep_manager_unlock_deep_sleep();
}
_running = 0;
core_util_critical_section_exit();
}

void Timer::start() {
core_util_critical_section_enter();
if (!_running) {
Expand Down
1 change: 1 addition & 0 deletions drivers/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Timer : private NonCopyable<Timer> {
public:
Timer();
Timer(const ticker_data_t *data);
~Timer();

/** Start the timer
*/
Expand Down
165 changes: 165 additions & 0 deletions features/FEATURE_BLE/ble/ArrayView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BLE_ARRAY_VIEW_H_
#define BLE_ARRAY_VIEW_H_

#include <stddef.h>
#include <stdint.h>

namespace ble {

/**
* Immutable view to an array.
*/
template<typename T>
struct ArrayView {

/**
* construct an array view to an empty array
*/
ArrayView() : _array(0), _size(0) { }

/**
* construct an array view from a pointer.
* and its size.
*/
ArrayView(T* array_ptr, size_t array_size) :
_array(array_ptr), _size(array_size) { }

/**
* Construct an array view from the reference to an array.
*/
template<size_t Size>
ArrayView(T (&elements)[Size]):
_array(elements), _size(Size) { }

/**
* Return the size of the array viewed.
*/
size_t size() const {
return _size;
}

/**
* Access to a mutable element of the array.
*/
T& operator[](size_t index) {
return _array[index];
}

/**
* Access to an immutable element of the array.
*/
const T& operator[](size_t index) const {
return _array[index];
}

/**
* Get the pointer to the array
*/
T* data() {
return _array;
}

/**
* Get the pointer to the const array
*/
const T* data() const {
return _array;
}

/**
* Equality operator
*/
friend bool operator==(const ArrayView& lhs, const ArrayView& rhs) {
if (lhs.size() != rhs.size()) {
return false;
}

if (lhs.data() == rhs.data()) {
return true;
}

return memcmp(lhs.data(), rhs.data(), lhs.size()) == 0;
}

/**
* Not equal operator
*/
friend bool operator!=(const ArrayView& lhs, const ArrayView& rhs) {
return !(lhs == rhs);
}

private:
T* const _array;
const size_t _size;
};


/**
* Generate an array view from a C/C++ array.
* This helper avoid the typing of template parameter when ArrayView are
* created 'inline'.
* @param elements The array viewed.
* @return The array_view to elements.
*/
template<typename T, size_t Size>
ArrayView<T> make_ArrayView(T (&elements)[Size]) {
return ArrayView<T>(elements);
}

/**
* Generate an array view from a C/C++ pointer and the size of the array.
* This helper avoid the typing of template parameter when ArrayView are
* created 'inline'.
* @param array_ptr The pointer to the array to view.
* @param array_size The size of the array.
* @return The array_view to array_ptr with a size of array_size.
*/
template<typename T>
ArrayView<T> make_ArrayView(T* array_ptr, size_t array_size) {
return ArrayView<T>(array_ptr, array_size);
}

/**
* Generate a const array view from a C/C++ array.
* This helper avoid the typing of template parameter when ArrayView are
* created 'inline'.
* @param elements The array viewed.
* @return The ArrayView to elements.
*/
template<typename T, size_t Size>
ArrayView<const T> make_const_ArrayView(T (&elements)[Size]) {
return ArrayView<const T>(elements);
}

/**
* Generate a const array view from a C/C++ pointer and the size of the array.
* This helper avoid the typing of template parameter when ArrayView are
* created 'inline'.
* @param array_ptr The pointer to the array to view.
* @param array_size The size of the array.
* @return The ArrayView to array_ptr with a size of array_size.
*/
template<typename T>
ArrayView<const T> make_const_ArrayView(T* array_ptr, size_t array_size) {
return ArrayView<const T>(array_ptr, array_size);
}

} // namespace ble

#endif /* BLE_ARRAY_VIEW_H_ */
77 changes: 77 additions & 0 deletions features/FEATURE_BLE/ble/BLETypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BLE_TYPES_H_
#define BLE_TYPES_H_

#include <stddef.h>
#include <stdint.h>

namespace ble {

/**
* A connection handle is an unsigned integer capable of holding a pointer.
* The real type (either a pointer to an object or an integer) is opaque and
* platform dependent.
*/
typedef uintptr_t connection_handle_t;

/**
* Model an attribute handle in a GATT database.
*/
typedef uint16_t attribute_handle_t;


/**
* Model an inclusive range of GATT attributes handles.
*/
struct attribute_handle_range_t {
attribute_handle_t begin;
attribute_handle_t end;

friend bool operator==(
const attribute_handle_range_t& lhs, const attribute_handle_range_t& rhs
) {
return (lhs.begin == rhs.begin) && (lhs.end == rhs.end);
}

friend bool operator!=(
const attribute_handle_range_t& lhs, const attribute_handle_range_t& rhs
) {
return !(lhs == rhs);
}
};


/**
* Construct an attribute_handle_range_t from its start and end handle.
* @note This function is defined instead of a constructor to keep "POD-ness"
* of attribute_handle_range_t.
*/
static inline attribute_handle_range_t attribute_handle_range(
attribute_handle_t begin,
attribute_handle_t end
) {
attribute_handle_range_t result = {
begin,
end
};
return result;
}

} // namespace ble

#endif /* BLE_TYPES_H_ */
5 changes: 5 additions & 0 deletions features/FEATURE_BLE/ble/CharacteristicDescriptorDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class CharacteristicDescriptorDiscovery {
* status of the discovery operation
*/
ble_error_t status;

/**
* error code associated with the status if any.
*/
uint8_t error_code;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion features/FEATURE_BLE/ble/DiscoveredCharacteristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "GattAttribute.h"
#include "GattClient.h"
#include "CharacteristicDescriptorDiscovery.h"
#include "ble/DiscoveredCharacteristicDescriptor.h"
#include "DiscoveredCharacteristicDescriptor.h"

/**
* @brief Representation of a characteristic discovered during a GattClient
Expand Down
3 changes: 2 additions & 1 deletion features/FEATURE_BLE/ble/Gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef __GAP_H__
#define __GAP_H__

#include "BLETypes.h"
#include "ble/BLEProtocol.h"
#include "GapAdvertisingData.h"
#include "GapAdvertisingParams.h"
Expand Down Expand Up @@ -171,7 +172,7 @@ class Gap {
/**
* Type for connection handle.
*/
typedef uint16_t Handle_t;
typedef ble::connection_handle_t Handle_t;

/**
* Structure containing GAP connection parameters. When in peripheral role
Expand Down
3 changes: 2 additions & 1 deletion features/FEATURE_BLE/ble/GattAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define __GATT_ATTRIBUTE_H__

#include "UUID.h"
#include "BLETypes.h"

/**
* Instances of this class encapsulate the data that belongs to a Bluetooth Low
Expand All @@ -29,7 +30,7 @@ class GattAttribute {
* Type for the handle or ID of the attribute in the ATT table. These are
* unique and are usually generated by the underlying BLE stack.
*/
typedef uint16_t Handle_t;
typedef ble::attribute_handle_t Handle_t;
/**
* Define the value of an invalid attribute handle.
*/
Expand Down
Loading