em_prs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /***************************************************************************//**
  2. * @file
  3. * @brief Peripheral Reflex System (PRS) peripheral API
  4. * @author Energy Micro AS
  5. * @version 3.0.0
  6. *******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * Permission is granted to anyone to use this software for any purpose,
  12. * including commercial applications, and to alter it and redistribute it
  13. * freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not
  16. * claim that you wrote the original software.
  17. * 2. Altered source versions must be plainly marked as such, and must not be
  18. * misrepresented as being the original software.
  19. * 3. This notice may not be removed or altered from any source distribution.
  20. *
  21. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  22. * obligation to support this Software. Energy Micro AS is providing the
  23. * Software "AS IS", with no express or implied warranties of any kind,
  24. * including, but not limited to, any implied warranties of merchantability
  25. * or fitness for any particular purpose or warranties against infringement
  26. * of any proprietary rights of a third party.
  27. *
  28. * Energy Micro AS will not be liable for any consequential, incidental, or
  29. * special damages, or any other relief, or for any claim by any third party,
  30. * arising from your use of this Software.
  31. *
  32. ******************************************************************************/
  33. #ifndef __EM_PRS_H
  34. #define __EM_PRS_H
  35. #include "em_part.h"
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /***************************************************************************//**
  40. * @addtogroup EM_Library
  41. * @{
  42. ******************************************************************************/
  43. /***************************************************************************//**
  44. * @addtogroup PRS
  45. * @{
  46. ******************************************************************************/
  47. /*******************************************************************************
  48. ******************************** ENUMS ************************************
  49. ******************************************************************************/
  50. /** Edge detection type. */
  51. typedef enum
  52. {
  53. prsEdgeOff = PRS_CH_CTRL_EDSEL_OFF, /**< Leave signal as is. */
  54. prsEdgePos = PRS_CH_CTRL_EDSEL_POSEDGE, /**< Generate pules on positive edge. */
  55. prsEdgeNeg = PRS_CH_CTRL_EDSEL_NEGEDGE, /**< Generate pules on negative edge. */
  56. prsEdgeBoth = PRS_CH_CTRL_EDSEL_BOTHEDGES /**< Generate pules on both edges. */
  57. } PRS_Edge_TypeDef;
  58. /*******************************************************************************
  59. ***************************** PROTOTYPES **********************************
  60. ******************************************************************************/
  61. /***************************************************************************//**
  62. * @brief
  63. * Set level control bit for one or more channels.
  64. *
  65. * @details
  66. * The level value for a channel is XORed with both the pulse possible issued
  67. * by PRS_PulseTrigger() and the PRS input signal selected for the channel(s).
  68. *
  69. * @param[in] level
  70. * Level to use for channels indicated by @p mask. Use logical OR combination
  71. * of PRS_SWLEVEL_CHnLEVEL defines for channels to set high level, otherwise 0.
  72. *
  73. * @param[in] mask
  74. * Mask indicating which channels to set level for. Use logical OR combination
  75. * of PRS_SWLEVEL_CHnLEVEL defines.
  76. ******************************************************************************/
  77. __STATIC_INLINE void PRS_LevelSet(uint32_t level, uint32_t mask)
  78. {
  79. PRS->SWLEVEL = (PRS->SWLEVEL & ~mask) | (level & mask);
  80. }
  81. /***************************************************************************//**
  82. * @brief
  83. * Trigger a high pulse (one HFPERCLK) for one or more channels.
  84. *
  85. * @details
  86. * Setting a bit for a channel causes the bit in the register to remain high
  87. * for one HFPERCLK cycle. The pulse is XORed with both the corresponding bit
  88. * in PRS SWLEVEL register and the PRS input signal selected for the
  89. * channel(s).
  90. *
  91. * @param[in] channels
  92. * Logical ORed combination of channels to trigger a pulse for. Use
  93. * PRS_SWPULSE_CHnPULSE defines.
  94. ******************************************************************************/
  95. __STATIC_INLINE void PRS_PulseTrigger(uint32_t channels)
  96. {
  97. PRS->SWPULSE = channels & _PRS_SWPULSE_MASK;
  98. }
  99. void PRS_SourceSignalSet(unsigned int ch,
  100. uint32_t source,
  101. uint32_t signal,
  102. PRS_Edge_TypeDef edge);
  103. #if ((defined _EFM32_TINY_FAMILY) || (defined _EFM32_GIANT_FAMILY))
  104. void PRS_SourceAsyncSignalSet(unsigned int ch,
  105. uint32_t source,
  106. uint32_t signal);
  107. #endif
  108. /** @} (end addtogroup PRS) */
  109. /** @} (end addtogroup EM_Library) */
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* __EM_PRS_H */