arc_timer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* ------------------------------------------
  2. * Copyright (c) 2016, Synopsys, Inc. All rights reserved.
  3. * Redistribution and use in source and binary forms, with or without modification,
  4. * are permitted provided that the following conditions are met:
  5. * 1) Redistributions of source code must retain the above copyright notice, this
  6. * list of conditions and the following disclaimer.
  7. * 2) Redistributions in binary form must reproduce the above copyright notice,
  8. * this list of conditions and the following disclaimer in the documentation and/or
  9. * other materials provided with the distribution.
  10. * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
  11. * be used to endorse or promote products derived from this software without
  12. * specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * \version 2016.05
  25. * \date 2014-07-15
  26. * \author Wayne Ren(Wei.Ren@synopsys.com)
  27. --------------------------------------------- */
  28. /**
  29. * \file
  30. * \ingroup ARC_HAL_MISC_TIMER
  31. * \brief header file of ARC internal timer
  32. */
  33. /**
  34. * \addtogroup ARC_HAL_MISC_TIMER
  35. * @{
  36. */
  37. #ifndef _ARC_HAL_TIMER_H_
  38. #define _ARC_HAL_TIMER_H_
  39. #include "inc/arc/arc.h"
  40. #include "inc/embARC_toolchain.h"
  41. /**
  42. * \name arc internal timers names
  43. * @{
  44. */
  45. #define TIMER_0 0 /*!< macro name for arc internal timer 0 */
  46. #define TIMER_1 1 /*!< macro name for arc internal timer 1 */
  47. #define TIMER_RTC 2 /*!< macro name for arc internal RTC */
  48. /** @} */
  49. /**
  50. * \name bit definition of RTC CTRL reg
  51. * @{
  52. */
  53. #define TIMER_RTC_ENABLE 0x01 /*!< enable RTC */
  54. #define TIMER_RTC_CLEAR 0x02 /* clears the AUX_RTC_LOW and AUX_RTC_HIGH */
  55. #define TIMER_RTC_STATUS_A0 0x40000000 /*!< track bit of atomicity of reads of RTC */
  56. #define TIMER_RTC_STATUS_A1 0x80000000 /*!< track bit of atomicity of reads of RTC */
  57. /** @} */
  58. /**
  59. * \name bit definition of timer CTRL reg
  60. * @{
  61. */
  62. #define TIMER_CTRL_IE (1 << 0) /*!< Interrupt when count reaches limit */
  63. #define TIMER_CTRL_NH (1 << 1) /*!< Count only when CPU NOT halted */
  64. #define TIMER_CTRL_W (1 << 2) /*!< watchdog enable */
  65. #define TIMER_CTRL_IP (1 << 3) /*!< interrupt pending */
  66. /** @} */
  67. #ifdef __cplusplus
  68. extern "C" {
  69. #endif
  70. extern int32_t arc_timer_present(const uint32_t no);
  71. extern int32_t arc_timer_start(const uint32_t no, const uint32_t mode, const uint32_t val);
  72. extern int32_t arc_timer_stop(const uint32_t no);
  73. extern int32_t arc_timer_current(const uint32_t no, void* val);
  74. extern int32_t arc_timer_int_clear(const uint32_t no);
  75. extern void arc_timer_init(void);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif /* _ARC_HAL_TIMER_H_ */
  80. /** }@*/