1 /***************************************************************************//**
\r
3 * @brief Peripheral Reflex System (PRS) peripheral API
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
\r
8 *******************************************************************************
\r
10 * Permission is granted to anyone to use this software for any purpose,
\r
11 * including commercial applications, and to alter it and redistribute it
\r
12 * freely, subject to the following restrictions:
\r
14 * 1. The origin of this software must not be misrepresented; you must not
\r
15 * claim that you wrote the original software.
\r
16 * 2. Altered source versions must be plainly marked as such, and must not be
\r
17 * misrepresented as being the original software.
\r
18 * 3. This notice may not be removed or altered from any source distribution.
\r
20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
\r
21 * obligation to support this Software. Silicon Labs is providing the
\r
22 * Software "AS IS", with no express or implied warranties of any kind,
\r
23 * including, but not limited to, any implied warranties of merchantability
\r
24 * or fitness for any particular purpose or warranties against infringement
\r
25 * of any proprietary rights of a third party.
\r
27 * Silicon Labs will not be liable for any consequential, incidental, or
\r
28 * special damages, or any other relief, or for any claim by any third party,
\r
29 * arising from your use of this Software.
\r
31 ******************************************************************************/
\r
33 #ifndef __SILICON_LABS_EM_PRS_H__
\r
34 #define __SILICON_LABS_EM_PRS_H__
\r
36 #include "em_device.h"
\r
37 #if defined(PRS_COUNT) && (PRS_COUNT > 0)
\r
43 /***************************************************************************//**
\r
44 * @addtogroup EM_Library
\r
46 ******************************************************************************/
\r
48 /***************************************************************************//**
\r
51 ******************************************************************************/
\r
53 /*******************************************************************************
\r
54 ******************************** ENUMS ************************************
\r
55 ******************************************************************************/
\r
57 /** Edge detection type. */
\r
60 prsEdgeOff = PRS_CH_CTRL_EDSEL_OFF, /**< Leave signal as is. */
\r
61 prsEdgePos = PRS_CH_CTRL_EDSEL_POSEDGE, /**< Generate pules on positive edge. */
\r
62 prsEdgeNeg = PRS_CH_CTRL_EDSEL_NEGEDGE, /**< Generate pules on negative edge. */
\r
63 prsEdgeBoth = PRS_CH_CTRL_EDSEL_BOTHEDGES /**< Generate pules on both edges. */
\r
66 /*******************************************************************************
\r
67 ***************************** PROTOTYPES **********************************
\r
68 ******************************************************************************/
\r
70 /***************************************************************************//**
\r
72 * Set level control bit for one or more channels.
\r
75 * The level value for a channel is XORed with both the pulse possible issued
\r
76 * by PRS_PulseTrigger() and the PRS input signal selected for the channel(s).
\r
79 * Level to use for channels indicated by @p mask. Use logical OR combination
\r
80 * of PRS_SWLEVEL_CHnLEVEL defines for channels to set high level, otherwise 0.
\r
83 * Mask indicating which channels to set level for. Use logical OR combination
\r
84 * of PRS_SWLEVEL_CHnLEVEL defines.
\r
85 ******************************************************************************/
\r
86 __STATIC_INLINE void PRS_LevelSet(uint32_t level, uint32_t mask)
\r
88 PRS->SWLEVEL = (PRS->SWLEVEL & ~mask) | (level & mask);
\r
92 /***************************************************************************//**
\r
94 * Trigger a high pulse (one HFPERCLK) for one or more channels.
\r
97 * Setting a bit for a channel causes the bit in the register to remain high
\r
98 * for one HFPERCLK cycle. The pulse is XORed with both the corresponding bit
\r
99 * in PRS SWLEVEL register and the PRS input signal selected for the
\r
102 * @param[in] channels
\r
103 * Logical ORed combination of channels to trigger a pulse for. Use
\r
104 * PRS_SWPULSE_CHnPULSE defines.
\r
105 ******************************************************************************/
\r
106 __STATIC_INLINE void PRS_PulseTrigger(uint32_t channels)
\r
108 PRS->SWPULSE = channels & _PRS_SWPULSE_MASK;
\r
111 void PRS_SourceSignalSet(unsigned int ch,
\r
114 PRS_Edge_TypeDef edge);
\r
116 #if defined( PRS_CH_CTRL_ASYNC )
\r
117 void PRS_SourceAsyncSignalSet(unsigned int ch,
\r
122 /** @} (end addtogroup PRS) */
\r
123 /** @} (end addtogroup EM_Library) */
\r
129 #endif /* defined(PRS_COUNT) && (PRS_COUNT > 0) */
\r
130 #endif /* __SILICON_LABS_EM_PRS_H__ */
\r