xtensa_init.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  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. * XTENSA INITIALIZATION ROUTINES CODED IN C
  31. *
  32. * This file contains miscellaneous Xtensa RTOS-generic initialization functions
  33. * that are implemented in C.
  34. */
  35. #ifdef XT_BOARD
  36. #include <xtensa/xtbsp.h>
  37. #endif
  38. #include "xtensa_rtos.h"
  39. #ifdef XT_RTOS_TIMER_INT
  40. unsigned _xt_tick_divisor = 0; /* cached number of cycles per tick */
  41. /*
  42. Compute and initialize at run-time the tick divisor (the number of
  43. processor clock cycles in an RTOS tick, used to set the tick timer).
  44. Called when the processor clock frequency is not known at compile-time.
  45. */
  46. void _xt_tick_divisor_init(void)
  47. {
  48. #ifdef XT_CLOCK_FREQ
  49. _xt_tick_divisor = (XT_CLOCK_FREQ / XT_TICK_PER_SEC);
  50. #else
  51. #ifdef XT_BOARD
  52. _xt_tick_divisor = xtbsp_clock_freq_hz() / XT_TICK_PER_SEC;
  53. #else
  54. #error "No way to obtain processor clock frequency"
  55. #endif /* XT_BOARD */
  56. #endif /* XT_CLOCK_FREQ */
  57. }
  58. #endif /* XT_RTOS_TIMER_INT */