1 /* 2 * FreeRTOS Kernel V11.0.1 3 * Copyright (C) 2015-2019 Cadence Design Systems, Inc. 4 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 * 6 * SPDX-License-Identifier: MIT 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 * this software and associated documentation files (the "Software"), to deal in 10 * the Software without restriction, including without limitation the rights to 11 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12 * the Software, and to permit persons to whom the Software is furnished to do so, 13 * subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in all 16 * copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 * https://www.FreeRTOS.org 26 * https://github.com/FreeRTOS 27 * 28 */ 29 30 /* 31 * XTENSA INITIALIZATION ROUTINES CODED IN C 32 * 33 * This file contains miscellaneous Xtensa RTOS-generic initialization functions 34 * that are implemented in C. 35 */ 36 37 38 #ifdef XT_BOARD 39 #include <xtensa/xtbsp.h> 40 #endif 41 42 #include "xtensa_rtos.h" 43 44 #ifdef XT_RTOS_TIMER_INT 45 46 unsigned _xt_tick_divisor = 0; /* cached number of cycles per tick */ 47 48 /* 49 * Compute and initialize at run-time the tick divisor (the number of 50 * processor clock cycles in an RTOS tick, used to set the tick timer). 51 * Called when the processor clock frequency is not known at compile-time. 52 */ _xt_tick_divisor_init(void)53 void _xt_tick_divisor_init( void ) 54 { 55 #ifdef XT_CLOCK_FREQ 56 _xt_tick_divisor = ( XT_CLOCK_FREQ / XT_TICK_PER_SEC ); 57 #else 58 #ifdef XT_BOARD 59 _xt_tick_divisor = xtbsp_clock_freq_hz() / XT_TICK_PER_SEC; 60 #else 61 #error "No way to obtain processor clock frequency" 62 #endif /* XT_BOARD */ 63 #endif /* XT_CLOCK_FREQ */ 64 } 65 66 #endif /* XT_RTOS_TIMER_INT */ 67