|
1 | 1 | /* mbed Microcontroller Library
|
2 |
| - * Copyright (c) 2019, Arm Limited and affiliates. |
| 2 | + * Copyright (c) 2019-2020, Arm Limited and affiliates. |
3 | 3 | * SPDX-License-Identifier: Apache-2.0
|
4 | 4 | *
|
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -54,6 +54,23 @@ static void cy_us_ticker_irq_handler(MBED_UNUSED void *arg, MBED_UNUSED cyhal_ti
|
54 | 54 | void us_ticker_init(void)
|
55 | 55 | {
|
56 | 56 | if (!cy_us_ticker_initialized) {
|
| 57 | + |
| 58 | +#ifdef TARGET_TFM |
| 59 | + /* There are two timers, Timer0 and Timer1, available on the PSoC64. |
| 60 | + * Timer0 has 8 channels and Timer1 has 24 channels. TF-M regression |
| 61 | + * tests make use of Timer0 Channel 1 and Timer0 Channel 2. Therefore, |
| 62 | + * reserve the timer channels used by TF-M. This approach can be |
| 63 | + * replaced once we have a way to allocate dedicated timers for TF-M |
| 64 | + * and Mbed OS. */ |
| 65 | + cyhal_resource_inst_t res = { CYHAL_RSC_TCPWM, 0, 0 }; |
| 66 | + if(CY_RSLT_SUCCESS != cyhal_hwmgr_reserve(&res)) { |
| 67 | + MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_timer_init"); |
| 68 | + } |
| 69 | + res.channel_num = 1; |
| 70 | + if(CY_RSLT_SUCCESS != cyhal_hwmgr_reserve(&res)) { |
| 71 | + MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_timer_init"); |
| 72 | + } |
| 73 | +#endif |
57 | 74 | if (CY_RSLT_SUCCESS != cyhal_timer_init(&cy_us_timer, NC, NULL)) {
|
58 | 75 | MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_timer_init");
|
59 | 76 | }
|
|
0 commit comments