]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/emlib/inc/em_prs.h
Add EFM32 Giant Gecko Starter Kit demo - still a work in progress as the low power...
[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.0.0\r
5  *******************************************************************************\r
6  * @section License\r
7  * <b>(C) Copyright 2014 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 \r
34 #ifndef __SILICON_LABS_EM_PRS_H_\r
35 #define __SILICON_LABS_EM_PRS_H_\r
36 \r
37 #include "em_device.h"\r
38 #if defined(PRS_COUNT) && (PRS_COUNT > 0)\r
39 \r
40 #ifdef __cplusplus\r
41 extern "C" {\r
42 #endif\r
43 \r
44 /***************************************************************************//**\r
45  * @addtogroup EM_Library\r
46  * @{\r
47  ******************************************************************************/\r
48 \r
49 /***************************************************************************//**\r
50  * @addtogroup PRS\r
51  * @{\r
52  ******************************************************************************/\r
53 \r
54 /*******************************************************************************\r
55  ********************************   ENUMS   ************************************\r
56  ******************************************************************************/\r
57 \r
58 /** Edge detection type. */\r
59 typedef enum\r
60 {\r
61   prsEdgeOff  = PRS_CH_CTRL_EDSEL_OFF,      /**< Leave signal as is. */\r
62   prsEdgePos  = PRS_CH_CTRL_EDSEL_POSEDGE,  /**< Generate pules on positive edge. */\r
63   prsEdgeNeg  = PRS_CH_CTRL_EDSEL_NEGEDGE,  /**< Generate pules on negative edge. */\r
64   prsEdgeBoth = PRS_CH_CTRL_EDSEL_BOTHEDGES /**< Generate pules on both edges. */\r
65 } PRS_Edge_TypeDef;\r
66 \r
67 /*******************************************************************************\r
68  *****************************   PROTOTYPES   **********************************\r
69  ******************************************************************************/\r
70 \r
71 /***************************************************************************//**\r
72  * @brief\r
73  *   Set level control bit for one or more channels.\r
74  *\r
75  * @details\r
76  *   The level value for a channel is XORed with both the pulse possible issued\r
77  *   by PRS_PulseTrigger() and the PRS input signal selected for the channel(s).\r
78  *\r
79  * @param[in] level\r
80  *   Level to use for channels indicated by @p mask. Use logical OR combination\r
81  *   of PRS_SWLEVEL_CHnLEVEL defines for channels to set high level, otherwise 0.\r
82  *\r
83  * @param[in] mask\r
84  *   Mask indicating which channels to set level for. Use logical OR combination\r
85  *   of PRS_SWLEVEL_CHnLEVEL defines.\r
86  ******************************************************************************/\r
87 __STATIC_INLINE void PRS_LevelSet(uint32_t level, uint32_t mask)\r
88 {\r
89   PRS->SWLEVEL = (PRS->SWLEVEL & ~mask) | (level & mask);\r
90 }\r
91 \r
92 \r
93 /***************************************************************************//**\r
94  * @brief\r
95  *   Trigger a high pulse (one HFPERCLK) for one or more channels.\r
96  *\r
97  * @details\r
98  *   Setting a bit for a channel causes the bit in the register to remain high\r
99  *   for one HFPERCLK cycle. The pulse is XORed with both the corresponding bit\r
100  *   in PRS SWLEVEL register and the PRS input signal selected for the\r
101  *   channel(s).\r
102  *\r
103  * @param[in] channels\r
104  *   Logical ORed combination of channels to trigger a pulse for. Use\r
105  *   PRS_SWPULSE_CHnPULSE defines.\r
106  ******************************************************************************/\r
107 __STATIC_INLINE void PRS_PulseTrigger(uint32_t channels)\r
108 {\r
109   PRS->SWPULSE = channels & _PRS_SWPULSE_MASK;\r
110 }\r
111 \r
112 void PRS_SourceSignalSet(unsigned int ch,\r
113                          uint32_t source,\r
114                          uint32_t signal,\r
115                          PRS_Edge_TypeDef edge);\r
116 \r
117 #if defined( PRS_CH_CTRL_ASYNC )\r
118 void PRS_SourceAsyncSignalSet(unsigned int ch,\r
119                               uint32_t source,\r
120                               uint32_t signal);\r
121 #endif\r
122 \r
123 /** @} (end addtogroup PRS) */\r
124 /** @} (end addtogroup EM_Library) */\r
125 \r
126 #ifdef __cplusplus\r
127 }\r
128 #endif\r
129 \r
130 #endif /* defined(PRS_COUNT) && (PRS_COUNT > 0) */\r
131 #endif /* __SILICON_LABS_EM_PRS_H_ */\r