Skip to content

Commit 6a2d93e

Browse files
author
Kyle Kearney
committed
Add optional post-bsp-init hook
This allows the application to inject its own resource reservations immmediately after the BSP (and therefore HAL) is initialized, ensuring that they can claim require resources before mbed tries to use them for more flexible purposes. For example, the application might want to claim a particular timer to make sure that it doesn't get picked for us_ticker (which can use any arbitrary timer instance).
1 parent ab5eb07 commit 6a2d93e

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* mbed Microcontroller Library
3+
* Copyright (c) 2019, Arm Limited and affiliates.
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 CY_MBED_POST_INIT_H
20+
#define CY_MBED_POST_INIT_H
21+
22+
#include "mbed_toolchain.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/*******************************************************************************
29+
* Function Name: cy_mbed_post_bsp_init_hook
30+
****************************************************************************//**
31+
*
32+
* Function that is called immediately after cybsp_init finishes executing
33+
* Applications can override this definition if they need to reserve resources
34+
* early in the startup process so that later stages won't try and use them.
35+
* For example, a timer instance might be reserved so that the us_ticker won't
36+
* try to allocate it.
37+
*
38+
*******************************************************************************/
39+
void cy_mbed_post_bsp_init_hook(void);
40+
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
45+
#endif /* CY_MBED_POST_INIT_H */

targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "cycfg.h"
2121
#include "cyhal_hwmgr.h"
2222
#include "cybsp.h"
23+
#include "cy_mbed_post_init.h"
2324
#include "mbed_power_mgmt.h"
2425
#if MBED_CONF_RTOS_PRESENT
2526
#include "rtos_idle.h"
@@ -49,6 +50,11 @@ static void active_idle_hook(void)
4950
}
5051
#endif
5152

53+
MBED_WEAK void cy_mbed_post_bsp_init_hook(void)
54+
{
55+
/* By default, do nothing */
56+
}
57+
5258
/*******************************************************************************
5359
* Function Name: mbed_sdk_init
5460
****************************************************************************//**
@@ -71,6 +77,8 @@ void mbed_sdk_init(void)
7177
/* Set up the device based on configurator selections */
7278
cybsp_init();
7379

80+
cy_mbed_post_bsp_init_hook();
81+
7482
#if CY_CPU_CORTEX_M0P
7583
/* Enable global interrupts */
7684
__enable_irq();

0 commit comments

Comments
 (0)