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.
pull/14325/head
George Beckstein 2021-02-22 17:18:41 -05:00
parent 8340ea2d2b
commit 9e4d46262d
3 changed files with 68 additions and 1 deletions

View File

@ -57,6 +57,9 @@
uint32_t nrf_dispatch_vector[NVIC_NUM_VECTORS] @ ".nvictable";
#endif
#include "platform/mbed_toolchain.h"
#include "subtarget_init.h"
extern uint32_t __Vectors[];
#define VECTORS_FLASH_START __Vectors
@ -113,7 +116,6 @@ void nrf_reloc_vector_table(void)
#endif
}
void mbed_sdk_init(void)
{
if (STDIO_UART_RTS != NC) {
@ -122,4 +124,6 @@ void mbed_sdk_init(void)
/* Set STDIO_UART_RTS as gpio driven low */
gpio_write(&rts, 0);
}
subtarget_sdk_init();
}

View File

@ -0,0 +1,24 @@
/* mbed Microcontroller Library
* Copyright (c) 2021 ARM Limited
* Copyright (c) 2021 Embedded Planet, Inc.
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#include "subtarget_init.h"
#include "platform/mbed_toolchain.h"
MBED_WEAK void subtarget_sdk_init(void) {
/* Do nothing by default */
}

View File

@ -0,0 +1,39 @@
/* mbed Microcontroller Library
* Copyright (c) 2021 ARM Limited
* Copyright (c) 2021 Embedded Planet, Inc.
* SPDX-License-Identifier: Apache-2.0
*
* 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 _NORDIC_SUBTARGET_INIT_
#define _NORDIC_SUBTARGET_INIT_
#ifdef __cplusplus
extern "C" {
#endif
/**
* Since Mbed's `mbed_sdk_init` hook is used by the NRF52 family code, this
* initialization hook is provided so subtargets may implement their own startup
* initialization code, if necessary.
*
* By default, it is a blank function that is declared a "weak" symbol
*/
void subtarget_sdk_init(void);
#ifdef __cplusplus
}
#endif
#endif /* _NORDIC_SUBTARGET_INIT_ */