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