Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
2 | * File Name : 91x_tim.h |
||
3 | * Author : MCD Application Team |
||
4 | * Date First Issued : 05/18/2006 : Version 1.0 |
||
5 | * Description : This file contains all the functions prototypes for the |
||
6 | * TIM software library. |
||
7 | ******************************************************************************** |
||
8 | * History: |
||
9 | * 05/22/2007 : Version 1.2 |
||
10 | * 05/24/2006 : Version 1.1 |
||
11 | * 05/18/2006 : Version 1.0 |
||
12 | ******************************************************************************** |
||
13 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH |
||
14 | * CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS |
||
15 | * A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT |
||
16 | * OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT |
||
17 | * OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION |
||
18 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
19 | *******************************************************************************/ |
||
20 | |||
21 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
22 | #ifndef __91x_TIM_H |
||
23 | #define __91x_TIM_H |
||
24 | |||
25 | /* Includes ------------------------------------------------------------------*/ |
||
26 | #include "91x_map.h" |
||
27 | #include "91x_scu.h" |
||
28 | |||
29 | /* Exported types ----------------------------------------------------------- */ |
||
30 | |||
31 | /* TIM Init structure define */ |
||
32 | typedef struct |
||
33 | { |
||
34 | u16 TIM_Mode; /* Timer mode */ |
||
35 | u16 TIM_OC1_Modes; /* Output Compare 1 Mode: Timing or Wave */ |
||
36 | u16 TIM_OC2_Modes; /* Output Compare 2 Mode: Timing or Wave */ |
||
37 | u16 TIM_Clock_Source; /* Timer Clock source APB/SCU/EXTERNAL */ |
||
38 | u16 TIM_Clock_Edge; /* Timer Clock Edge: Rising or Falling Edge */ |
||
39 | u16 TIM_OPM_INPUT_Edge; /* Timer Input Capture 1 Edge used in OPM Mode */ |
||
40 | u16 TIM_ICAP1_Edge; /* Timer Input Capture 1 Edge used in ICAP1 Mode */ |
||
41 | u16 TIM_ICAP2_Edge; /* Timer Input Capture 2 Edge used in ICAP2 Mode */ |
||
42 | u8 TIM_Prescaler; /* Timer Prescaler factor */ |
||
43 | u16 TIM_Pulse_Level_1; /* Level applied on the Output Compare Pin 1 */ |
||
44 | u16 TIM_Pulse_Level_2; /* Level applied on the Output Compare Pin 2 */ |
||
45 | u16 TIM_Period_Level; /* Level applied during the Period of a PWM Mode */ |
||
46 | u16 TIM_Pulse_Length_1; /* Pulse 1 Length used in Output Compare 1 Mode */ |
||
47 | u16 TIM_Pulse_Length_2; /* Pulse 2 Length used in Output Compare 2 Mode */ |
||
48 | u16 TIM_Full_Period; /* Period Length used in PWM Mode */ |
||
49 | } TIM_InitTypeDef; |
||
50 | |||
51 | typedef enum |
||
52 | { |
||
53 | TIM_START, |
||
54 | TIM_STOP, |
||
55 | TIM_CLEAR |
||
56 | } TIM_CounterOperations; |
||
57 | |||
58 | /* Exported constants --------------------------------------------------------*/ |
||
59 | |||
60 | /* TIM MODE */ |
||
61 | #define TIM_PWMI 0x4000 /* PWM INPUT Mode */ |
||
62 | #define TIM_OCM_CHANNEL_1 0x0040 /* OUTPUT COMPARE CHANNEL 1 Mode */ |
||
63 | #define TIM_OCM_CHANNEL_2 0x0080 /* OUTPUT COMPARE CHANNEL 2 Mode */ |
||
64 | #define TIM_OCM_CHANNEL_12 0x00C0 /* OUTPUT COMPARE CHANNEL 1 & 2 Mode */ |
||
65 | #define TIM_PWM 0x0010 /* PWM Mode */ |
||
66 | #define TIM_OPM 0x0020 /* ONE PULSE Mode */ |
||
67 | #define TIM_ICAP_CHANNEL_1 0x0400 /* INPUT CAPTURE 1 Mode */ |
||
68 | #define TIM_ICAP_CHANNEL_2 0x0500 /* INPUT CAPTURE 2 Mode */ |
||
69 | #define TIM_ICAP_CHANNEL_12 0x0600 /* INPUT CAPTURE 1 & 2 Mode */ |
||
70 | |||
71 | /* TIM OUTPUT COMPARE MODE */ |
||
72 | #define TIM_WAVE 0x0001 |
||
73 | #define TIM_TIMING 0x0002 |
||
74 | |||
75 | /* TIM CLOCK SOURCE */ |
||
76 | #define TIM_CLK_APB 0xFFFE |
||
77 | #define TIM_CLK_EXTERNAL 0x0001 |
||
78 | #define TIM_CLK_SCU 0x0001 |
||
79 | |||
80 | /* TIM CLOCK EDGE */ |
||
81 | #define TIM_CLK_EDGE_FALLING 0xFFFD |
||
82 | #define TIM_CLK_EDGE_RISING 0x0002 |
||
83 | |||
84 | /* TIM OPM INPUT EDGE */ |
||
85 | #define TIM_OPM_EDGE_FALLING 0xFFFB |
||
86 | #define TIM_OPM_EDGE_RISING 0x0004 |
||
87 | |||
88 | /* TIM ICAPA INPUT EDGE */ |
||
89 | #define TIM_ICAP1_EDGE_FALLING 0xFFFB |
||
90 | #define TIM_ICAP1_EDGE_RISING 0x0004 |
||
91 | |||
92 | /* TIM ICAPB INPUT EDGE */ |
||
93 | #define TIM_ICAP2_EDGE_FALLING 0xFFF7 |
||
94 | #define TIM_ICAP2_EDGE_RISING 0x0008 |
||
95 | |||
96 | /* TIM OUTPUT LEVEL */ |
||
97 | #define TIM_HIGH 0x0200 |
||
98 | #define TIM_LOW 0x0300 |
||
99 | |||
100 | /* TIM OUTPUT EDGE */ |
||
101 | #define TIM_OUTPUT_EDGE_RISING 0x8000 |
||
102 | #define TIM_OUTPUT_EDGE_FALLING 0x0800 |
||
103 | |||
104 | /* TIM channels */ |
||
105 | #define TIM_PWM_OC1_Channel 0x1 /* PWM/Output Compare 1 Channel */ |
||
106 | #define TIM_OC2_Channel 0x2 /* Output Compare 2 Channel */ |
||
107 | |||
108 | /* TIM DMA SOURCE */ |
||
109 | #define TIM_DMA_IC1 0x0000 /* Input Capture Channel 1 DMA Source */ |
||
110 | #define TIM_DMA_OC1 0x1000 /* OUTPUT Compare Channel 1 DMA Source */ |
||
111 | #define TIM_DMA_IC2 0x2000 /* Input Capture Channel 2 DMA Source */ |
||
112 | #define TIM_DMA_OC2 0x3000 /* OUTPUT Compare Channel 2 DMA Source */ |
||
113 | |||
114 | /* TIM DMA ENABLE or DISABLE */ |
||
115 | #define TIM_DMA_ENABLE 0x0400 /* DMA Enable */ |
||
116 | #define TIM_DMA_DISABLE 0xFBFF /* DMA Disable */ |
||
117 | |||
118 | /* TIM Interruption Sources*/ |
||
119 | #define TIM_IT_IC1 0x8000 /* Input Capture Channel 1 Interrupt Source */ |
||
120 | #define TIM_IT_OC1 0x4000 /* Output Compare Channel 1 Interrupt Source */ |
||
121 | #define TIM_IT_TO 0x2000 /* Timer OverFlow Interrupt Source */ |
||
122 | #define TIM_IT_IC2 0x1000 /* Input Capture Channel 2 Interrupt Source */ |
||
123 | #define TIM_IT_OC2 0x0800 /* Output Compare Channel 2 Interrupt Source */ |
||
124 | |||
125 | /* TIM Flags */ |
||
126 | #define TIM_FLAG_IC1 0x8000 /* Input Capture Channel 1 Flag */ |
||
127 | #define TIM_FLAG_OC1 0x4000 /* Output Compare Channel 1 Flag */ |
||
128 | #define TIM_FLAG_TO 0x2000 /* Timer OverFlow Flag */ |
||
129 | #define TIM_FLAG_IC2 0x1000 /* Input Capture Channel 2 Flag */ |
||
130 | #define TIM_FLAG_OC2 0x0800 /* Output Compare Channel 2 Flag */ |
||
131 | |||
132 | /* Module private variables --------------------------------------------------*/ |
||
133 | /* Exported macro ------------------------------------------------------------*/ |
||
134 | /* Private functions ---------------------------------------------------------*/ |
||
135 | /* Exported functions ------------------------------------------------------- */ |
||
136 | void TIM_Init(TIM_TypeDef *TIMx, TIM_InitTypeDef *TIM_InitStruct); |
||
137 | void TIM_DeInit(TIM_TypeDef *TIMx); |
||
138 | void TIM_StructInit(TIM_InitTypeDef *TIM_InitStruct); |
||
139 | void TIM_CounterCmd(TIM_TypeDef *TIMx, TIM_CounterOperations TIM_operation); |
||
140 | void TIM_PrescalerConfig(TIM_TypeDef *TIMx, u8 TIM_Prescaler); |
||
141 | u8 TIM_GetPrescalerValue(TIM_TypeDef *TIMx); |
||
142 | u16 TIM_GetCounterValue(TIM_TypeDef *TIMx); |
||
143 | u16 TIM_GetICAP1Value(TIM_TypeDef *TIMx); |
||
144 | u16 TIM_GetICAP2Value(TIM_TypeDef *TIMx); |
||
145 | void TIM_SetPulse(TIM_TypeDef *TIMx,u16 TIM_Channel ,u16 TIM_Pulse); |
||
146 | FlagStatus TIM_GetFlagStatus(TIM_TypeDef *TIMx, u16 TIM_Flag); |
||
147 | void TIM_ClearFlag(TIM_TypeDef *TIMx, u16 TIM_Flag); |
||
148 | u16 TIM_GetPWMIPulse(TIM_TypeDef *TIMx); |
||
149 | u16 TIM_GetPWMIPeriod(TIM_TypeDef *TIMx); |
||
150 | void TIM_ITConfig(TIM_TypeDef *TIMx, u16 TIM_IT, FunctionalState TIM_Newstate); |
||
151 | void TIM_DMAConfig(TIM_TypeDef *TIMx, u16 TIM_DMA_Sources); |
||
152 | void TIM_DMACmd(TIM_TypeDef *TIMx, FunctionalState TIM_Newstate); |
||
153 | |||
154 | #endif /* __91x_TIM_H */ |
||
155 | |||
156 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |