]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/emlib/inc/em_prs.h
31b71fef757e04df7a8f7adf7a8cfade940063c9
[freertos] / FreeRTOS / Demo / CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio / Source / SilLabs_Code / emlib / inc / em_prs.h
1 /***************************************************************************//**\r
2  * @file em_prs.h\r
3  * @brief Peripheral Reflex System (PRS) peripheral API\r
4  * @version 4.2.1\r
5  *******************************************************************************\r
6  * @section License\r
7  * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>\r
8  *******************************************************************************\r
9  *\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
13  *\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
19  *\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
26  *\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
30  *\r
31  ******************************************************************************/\r
32 \r
33 #ifndef __SILICON_LABS_EM_PRS_H__\r
34 #define __SILICON_LABS_EM_PRS_H__\r
35 \r
36 #include "em_device.h"\r
37 #if defined(PRS_COUNT) && (PRS_COUNT > 0)\r
38 \r
39 #ifdef __cplusplus\r
40 extern "C" {\r
41 #endif\r
42 \r
43 /***************************************************************************//**\r
44  * @addtogroup EM_Library\r
45  * @{\r
46  ******************************************************************************/\r
47 \r
48 /***************************************************************************//**\r
49  * @addtogroup PRS\r
50  * @{\r
51  ******************************************************************************/\r
52 \r
53 /*******************************************************************************\r
54  ********************************   ENUMS   ************************************\r
55  ******************************************************************************/\r
56 \r
57 /** Edge detection type. */\r
58 typedef enum\r
59 {\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
64 } PRS_Edge_TypeDef;\r
65 \r
66 /*******************************************************************************\r
67  *****************************   PROTOTYPES   **********************************\r
68  ******************************************************************************/\r
69 \r
70 /***************************************************************************//**\r
71  * @brief\r
72  *   Set level control bit for one or more channels.\r
73  *\r
74  * @details\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
77  *\r
78  * @param[in] level\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
81  *\r
82  * @param[in] mask\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
87 {\r
88   PRS->SWLEVEL = (PRS->SWLEVEL & ~mask) | (level & mask);\r
89 }\r
90 \r
91 \r
92 /***************************************************************************//**\r
93  * @brief\r
94  *   Trigger a high pulse (one HFPERCLK) for one or more channels.\r
95  *\r
96  * @details\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
100  *   channel(s).\r
101  *\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
107 {\r
108   PRS->SWPULSE = channels & _PRS_SWPULSE_MASK;\r
109 }\r
110 \r
111 void PRS_SourceSignalSet(unsigned int ch,\r
112                          uint32_t source,\r
113                          uint32_t signal,\r
114                          PRS_Edge_TypeDef edge);\r
115 \r
116 #if defined( PRS_CH_CTRL_ASYNC )\r
117 void PRS_SourceAsyncSignalSet(unsigned int ch,\r
118                               uint32_t source,\r
119                               uint32_t signal);\r
120 #endif\r
121 \r
122 /** @} (end addtogroup PRS) */\r
123 /** @} (end addtogroup EM_Library) */\r
124 \r
125 #ifdef __cplusplus\r
126 }\r
127 #endif\r
128 \r
129 #endif /* defined(PRS_COUNT) && (PRS_COUNT > 0) */\r
130 #endif /* __SILICON_LABS_EM_PRS_H__ */\r