efm32_prs.h 4.7 KB

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