Skip to content

Commit 8623452

Browse files
Merge branch 'upstream/master'
2 parents 5cb6b71 + 0c93185 commit 8623452

File tree

376 files changed

+9292
-4717
lines changed

Some content is hidden

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

376 files changed

+9292
-4717
lines changed

libraries/USBDevice/USBDevice/USBDevice.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,11 @@ void USBDevice::disconnect(void)
718718
{
719719
/* Disconnect device */
720720
USBHAL::disconnect();
721+
722+
/* Set initial device state */
723+
device.state = POWERED;
724+
device.configuration = 0;
725+
device.suspended = false;
721726
}
722727

723728
CONTROL_TRANSFER * USBDevice::getTransferPtr(void)

libraries/mbed/api/error.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
* #endcode
5454
*/
5555

56-
#include "toolchain.h"
57-
5856
#ifdef __cplusplus
5957
extern "C" {
6058
#endif

libraries/mbed/api/mbed_assert.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
#ifndef MBED_ASSERT_H
17+
#define MBED_ASSERT_H
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
/** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
24+
* This function is active only if NDEBUG is not defined prior to including this
25+
* assert header file.
26+
* In case of MBED_ASSERT failing condition, the assertation message is printed
27+
* to stderr and mbed_die() is called.
28+
* @param expr Expresion to be checked.
29+
* @param file File where assertation failed.
30+
* @param line Failing assertation line number.
31+
*/
32+
void mbed_assert_internal(const char *expr, const char *file, int line);
33+
34+
#ifdef __cplusplus
35+
}
36+
#endif
37+
38+
#ifdef NDEBUG
39+
#define MBED_ASSERT(expr) ((void)0)
40+
41+
#else
42+
#define MBED_ASSERT(expr) \
43+
do { \
44+
if (!(expr)) { \
45+
mbed_assert_internal(#expr, __FILE__, __LINE__); \
46+
} \
47+
} while (0)
48+
#endif
49+
50+
#endif

libraries/mbed/common/assert.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 "mbed_assert.h"
17+
#include "device.h"
18+
19+
#if DEVICE_STDIO_MESSAGES
20+
#include <stdio.h>
21+
#endif
22+
23+
#include <stdlib.h>
24+
#include "mbed_interface.h"
25+
26+
void mbed_assert_internal(const char *expr, const char *file, int line)
27+
{
28+
#if DEVICE_STDIO_MESSAGES
29+
fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
30+
#endif
31+
mbed_die();
32+
}

libraries/mbed/common/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "gpio_api.h"
1717
#include "wait_api.h"
1818
#include "toolchain.h"
19+
#include "mbed_interface.h"
1920

20-
WEAK void mbed_die(void);
2121
WEAK void mbed_die(void) {
2222
#ifndef NRF51_H
2323
__disable_irq(); // dont allow interrupts to disturb the flash pattern

libraries/mbed/common/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
#include <stdarg.h>
1818
#include "device.h"
1919
#include "toolchain.h"
20+
#include "error.h"
2021
#if DEVICE_STDIO_MESSAGES
2122
#include <stdio.h>
2223
#endif
2324

24-
WEAK void error(const char* format, ...);
2525
WEAK void error(const char* format, ...) {
2626
#if DEVICE_STDIO_MESSAGES
2727
va_list arg;

libraries/mbed/common/mbed_interface.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ int mbed_interface_reset(void) {
3838
}
3939
}
4040

41-
WEAK int mbed_interface_uid(char *uid);
4241
WEAK int mbed_interface_uid(char *uid) {
4342
if (mbed_interface_connected()) {
4443
return semihost_uid(uid); // Returns 0 if successful, -1 on failure
@@ -77,13 +76,11 @@ void mbed_reset(void) {
7776
mbed_interface_reset();
7877
}
7978

80-
WEAK int mbed_uid(char *uid);
8179
WEAK int mbed_uid(char *uid) {
8280
return mbed_interface_uid(uid);
8381
}
8482
#endif
8583

86-
WEAK void mbed_mac_address(char *mac);
8784
WEAK void mbed_mac_address(char *mac) {
8885
#if DEVICE_SEMIHOST
8986
char uid[DEVICE_ID_LENGTH + 1];

libraries/mbed/common/pinmap_common.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#include "error.h"
1818

1919
void pinmap_pinout(PinName pin, const PinMap *map) {
20-
if (pin == NC) return;
20+
if (pin == NC)
21+
return;
2122

2223
while (map->pin != NC) {
2324
if (map->pin == pin) {
@@ -33,11 +34,14 @@ void pinmap_pinout(PinName pin, const PinMap *map) {
3334

3435
uint32_t pinmap_merge(uint32_t a, uint32_t b) {
3536
// both are the same (inc both NC)
36-
if (a == b) return a;
37+
if (a == b)
38+
return a;
3739

3840
// one (or both) is not connected
39-
if (a == (uint32_t)NC) return b;
40-
if (b == (uint32_t)NC) return a;
41+
if (a == (uint32_t)NC)
42+
return b;
43+
if (b == (uint32_t)NC)
44+
return a;
4145

4246
// mis-match error case
4347
error("pinmap mis-match");

libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MEMORY
77
VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400
88
FLASH_PROTECTION (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010
99
FLASH (rx) : ORIGIN = 0x00000410, LENGTH = 0x00100000 - 0x00000410
10-
RAM (rwx) : ORIGIN = 0x1FFF0400, LENGTH = 0x00040000 - 0x00000400
10+
RAM (rwx) : ORIGIN = 0x1FFF0198, LENGTH = 0x00040000 - 0x00000198
1111
}
1212

1313
/* Linker script to place sections and symbol values. Should be used together

libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#ifdef __STACK_SIZE
5050
.equ Stack_Size, __STACK_SIZE
5151
#else
52-
.equ Stack_Size, 0x400
52+
.equ Stack_Size, 0xC00
5353
#endif
5454
.globl __StackTop
5555
.globl __StackLimit
@@ -64,7 +64,7 @@ __StackTop:
6464
#ifdef __HEAP_SIZE
6565
.equ Heap_Size, __HEAP_SIZE
6666
#else
67-
.equ Heap_Size, 0x80
67+
.equ Heap_Size, 0x400
6868
#endif
6969
.globl __HeapBase
7070
.globl __HeapLimit
@@ -199,6 +199,18 @@ Reset_Handler:
199199
* __data_start__/__data_end__: RAM address range that data should be
200200
* copied to. Both must be aligned to 4 bytes boundary. */
201201

202+
disable_watchdog:
203+
/* unlock */
204+
ldr r1, =0x4005200e
205+
ldr r0, =0xc520
206+
strh r0, [r1]
207+
ldr r0, =0xd928
208+
strh r0, [r1]
209+
/* disable */
210+
ldr r1, =0x40052000
211+
ldr r0, =0x01d2
212+
strh r0, [r1]
213+
202214
ldr r1, =__etext
203215
ldr r2, =__data_start__
204216
ldr r3, =__data_end__

libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef MBED_CMSIS_NVIC_H
88
#define MBED_CMSIS_NVIC_H
99

10-
#define NVIC_NUM_VECTORS (16 + 85) // CORE + MCU Peripherals
10+
#define NVIC_NUM_VECTORS (16 + 86) // CORE + MCU Peripherals
1111
#define NVIC_USER_IRQ_OFFSET 16
1212

1313
#include "cmsis.h"

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO/startup_stm32f401xe.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
;******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
22
;* File Name : startup_stm32f401xe.s
33
;* Author : MCD Application Team
4-
;* Version : V2.0.0
5-
;* Date : 18-February-2014
6-
;* Description : STM32F401xe devices vector table for MDK-ARM toolchain.
4+
;* Version : V2.1.0RC2
5+
;* Date : 14-May-2014
6+
;* Description : STM32F401xe devices vector table for MDK-ARM_MICRO toolchain.
77
;* This module performs:
88
;* - Set the initial SP
99
;* - Set the initial PC == Reset_Handler

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/startup_stm32f401xe.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
;******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
22
;* File Name : startup_stm32f401xe.s
33
;* Author : MCD Application Team
4-
;* Version : V2.0.0
5-
;* Date : 18-February-2014
6-
;* Description : STM32F401xe devices vector table for MDK-ARM toolchain.
4+
;* Version : V2.1.0RC2
5+
;* Date : 14-May-2014
6+
;* Description : STM32F401xe devices vector table for MDK-ARM_STD toolchain.
77
;* This module performs:
88
;* - Set the initial SP
99
;* - Set the initial PC == Reset_Handler
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/**
2+
******************************************************************************
3+
* @file hal_tick.c
4+
* @author MCD Application Team
5+
* @brief Initialization of HAL tick
6+
******************************************************************************
7+
* @attention
8+
*
9+
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
10+
*
11+
* Redistribution and use in source and binary forms, with or without modification,
12+
* are permitted provided that the following conditions are met:
13+
* 1. Redistributions of source code must retain the above copyright notice,
14+
* this list of conditions and the following disclaimer.
15+
* 2. Redistributions in binary form must reproduce the above copyright notice,
16+
* this list of conditions and the following disclaimer in the documentation
17+
* and/or other materials provided with the distribution.
18+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
19+
* may be used to endorse or promote products derived from this software
20+
* without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*
33+
******************************************************************************
34+
*/
35+
#include "hal_tick.h"
36+
37+
TIM_HandleTypeDef TimMasterHandle;
38+
uint32_t PreviousVal = 0;
39+
40+
void us_ticker_irq_handler(void);
41+
42+
void timer_irq_handler(void) {
43+
// Channel 1 for mbed timeout
44+
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
45+
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
46+
us_ticker_irq_handler();
47+
}
48+
49+
// Channel 2 for HAL tick
50+
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
51+
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
52+
uint32_t val = __HAL_TIM_GetCounter(&TimMasterHandle);
53+
if ((val - PreviousVal) >= HAL_TICK_DELAY) {
54+
// Increment HAL variable
55+
HAL_IncTick();
56+
// Prepare next interrupt
57+
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, val + HAL_TICK_DELAY);
58+
PreviousVal = val;
59+
#if 0 // For DEBUG only
60+
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_6);
61+
#endif
62+
}
63+
}
64+
}
65+
66+
// Reconfigure the HAL tick using a standard timer instead of systick.
67+
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
68+
// Enable timer clock
69+
TIM_MST_RCC;
70+
71+
// Reset timer
72+
TIM_MST_RESET_ON;
73+
TIM_MST_RESET_OFF;
74+
75+
// Configure time base
76+
TimMasterHandle.Instance = TIM_MST;
77+
TimMasterHandle.Init.Period = 0xFFFFFFFF;
78+
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
79+
TimMasterHandle.Init.ClockDivision = 0;
80+
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
81+
TimMasterHandle.Init.RepetitionCounter = 0;
82+
HAL_TIM_OC_Init(&TimMasterHandle);
83+
84+
NVIC_SetVector(TIM_MST_IRQ, (uint32_t)timer_irq_handler);
85+
NVIC_EnableIRQ(TIM_MST_IRQ);
86+
87+
// Channel 1 for mbed timeout
88+
HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1);
89+
90+
// Channel 2 for HAL tick
91+
HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_2);
92+
PreviousVal = __HAL_TIM_GetCounter(&TimMasterHandle);
93+
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, PreviousVal + HAL_TICK_DELAY);
94+
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
95+
96+
#if 0 // For DEBUG only
97+
__GPIOB_CLK_ENABLE();
98+
GPIO_InitTypeDef GPIO_InitStruct;
99+
GPIO_InitStruct.Pin = GPIO_PIN_6;
100+
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
101+
GPIO_InitStruct.Pull = GPIO_PULLUP;
102+
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
103+
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
104+
#endif
105+
106+
return HAL_OK;
107+
}
108+
109+
/**
110+
* @}
111+
*/
112+
113+
/**
114+
* @}
115+
*/
116+
117+
/**
118+
* @}
119+
*/
120+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)