2 * @brief State Configurable Timer registers and control functions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __SCT_001_H_
\r
33 #define __SCT_001_H_
\r
35 #include "sys_config.h"
\r
42 /** @defgroup IP_SCT_001 IP: SCT register block and driver
\r
43 * @ingroup IP_Drivers
\r
44 * State Configurable Timer
\r
49 * @brief SCT Module configuration
\r
51 #define CONFIG_SCT_nEV (16) /*!< Number of events */
\r
52 #define CONFIG_SCT_nRG (16) /*!< Number of match/compare registers */
\r
53 #define CONFIG_SCT_nOU (16) /*!< Number of outputs */
\r
56 * @brief State Configurable Timer register block structure
\r
59 __IO uint32_t CONFIG; /*!< Configuration Register */
\r
61 __IO uint32_t CTRL_U; /*!< Control Register */
\r
63 __IO uint16_t CTRL_L; /*!< Low control register */
\r
64 __IO uint16_t CTRL_H; /*!< High control register */
\r
69 __IO uint16_t LIMIT_L; /*!< limit register for counter L */
\r
70 __IO uint16_t LIMIT_H; /*!< limit register for counter H */
\r
71 __IO uint16_t HALT_L; /*!< halt register for counter L */
\r
72 __IO uint16_t HALT_H; /*!< halt register for counter H */
\r
73 __IO uint16_t STOP_L; /*!< stop register for counter L */
\r
74 __IO uint16_t STOP_H; /*!< stop register for counter H */
\r
75 __IO uint16_t START_L; /*!< start register for counter L */
\r
76 __IO uint16_t START_H; /*!< start register for counter H */
\r
77 uint32_t RESERVED1[10]; /*!< 0x03C reserved */
\r
79 __IO uint32_t COUNT_U; /*!< counter register */
\r
81 __IO uint16_t COUNT_L; /*!< counter register for counter L */
\r
82 __IO uint16_t COUNT_H; /*!< counter register for counter H */
\r
87 __IO uint16_t STATE_L; /*!< state register for counter L */
\r
88 __IO uint16_t STATE_H; /*!< state register for counter H */
\r
89 __I uint32_t INPUT; /*!< input register */
\r
90 __IO uint16_t REGMODE_L; /*!< match - capture registers mode register L */
\r
91 __IO uint16_t REGMODE_H; /*!< match - capture registers mode register H */
\r
92 __IO uint32_t OUTPUT; /*!< output register */
\r
93 __IO uint32_t OUTPUTDIRCTRL; /*!< output counter direction Control Register */
\r
94 __IO uint32_t RES; /*!< conflict resolution register */
\r
95 __IO uint32_t DMA0REQUEST; /*!< DMA0 Request Register */
\r
96 __IO uint32_t DMA1REQUEST; /*!< DMA1 Request Register */
\r
97 uint32_t RESERVED2[35];
\r
98 __IO uint32_t EVEN; /*!< event enable register */
\r
99 __IO uint32_t EVFLAG; /*!< event flag register */
\r
100 __IO uint32_t CONEN; /*!< conflict enable register */
\r
101 __IO uint32_t CONFLAG; /*!< conflict flag register */
\r
103 __IO union { /*!< ... Match / Capture value */
\r
104 uint32_t U; /*!< SCTMATCH[i].U Unified 32-bit register */
\r
106 uint16_t L; /*!< SCTMATCH[i].L Access to L value */
\r
107 uint16_t H; /*!< SCTMATCH[i].H Access to H value */
\r
110 } MATCH[CONFIG_SCT_nRG];
\r
113 uint32_t U; /*!< SCTCAP[i].U Unified 32-bit register */
\r
115 uint16_t L; /*!< SCTCAP[i].L Access to L value */
\r
116 uint16_t H; /*!< SCTCAP[i].H Access to H value */
\r
119 } CAP[CONFIG_SCT_nRG];
\r
123 uint32_t RESERVED3[32 - CONFIG_SCT_nRG]; /*!< ...-0x17C reserved */
\r
125 __IO uint16_t MATCH_L[CONFIG_SCT_nRG]; /*!< 0x180-... Match Value L counter */
\r
126 __I uint16_t CAP_L[CONFIG_SCT_nRG]; /*!< 0x180-... Capture Value L counter */
\r
129 uint16_t RESERVED4[32 - CONFIG_SCT_nRG]; /*!< ...-0x1BE reserved */
\r
131 __IO uint16_t MATCH_H[CONFIG_SCT_nRG]; /*!< 0x1C0-... Match Value H counter */
\r
132 __I uint16_t CAP_H[CONFIG_SCT_nRG]; /*!< 0x1C0-... Capture Value H counter */
\r
135 uint16_t RESERVED5[32 - CONFIG_SCT_nRG]; /*!< ...-0x1FE reserved */
\r
137 __IO union { /*!< 0x200-... Match Reload / Capture Control value */
\r
138 uint32_t U; /*!< SCTMATCHREL[i].U Unified 32-bit register */
\r
140 uint16_t L; /*!< SCTMATCHREL[i].L Access to L value */
\r
141 uint16_t H; /*!< SCTMATCHREL[i].H Access to H value */
\r
144 } MATCHREL[CONFIG_SCT_nRG];
\r
147 uint32_t U; /*!< SCTCAPCTRL[i].U Unified 32-bit register */
\r
149 uint16_t L; /*!< SCTCAPCTRL[i].L Access to L value */
\r
150 uint16_t H; /*!< SCTCAPCTRL[i].H Access to H value */
\r
153 } CAPCTRL[CONFIG_SCT_nRG];
\r
157 uint32_t RESERVED6[32 - CONFIG_SCT_nRG]; /*!< ...-0x27C reserved */
\r
159 __IO uint16_t MATCHREL_L[CONFIG_SCT_nRG]; /*!< 0x280-... Match Reload value L counter */
\r
160 __IO uint16_t CAPCTRL_L[CONFIG_SCT_nRG]; /*!< 0x280-... Capture Control value L counter */
\r
163 uint16_t RESERVED7[32 - CONFIG_SCT_nRG]; /*!< ...-0x2BE reserved */
\r
165 __IO uint16_t MATCHREL_H[CONFIG_SCT_nRG]; /*!< 0x2C0-... Match Reload value H counter */
\r
166 __IO uint16_t CAPCTRL_H[CONFIG_SCT_nRG]; /*!< 0x2C0-... Capture Control value H counter */
\r
169 uint16_t RESERVED8[32 - CONFIG_SCT_nRG]; /*!< ...-0x2FE reserved */
\r
170 __IO struct { /*!< 0x300-0x3FC SCTEVENT[i].STATE / SCTEVENT[i].CTRL*/
\r
171 uint32_t STATE; /*!< Event State Register */
\r
172 uint32_t CTRL; /*!< Event Control Register */
\r
173 } EVENT[CONFIG_SCT_nEV];
\r
175 uint32_t RESERVED9[128 - 2 * CONFIG_SCT_nEV]; /*!< ...-0x4FC reserved */
\r
176 __IO struct { /*!< 0x500-0x57C SCTOUT[i].SET / SCTOUT[i].CLR */
\r
177 uint32_t SET; /*!< Output n Set Register */
\r
178 uint32_t CLR; /*!< Output n Clear Register */
\r
179 } OUT[CONFIG_SCT_nOU];
\r
181 uint32_t RESERVED10[191 - 2 * CONFIG_SCT_nOU]; /*!< ...-0x7F8 reserved */
\r
182 __I uint32_t MODULECONTENT; /*!< 0x7FC Module Content */
\r
186 * @brief Macro defines for SCT configuration register
\r
188 #define SCT_CONFIG_16BIT_COUNTER 0x00000000 /*!< Operate as 2 16-bit counters */
\r
189 #define SCT_CONFIG_32BIT_COUNTER 0x00000001 /*!< Operate as 1 32-bit counter */
\r
191 #define SCT_CONFIG_CLKMODE_BUSCLK (0x0 << 1) /*!< Bus clock */
\r
192 #define SCT_CONFIG_CLKMODE_SCTCLK (0x1 << 1) /*!< SCT clock */
\r
193 #define SCT_CONFIG_CLKMODE_INCLK (0x2 << 1) /*!< Input clock selected in CLKSEL field */
\r
194 #define SCT_CONFIG_CLKMODE_INEDGECLK (0x3 << 1) /*!< Input clock edge selected in CLKSEL field */
\r
196 #define SCT_CONFIG_NORELOADL_U (0x1 << 7) /*!< Operate as 1 32-bit counter */
\r
197 #define SCT_CONFIG_NORELOADH (0x1 << 8) /*!< Operate as 1 32-bit counter */
\r
200 * @brief Macro defines for SCT control register
\r
202 #define COUNTUP_TO_LIMIT_THEN_CLEAR_TO_ZERO 0 /*!< Direction for low or unified counter */
\r
203 #define COUNTUP_TO LIMIT_THEN_COUNTDOWN_TO_ZERO 1
\r
205 #define SCT_CTRL_STOP_L (1 << 1) /*!< Stop low counter */
\r
206 #define SCT_CTRL_HALT_L (1 << 2) /*!< Halt low counter */
\r
207 #define SCT_CTRL_CLRCTR_L (1 << 3) /*!< Clear low or unified counter */
\r
208 #define SCT_CTRL_BIDIR_L(x) (((x) & 0x01) << 4) /*!< Bidirectional bit */
\r
209 #define SCT_CTRL_PRE_L(x) (((x) & 0xFF) << 5) /*!< Prescale clock for low or unified counter */
\r
211 #define COUNTUP_TO_LIMIT_THEN_CLEAR_TO_ZERO 0 /*!< Direction for high counter */
\r
212 #define COUNTUP_TO LIMIT_THEN_COUNTDOWN_TO_ZERO 1
\r
213 #define SCT_CTRL_STOP_H (1 << 17) /*!< Stop high counter */
\r
214 #define SCT_CTRL_HALT_H (1 << 18) /*!< Halt high counter */
\r
215 #define SCT_CTRL_CLRCTR_H (1 << 19) /*!< Clear high counter */
\r
216 #define SCT_CTRL_BIDIR_H(x) (((x) & 0x01) << 20)
\r
217 #define SCT_CTRL_PRE_H(x) (((x) & 0xFF) << 21) /*!< Prescale clock for high counter */
\r
220 * @brief Macro defines for SCT Conflict resolution register
\r
222 #define SCT_RES_NOCHANGE (0)
\r
223 #define SCT_RES_SET_OUTPUT (1)
\r
224 #define SCT_RES_CLEAR_OUTPUT (2)
\r
225 #define SCT_RES_TOGGLE_OUTPUT (3)
\r
228 * @brief Set the value in SCT unified count register
\r
229 * @param pSCT : Pointer to SCT register block
\r
230 * @param count : SCT count value
\r
232 * @note Writes 32-bit value into SCT unified count register
\r
234 STATIC INLINE void IP_SCT_SetCount(IP_SCT_001_T *pSCT, uint32_t count)
\r
236 pSCT->COUNT_U = count;
\r
240 * @brief Set the value in SCT Lower count register
\r
241 * @param pSCT : Pointer to SCT register block
\r
242 * @param count : SCT count value
\r
244 * @note Writes 16-bit value into SCT Lower count register
\r
246 STATIC INLINE void IP_SCT_SetCountL(IP_SCT_001_T *pSCT, uint16_t count)
\r
248 pSCT->COUNT_L = count;
\r
252 * @brief Set the value in SCT Higher count register
\r
253 * @param pSCT : Pointer to SCT register block
\r
254 * @param count : SCT count value
\r
256 * @note Writes 16-bit value into SCT Higher count register
\r
258 STATIC INLINE void IP_SCT_SetCountH(IP_SCT_001_T *pSCT, uint16_t count)
\r
260 pSCT->COUNT_H = count;
\r
264 * @brief Set the match value in SCT Unified match register
\r
265 * @param pSCT : Pointer to SCT register block
\r
266 * @param n : Match register number
\r
267 * @param count : SCT match count value
\r
269 * @note Writes 32-bit value into SCT unified match register
\r
271 STATIC INLINE void IP_SCT_SetMatchCount(IP_SCT_001_T *pSCT, uint32_t n, uint32_t count)
\r
273 pSCT->MATCH[n].U = count;
\r
277 * @brief Set the match reload value in SCT Unified match reload register
\r
278 * @param pSCT : Pointer to SCT register block
\r
279 * @param n : Match register number
\r
280 * @param count : SCT match reload count value
\r
283 STATIC INLINE void IP_SCT_SetMatchReload(IP_SCT_001_T *pSCT, uint32_t n, uint32_t count)
\r
285 pSCT->MATCHREL[n].U = count;
\r
289 * @brief Enable the interrupt for the specified event
\r
290 * @param pSCT : Pointer to SCT register block
\r
291 * @param evt : Event value
\r
294 STATIC INLINE void IP_SCT_EventIntEnable(IP_SCT_001_T *pSCT, uint32_t evt)
\r
300 * @brief Disable the interrupt for the specified event
\r
301 * @param pSCT : Pointer to SCT register block
\r
302 * @param evt : Event value
\r
305 STATIC INLINE void IP_SCT_EventIntDisable(IP_SCT_001_T *pSCT, uint32_t evt)
\r
307 pSCT->EVEN &= ~(evt);
\r
311 * @brief Clear the specified event flag
\r
312 * @param pSCT : Pointer to SCT register block
\r
313 * @param evt : Event value
\r
316 STATIC INLINE void IP_SCT_ClearEventFlag(IP_SCT_001_T *pSCT, uint32_t evt)
\r
318 pSCT->EVFLAG |= evt;
\r
322 * @brief Configure SCT
\r
323 * @param pSCT : Pointer to SCT register block
\r
324 * @param value : SCT Configuration register value
\r
326 * @note Initialise the SCT configuration register with the \a value
\r
328 void IP_SCT_Config(IP_SCT_001_T *pSCT, uint32_t value);
\r
331 * @brief Set or Clear the Control register
\r
332 * @param pSCT : Pointer to SCT register block
\r
333 * @param value : SCT Control register value
\r
334 * @param ena : ENABLE - To set the fields specified by value
\r
335 * : DISABLE - To clear the field specified by value
\r
337 * @note Set or clear the control register bits as specified by \a value.
\r
338 * If \a ena is set to ENABLE, the mentioned register fields
\r
339 * will be set. If a\ ena is set to DISABLE, the mentioned register
\r
340 * fields will be cleared
\r
342 void IP_SCT_ControlSetClr(IP_SCT_001_T *pSCT, uint32_t value, FunctionalState ena);
\r
345 * @brief Set the conflict resolution
\r
346 * @param pSCT : Pointer to SCT register block
\r
347 * @param outnum : Output number
\r
348 * @param value : Output value
\r
349 * - SCT_RES_NOCHANGE :No change
\r
350 * - SCT_RES_SET_OUTPUT :Set output
\r
351 * - SCT_RES_CLEAR_OUTPUT :Clear output
\r
352 * - SCT_RES_TOGGLE_OUTPUT :Toggle output
\r
353 * : SCT_RES_NOCHANGE
\r
354 * : DISABLE - To clear the field specified by value
\r
356 * @note Set conflict resolution value for the output \a outnum
\r
358 void IP_SCT_ConflictResolutionSet(IP_SCT_001_T *pSCT, uint8_t outnum, uint8_t value);
\r
361 * @brief Clear the SCT event flag
\r
362 * @param pSCT : Pointer to SCT register block
\r
363 * @param even_num : SCT Event number
\r
365 * @note Clear the SCT event flag for the event \a even_num
\r
367 void IP_SCT_EventFlagClear(IP_SCT_001_T *pSCT, uint8_t even_num);
\r
377 #endif /* __SCT_001_H_ */
\r