Skip to content

Commit cc8cc59

Browse files
urutvajainvikas8
authored andcommitted
cypress: psoc64: Reserve timer channels used by TF-M
There are two timers, Timer0 and Timer1, available on the PSoC64. Timer0 has 8 channels and Timer1 has 24 channels. TF-M regression tests make use of Timer0 Channel 0 and Timer0 Channel 1. Therefore, reserve the timer channels used by TF-M. This approach can be replaced once we have a way to allocate dedicated timers for TF-M and Mbed OS. Signed-off-by: Devaraj Ranganna <[email protected]> Signed-off-by: Vikas Katariya <[email protected]>
1 parent c8ab263 commit cc8cc59

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/cy_us_ticker_api.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2019, Arm Limited and affiliates.
2+
* Copyright (c) 2019-2020, Arm Limited and affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* 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
5454
void us_ticker_init(void)
5555
{
5656
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
5774
if (CY_RSLT_SUCCESS != cyhal_timer_init(&cy_us_timer, NC, NULL)) {
5875
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_FAILED_OPERATION), "cyhal_timer_init");
5976
}

0 commit comments

Comments
 (0)