hpm_mono_drv.h 818 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_MONO_DRV_H
  8. #define HPM_MONO_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_mono_regs.h"
  11. /**
  12. *
  13. * @brief MONO driver APIs
  14. * @defgroup mono_interface MONO driver APIs
  15. * @ingroup io_interfaces
  16. * @{
  17. */
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @brief Get counter
  23. *
  24. * @param[in] ptr MONO base address
  25. *
  26. * @return 64 bits counter value
  27. */
  28. static inline uint64_t mono_get_counter(MONO_Type *ptr)
  29. {
  30. return (uint64_t)((uint64_t)((ptr->MONOH) << 32))
  31. | (uint64_t)((ptr->MONOL));
  32. }
  33. /**
  34. * @brief Update MONO counter by 1
  35. *
  36. * @param[in] ptr MONO base
  37. */
  38. static inline void mono_update(MONO_Type *ptr)
  39. {
  40. ptr->MONOL = 1;
  41. }
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. /**
  46. * @}
  47. */
  48. #endif /* HPM_MONO_DRV_H */