📄 main.c
字号:
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
* File Name : main.c
* Author : MCD Application Team
* Date First Issued : 07/17/2006
* Description : Main program body
********************************************************************************
* History:
* 07/17/2006 : V1.0
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "75x_lib.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
TIM_InitTypeDef TIM_InitStructure;
ErrorStatus OSC4MStartUpStatus;
/* Private function prototypes -----------------------------------------------*/
void GPIO_Configuration(void);
void MRCC_Configuration(void);
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void main()
{
#ifdef DEBUG
debug();
#endif
/* MRCC Configuration */
MRCC_Configuration();
/* GPIO Configuration */
GPIO_Configuration();
/* TIM1 configuration in Encoder mode */
TIM_InitStructure.TIM_Mode = TIM_Mode_Encoder3;
TIM_InitStructure.TIM_Prescaler = 0x1;
TIM_InitStructure.TIM_ClockSource = TIM_ClockSource_Internal;
TIM_InitStructure.TIM_Period = 0xFFFF;
TIM_InitStructure.TIM_IC1Selection = TIM_IC1Selection_TI1;
TIM_InitStructure.TIM_IC1Polarity = TIM_IC1Polarity_Falling;
TIM_InitStructure.TIM_IC2Selection = TIM_IC2Selection_TI2;
TIM_InitStructure.TIM_IC2Polarity = TIM_IC2Polarity_Falling;
TIM_Init(TIM1, &TIM_InitStructure);
/* Enable the TIM1 counter */
TIM_Cmd(TIM1, ENABLE);
while(1);
}
/*******************************************************************************
* Function Name : MRCC_Configuration
* Description : Configures the different system clocks.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void MRCC_Configuration(void)
{
/* MRCC system reset(for debug purpose) */
MRCC_DeInit();
/* Wait for OSC4M start-up */
OSC4MStartUpStatus = MRCC_WaitForOSC4MStartUp();
if(OSC4MStartUpStatus == SUCCESS)
{
/* Set HCLK to 60 MHz */
MRCC_HCLKConfig(MRCC_CKSYS_Div1);
/* Set CKTIM to 60 MHz */
MRCC_CKTIMConfig(MRCC_HCLK_Div1);
/* Set PCLK to 30 MHz */
MRCC_PCLKConfig(MRCC_CKTIM_Div2);
/* Enable Flash burst mode */
CFG_FLASHBurstConfig(CFG_FLASHBurst_Enable);
/* Set CKSYS to 60 MHz */
MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_15);
}
/* GPIO pins optimized for 3V3 operation */
MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3);
/* Enable GPIO and TIM1 clock */
MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO | MRCC_Peripheral_TIM1, ENABLE);
}
/*******************************************************************************
* Function Name : GPIO_Configuration
* Description : Configures the used GPIO ports.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* TIM1_TI1(P0.29) and TIM1_TI2(P0.31) pins configuration */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_29 | GPIO_Pin_31;
GPIO_Init(GPIO0, &GPIO_InitStructure);
}
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -