Skip to content

Commit f7ec796

Browse files
committed
Introduce subtarget_sdk_init startup hook.
The `mbed_sdk_init` startup hook is implemented at the NRF52-series level and so is unavailable for override. This commit adds an additional startup hook for NRF52 subtargets to perform any other startup initialization required.
1 parent 7b6c7cc commit f7ec796

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
uint32_t nrf_dispatch_vector[NVIC_NUM_VECTORS] @ ".nvictable";
5858
#endif
5959

60+
#include "platform/mbed_toolchain.h"
61+
#include "subtarget_init.h"
62+
6063
extern uint32_t __Vectors[];
6164

6265
#define VECTORS_FLASH_START __Vectors
@@ -113,7 +116,6 @@ void nrf_reloc_vector_table(void)
113116
#endif
114117
}
115118

116-
117119
void mbed_sdk_init(void)
118120
{
119121
if (STDIO_UART_RTS != NC) {
@@ -122,4 +124,6 @@ void mbed_sdk_init(void)
122124
/* Set STDIO_UART_RTS as gpio driven low */
123125
gpio_write(&rts, 0);
124126
}
127+
128+
subtarget_sdk_init();
125129
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2021 ARM Limited
3+
* Copyright (c) 2021 Embedded Planet, Inc.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "subtarget_init.h"
20+
#include "platform/mbed_toolchain.h"
21+
22+
MBED_WEAK void subtarget_sdk_init(void) {
23+
/* Do nothing by default */
24+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2021 ARM Limited
3+
* Copyright (c) 2021 Embedded Planet, Inc.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef _NORDIC_SUBTARGET_INIT_
20+
#define _NORDIC_SUBTARGET_INIT_
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
26+
/**
27+
* Since Mbed's `mbed_sdk_init` hook is used by the NRF52 family code, this
28+
* initialization hook is provided so subtargets may implement their own startup
29+
* initialization code, if necessary.
30+
*
31+
* By default, it is a blank function that is declared a "weak" symbol
32+
*/
33+
void subtarget_sdk_init(void);
34+
35+
#ifdef __cplusplus
36+
}
37+
#endif
38+
39+
#endif /* _NORDIC_SUBTARGET_INIT_ */

0 commit comments

Comments
 (0)