Skip to content

Commit a639a5c

Browse files
committed
Merge branch latest 'master' into dev_target_k64f
Conflicts: libraries/rtos/rtx/RTX_Conf_CM.c workspace_tools/build_api.py
2 parents 67a2c2a + f3de345 commit a639a5c

File tree

607 files changed

+248608
-2114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

607 files changed

+248608
-2114
lines changed

libraries/USBDevice/USBHID/USBHID.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ bool USBHID::readNB(HID_REPORT *report)
5959
uint32_t bytesRead = 0;
6060
bool result;
6161
result = USBDevice::readEP_NB(EPINT_OUT, report->data, &bytesRead, MAX_HID_REPORT_SIZE);
62+
// if readEP_NB did not succeed, does not issue a readStart
63+
if (!result)
64+
return false;
6265
report->length = bytesRead;
6366
if(!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE))
6467
return false;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GattServer
3838
/* These functions must be defined in the sub-class */
3939
virtual ble_error_t addService(GattService &) = 0;
4040
virtual ble_error_t readValue(uint16_t, uint8_t[], uint16_t) = 0;
41-
virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t) = 0;
41+
virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false) = 0;
4242

4343
// ToDo: For updateValue, check the CCCD to see if the value we are
4444
// updating has the notify or indicate bits sent, and if BOTH are set
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#include "pstorage.h"
3434

3535
#include "hw/GapEvents.h"
36-
#include "hw/nRF51822n/nRF51Gap.h"
37-
#include "hw/nRF51822n/nRF51GattServer.h"
36+
#include "nRF51Gap.h"
37+
#include "nRF51GattServer.h"
3838

3939
static void service_error_callback(uint32_t nrf_error);
4040
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include "mbed.h"
2626
#include "blecommon.h"
2727
#include "hw/BLEDevice.h"
28-
#include "hw/nRF51822n/nRF51Gap.h"
29-
#include "hw/nRF51822n/nRF51GattServer.h"
28+
#include "nRF51Gap.h"
29+
#include "nRF51GattServer.h"
3030

3131
/**************************************************************************/
3232
/*!
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ ble_error_t nRF51Gap::startAdvertising(GapAdvertisingParams & params)
162162
return BLE_ERROR_PARAM_OUT_OF_RANGE;
163163
}
164164

165-
/* ToDo: Start Advertising */
165+
/* Start Advertising */
166166
ble_gap_adv_params_t adv_para = { 0 };
167167

168168
adv_para.type = params.getAdvertisingType() ;
@@ -174,7 +174,7 @@ ble_error_t nRF51Gap::startAdvertising(GapAdvertisingParams & params)
174174

175175
ASSERT( ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE);
176176

177-
state.advertising = 1;
177+
state.advertising = 1;
178178

179179
return BLE_ERROR_NONE;
180180
}
@@ -197,12 +197,10 @@ ble_error_t nRF51Gap::startAdvertising(GapAdvertisingParams & params)
197197
/**************************************************************************/
198198
ble_error_t nRF51Gap::stopAdvertising(void)
199199
{
200-
/* ToDo: Stop Advertising */
200+
/* Stop Advertising */
201+
ASSERT( ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
201202

202-
/* ToDo: Check response */
203-
wait(0.1);
204-
205-
state.advertising = 0;
203+
state.advertising = 0;
206204

207205
return BLE_ERROR_NONE;
208206
}
@@ -225,10 +223,11 @@ ble_error_t nRF51Gap::stopAdvertising(void)
225223
/**************************************************************************/
226224
ble_error_t nRF51Gap::disconnect(void)
227225
{
228-
/* ToDo: Disconnect if we are connected to a central device */
229-
230-
state.advertising = 0;
231-
state.connected = 0;
226+
/* Disconnect if we are connected to a central device */
227+
// ASSERT( ERROR_NONE == sd_ble_gap_disconnect(), BLE_ERROR_PARAM_OUT_OF_RANGE);
228+
229+
state.advertising = 0;
230+
state.connected = 0;
232231

233232
return BLE_ERROR_NONE;
234233
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,13 @@ ble_error_t nRF51GattServer::readValue(uint16_t charHandle, uint8_t buffer[], ui
136136
@endcode
137137
*/
138138
/**************************************************************************/
139-
ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len)
139+
ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len, bool localOnly)
140140
{
141+
if (localOnly)
142+
{
143+
/* Only update locally regardless of notify/indicate */
144+
ASSERT_INT( ERROR_NONE, sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer), BLE_ERROR_PARAM_OUT_OF_RANGE );
145+
}
141146
if ((p_characteristics[charHandle]->properties & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)) &&
142147
(m_connectionHandle != BLE_CONN_HANDLE_INVALID) )
143148
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class nRF51GattServer : public GattServer
4343
/* Functions that must be implemented from GattServer */
4444
virtual ble_error_t addService(GattService &);
4545
virtual ble_error_t readValue(uint16_t, uint8_t[], uint16_t);
46-
virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t);
46+
virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t, bool localOnly = false);
4747

4848
/* nRF51 Functions */
4949
void eventCallback(void);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
#ifndef _NORDIC_GLOBAL_H_
17+
#define _NORDIC_GLOBAL_H_
18+
19+
/* There are no global defines in mbed, so we need to define */
20+
/* mandatory conditional compilation flags here */
21+
#define NRF51
22+
#define DEBUG_NRF_USER
23+
#define BLE_STACK_SUPPORT_REQD
24+
#define BOARD_PCA10001
25+
26+
#endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
1+
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
22
*
33
* The information contained herein is property of Nordic Semiconductor ASA.
44
* Terms and conditions of usage are described in detail in NORDIC

libraries/mbed/api/error.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@
5353
* #endcode
5454
*/
5555

56-
#include <stdlib.h>
57-
#include "device.h"
56+
#include "toolchain.h"
5857

59-
#if DEVICE_STDIO_MESSAGES
60-
#include <stdio.h>
61-
#define error(...) (fprintf(stderr, __VA_ARGS__), exit(1))
62-
#else
63-
#define error(...) (exit(1))
58+
#ifdef __cplusplus
59+
extern "C" {
60+
#endif
61+
62+
void error(const char* format, ...);
63+
64+
#ifdef __cplusplus
65+
}
6466
#endif
6567

6668
#endif

libraries/mbed/api/mbed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef MBED_H
1717
#define MBED_H
1818

19-
#define MBED_LIBRARY_VERSION 80
19+
#define MBED_LIBRARY_VERSION 81
2020

2121
#include "platform.h"
2222

libraries/mbed/common/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
WEAK void mbed_die(void);
2121
WEAK void mbed_die(void) {
22+
#ifndef NRF51_H
2223
__disable_irq(); // dont allow interrupts to disturb the flash pattern
23-
24+
#endif
2425
#if (DEVICE_ERROR_RED == 1)
2526
gpio_t led_red; gpio_init_out(&led_red, LED_RED);
26-
2727
#elif (DEVICE_ERROR_PATTERN == 1)
2828
gpio_t led_1; gpio_init_out(&led_1, LED1);
2929
gpio_t led_2; gpio_init_out(&led_2, LED2);

libraries/mbed/common/error.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include <stdlib.h>
17+
#include <stdarg.h>
18+
#include "device.h"
19+
#include "toolchain.h"
20+
#if DEVICE_STDIO_MESSAGES
21+
#include <stdio.h>
22+
#endif
23+
24+
WEAK void error(const char* format, ...);
25+
WEAK void error(const char* format, ...) {
26+
#if DEVICE_STDIO_MESSAGES
27+
va_list arg;
28+
va_start(arg, format);
29+
vfprintf(stderr, format, arg);
30+
va_end(arg);
31+
#endif
32+
exit(1);
33+
}

libraries/mbed/common/gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode)
1919
{
20-
gpio_init(gpio, pin);
21-
gpio_mode(gpio, mode);
20+
gpio_init(gpio, pin);
2221
gpio_dir(gpio, PIN_INPUT);
22+
gpio_mode(gpio, mode);
2323
}
2424

2525
static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value)

libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_NRF51822/system_nrf51822.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,12 @@ void SystemCoreClockUpdate(void)
4343
}
4444

4545
void SystemInit(void)
46-
{
47-
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
48-
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
49-
}
50-
//write FWID (NRF_UICR->FWID is readonly)
51-
*(uint32_t *)0x10001010 = 0xFFFF0049;
52-
53-
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
54-
}
55-
56-
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
57-
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
58-
}
46+
{
5947
// Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required
6048
// to enable the use of peripherals" found at Product Anomaly document for your device found at
6149
// https://www.nordicsemi.com/. The side effect of executing these instructions in the devices
6250
// that do not need it is that the new peripherals in the second generation devices (LPCOMP for
6351
// example) will not be available.
64-
6552
if (is_manual_peripheral_setup_needed()){
6653
*(uint32_t volatile *)0x40000504 = 0xC007FFDF;
6754
*(uint32_t volatile *)0x40006C18 = 0x00008000;

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC81X/TARGET_LPC812/system_LPC8xx.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,23 @@
100100
// </h>
101101
// </e>
102102
*/
103-
#define CLOCK_SETUP 1
104-
#define SYSOSCCTRL_Val 0x00000000 // Reset: 0x000
105-
#define WDTOSCCTRL_Val 0x00000000 // Reset: 0x000
106-
#define SYSPLLCTRL_Val 0x00000041 // Reset: 0x000
107-
#define SYSPLLCLKSEL_Val 0x00000000 // Reset: 0x000
108-
#define MAINCLKSEL_Val 0x00000000 // Reset: 0x000
109-
#define SYSAHBCLKDIV_Val 0x00000001 // Reset: 0x001
103+
#define CLOCK_SETUP 1 // 1 == IRC: 2 == System Oscillator 12Mhz Xtal:
104+
105+
#if (CLOCK_SETUP == 1)
106+
#define SYSOSCCTRL_Val 0x00000000 // Reset: 0x000
107+
#define WDTOSCCTRL_Val 0x00000000 // Reset: 0x000
108+
#define SYSPLLCTRL_Val 0x00000041 // Reset: 0x000
109+
#define SYSPLLCLKSEL_Val 0x00000000 // Reset: 0x000
110+
#define MAINCLKSEL_Val 0x00000000 // Reset: 0x000
111+
#define SYSAHBCLKDIV_Val 0x00000001 // Reset: 0x001
112+
#elif (CLOCK_SETUP == 2)
113+
#define SYSOSCCTRL_Val 0x00000000 // Reset: 0x000
114+
#define WDTOSCCTRL_Val 0x00000000 // Reset: 0x000
115+
#define SYSPLLCTRL_Val 0x00000040 // Reset: 0x000
116+
#define SYSPLLCLKSEL_Val 0x00000001 // Reset: 0x000
117+
#define MAINCLKSEL_Val 0x00000003 // Reset: 0x000
118+
#define SYSAHBCLKDIV_Val 0x00000001 // Reset: 0x001
119+
#endif
110120

111121
/*
112122
//-------- <<< end of configuration section >>> ------------------------------

0 commit comments

Comments
 (0)