1 /**********************************************************************
\r
2 * $Id$ lpc18xx_sct.h 2011-06-02
\r
4 * @file lpc18xx_sct.h
\r
5 * @brief Contains all macro definitions and function prototypes
\r
6 * support for SCT firmware library on LPC18xx
\r
8 * @date 02. June. 2011
\r
9 * @author NXP MCU SW Application Team
\r
11 * Copyright(C) 2011, NXP Semiconductor
\r
12 * All rights reserved.
\r
14 ***********************************************************************
\r
15 * Software that is described herein is for illustrative purposes only
\r
16 * which provides customers with programming information regarding the
\r
17 * products. This software is supplied "AS IS" without any warranties.
\r
18 * NXP Semiconductors assumes no responsibility or liability for the
\r
19 * use of the software, conveys no license or title under any patent,
\r
20 * copyright, or mask work right to the product. NXP Semiconductors
\r
21 * reserves the right to make changes in the software without
\r
22 * notification. NXP Semiconductors also make no representation or
\r
23 * warranty that such application will be suitable for the specified
\r
24 * use without further testing or modification.
\r
25 **********************************************************************/
\r
27 /* Peripheral group ----------------------------------------------------------- */
\r
28 /** @defgroup SCT SCT (State Configurable Timer)
\r
29 * @ingroup LPC1800CMSIS_FwLib_Drivers
\r
33 #ifndef LPC18XX_SCT_H_
\r
34 #define LPC18XX_SCT_H_
\r
36 /* Includes ------------------------------------------------------------------- */
\r
37 #include "LPC18xx.h"
\r
38 #include "lpc_types.h"
\r
46 /* Private macros ------------------------------------------------------------- */
\r
47 /** @defgroup SCT_Private_Macros SCT Private Macros
\r
51 /* -------------------------- BIT DEFINITIONS ----------------------------------- */
\r
52 /*********************************************************************//**
\r
53 * Macro defines for SCT configuration register
\r
54 **********************************************************************/
\r
55 /** Selects 16/32 bit counter */
\r
56 #define SCT_CONFIG_16BIT_COUNTER 0x00000000
\r
57 #define SCT_CONFIG_32BIT_COUNTER 0x00000001
\r
59 /*********************************************************************//**
\r
60 * Macro defines for SCT control register
\r
61 **********************************************************************/
\r
62 /** Stop low counter */
\r
63 #define SCT_CTRL_STOP_L (1<<1)
\r
64 /** Halt low counter */
\r
65 #define SCT_CTRL_HALT_L (1<<2)
\r
66 /** Clear low or unified counter */
\r
67 #define SCT_CTRL_CLRCTR_L (1<<3)
\r
68 /** Direction for low or unified counter */
\r
69 #define COUNTUP_TO_LIMIT_THEN_CLEAR_TO_ZERO 0
\r
70 #define COUNTUP_TO LIMIT_THEN_COUNTDOWN_TO_ZERO 1
\r
71 #define SCT_CTRL_BIDIR_L(x) (((x)&0x01)<<4)
\r
72 /** Prescale clock for low or unified counter */
\r
73 #define SCT_CTRL_PRE_L(x) (((x)&0xFF)<<5)
\r
75 /** Stop high counter */
\r
76 #define SCT_CTRL_STOP_H (1<<17)
\r
77 /** Halt high counter */
\r
78 #define SCT_CTRL_HALT_H (1<<18)
\r
79 /** Clear high counter */
\r
80 #define SCT_CTRL_CLRCTR_H (1<<19)
\r
81 /** Direction for high counter */
\r
82 #define COUNTUP_TO_LIMIT_THEN_CLEAR_TO_ZERO 0
\r
83 #define COUNTUP_TO LIMIT_THEN_COUNTDOWN_TO_ZERO 1
\r
84 #define SCT_CTRL_BIDIR_H(x) (((x)&0x01)<<20)
\r
85 /** Prescale clock for high counter */
\r
86 #define SCT_CTRL_PRE_H(x) (((x)&0xFF)<<21)
\r
87 /*********************************************************************//**
\r
88 * Macro defines for SCT Conflict resolution register
\r
89 **********************************************************************/
\r
90 /** Define conflict solution */
\r
91 #define SCT_RES_NOCHANGE (0)
\r
92 #define SCT_RES_SET_OUTPUT (1)
\r
93 #define SCT_RES_CLEAR_OUTPUT (2)
\r
94 #define SCT_RES_TOGGLE_OUTPUT (3)
\r
96 /* ------------------- CHECK PARAM DEFINITIONS ------------------------- */
\r
97 /** Check SCT output number */
\r
98 #define PARAM_SCT_OUTPUT_NUM(n) ((n)<= CONFIG_SCT_nOU )
\r
100 /** Check SCT counter type */
\r
101 #define PARAM_SCT_CONFIG_COUNTER_TYPE(n) ((n==SCT_CONFIG_16BIT_COUNTER)||(n==SCT_CONFIG_32BIT_COUNTER))
\r
103 /** Check SCT conflict solution */
\r
104 #define PARAM_SCT_RES(n) ((n==SCT_RES_NOCHANGE)||(n==SCT_RES_SET_OUTPUT)\
\r
105 ||(n==SCT_RES_CLEAR_OUTPUT)||(n==SCT_RES_TOGGLE_OUTPUT))
\r
107 /** Check SCT event number */
\r
108 #define PARAM_SCT_EVENT(n) ((n) <= 15)
\r
116 /* Public Functions ----------------------------------------------------------- */
\r
117 /** @defgroup SCT_Public_Functions SCT Public Functions
\r
121 void SCT_Config(uint32_t value);
\r
122 void SCT_ControlSet(uint32_t value, FunctionalState ena);
\r
123 void SCT_ConflictResolutionSet(uint8_t outnum, uint8_t value);
\r
124 void SCT_EventFlagClear(uint8_t even_num);
\r
136 #endif /* LPC18XX_SCT_H_ */
\r
142 /* --------------------------------- End Of File ------------------------------ */
\r