本文整理汇总了C++中TIMx_CLK_ENABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ TIMx_CLK_ENABLE函数的具体用法?C++ TIMx_CLK_ENABLE怎么用?C++ TIMx_CLK_ENABLE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIMx_CLK_ENABLE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HAL_TIM_PWM_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO Channels Clock */
TIMx_CHANNEL_GPIO_PORT();
/* Configure PA.05 (TIM2_Channel1), PB.03 (TIM2_Channel2), PB.10 (TIM2_Channel3),
PB.11 (TIM2_Channel4) in output, push-pull, alternate function mode
*/
/* Common configuration for all channels */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL1;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL2;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL2, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL3;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL3;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL3, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL4;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL4;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL4, &GPIO_InitStruct);
}
示例2: HAL_TIM_IC_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO channels Clock */
TIMx_CHANNEL_GPIO_PORT();
/* Configure (TIMx_Channel) in Alternate function, push-pull and 100MHz speed */
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF_TIMx;
HAL_GPIO_Init(GPIO_PORT, &GPIO_InitStruct);
/*##-2- Configure the NVIC for TIMx ########################################*/
/* Set the TIMx priority */
HAL_NVIC_SetPriority(TIMx_IRQn, 0, 1);
/* Enable the TIMx global Interrupt */
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
示例3: TIM_Config
/**
* @brief TIM_Config: Configure TIMusb timer
* @param None.
* @retval None
*/
static void TIM_Config(void)
{
/* Set TIMusb instance */
TimHandle.Instance = TIMusb;
/* Initialize TIMx peripheral as follow:
+ Period = 10000 - 1
+ Prescaler = ((SystemCoreClock/2)/10000) - 1
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Init.Period = (CDC_POLLING_INTERVAL*1000) - 1;
TimHandle.Init.Prescaler = 84-1;
TimHandle.Init.ClockDivision = 0;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-6- Enable TIM peripherals Clock #######################################*/
TIMx_CLK_ENABLE();
/*##-7- Configure the NVIC for TIMx ########################################*/
/* Set Interrupt Group Priority */
HAL_NVIC_SetPriority(TIMx_IRQn, 6, 0);
/* Enable the TIMx global Interrupt */
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
示例4: HAL_TIM_PWM_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable all GPIO Channels Clock requested */
TIMx_CHANNEL_GPIO_PORT();
/* Configure PC.06 (pin 9 (PC6) in CN10 connector) (TIM8_Channel1), PC.07 (pin 12 (RX) in CN7 connector) (TIM8_Channel2), PC.08 (pin 20 (D0) in CN6 connector) (TIM8_Channel3),
PC.09 (pin 19 (D1) in CN6 connector) (TIM8_Channel4) in output, push-pull, alternate function mode
*/
/* Common configuration for all channels */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL1;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL2;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL2, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL3;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL3;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL3, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL4;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL4;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL4, &GPIO_InitStruct);
}
示例5: HAL_TIM_PWM_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable all GPIO Channels Clock requested */
TIMx_CHANNEL_GPIO_PORT();
/* Configure PA.0 (On Eval Board, pin 31 on CN1 for example) (TIM2_Channel1), PA.1 (On Eval Board, pin 33 on CN1 for example) (TIM2_Channel2), PA.2 (On Eval Board, pin 34 on CN1 for example) (TIM2_Channel3),
PA.3 (On Eval Board, pin 58 on CN11 for example) (TIM2_Channel4) in output, push-pull, alternate function mode
*/
/* Common configuration for all channels */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL2, &GPIO_InitStruct);
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL3;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL3, &GPIO_InitStruct);
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL4;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL4, &GPIO_InitStruct);
}
示例6: HAL_TIM_OnePulse_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Enable the TIMx clock */
TIMx_CLK_ENABLE();
/* Enable GPIO Port Channel1 & channel2 Clock */
TIMx_CHANNEL1_GPIO_PORT();
TIMx_CHANNEL2_GPIO_PORT();
/* Configure PA.00 and PA.01 */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF_TIMx;
GPIO_InitStruct.Pull = GPIO_PUPD_CHANNEL1;
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CH1, &GPIO_InitStruct);
GPIO_InitStruct.Pull = GPIO_PUPD_CHANNEL2;
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT_CH2, &GPIO_InitStruct);
}
示例7: HAL_TIM_PWM_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* - DMA configuration for transmission request by peripheral
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
static DMA_HandleTypeDef hdma_tim;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO Channel3/3N Clocks */
TIMx_CHANNEL3_GPIOCLK_ENABLE();
TIMx_CHANNEL3N_GPIOCLK_ENABLE();
/* Enable DMA2 clock */
DMAx_CLK_ENABLE
/*##-2- Configure peripheral GPIO ##########################################*/
/* Configure TIM1_Channel3 & TIMx_Channel3N in output, push-pull &
alternate function mode */
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF_TIMx;
HAL_GPIO_Init(TIMx_GPIO_CHANNEL3_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL3N;
HAL_GPIO_Init(TIMx_GPIO_CHANNEL3N_PORT, &GPIO_InitStruct);
/*##-3- Configure the DMA stream ###########################################*/
/* Set the parameters to be configured */
hdma_tim.Init.Channel = DMA_CHANNEL_CC3;
hdma_tim.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tim.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_tim.Init.Mode = DMA_CIRCULAR;
hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE;
hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE;
/* Set hdma_tim instance */
hdma_tim.Instance = TIMx_CC3_DMA_STREAM;
/* Link hdma_tim to hdma[3] (channel3) */
__HAL_LINKDMA(htim, hdma[3], hdma_tim);
/* Initialize TIMx DMA handle */
HAL_DMA_Init(htim->hdma[3]);
/*##-4- Configure the NVIC for DMA #########################################*/
/* NVIC configuration for DMA transfer complete interrupt */
HAL_NVIC_SetPriority(TIMx_DMA_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIMx_DMA_IRQn);
}
示例8: HAL_TIM_IC_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
{
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Configure the NVIC for TIMx */
HAL_NVIC_SetPriority(TIMx_IRQn, 0, 0);
/* Enable the TIMx global Interrupt */
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
示例9: HAL_TIM_Base_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
/*##-1- Enable peripheral clock #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/*##-2- Configure the NVIC for TIMx ########################################*/
/* Set the TIMx priority */
HAL_NVIC_SetPriority(TIMx_IRQn, 3, 0);
/* Enable the TIMx global Interrupt */
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
示例10: HAL_TIM_Base_MspInit
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
#ifdef TIMn
if(htim->Instance == TIMx)
{
TIMx_CLK_ENABLE();
HAL_NVIC_SetPriority(TIMx_IRQn, 0xF, 0);
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
#endif
#ifdef ADC_TIMx
if(htim->Instance == ADC_TIMx)
{
ADC_TIMx_CLK_ENABLE();
HAL_NVIC_SetPriority(ADC_TIMx_IRQn, 0xF, 0);
HAL_NVIC_EnableIRQ(ADC_TIMx_IRQn);
}
#endif
#ifdef DAC_TIMx
if(htim->Instance == DAC_TIMx)
{
DAC_TIMx_CLK_ENABLE();
HAL_NVIC_SetPriority(DAC_TIMx_IRQn, 0xF, 0);
HAL_NVIC_EnableIRQ(DAC_TIMx_IRQn);
}
#endif
#ifdef PTP_TIMx
if(htim->Instance == PTP_TIMx)
{
PTP_TIMx_CLK_ENABLE();
HAL_NVIC_SetPriority(PTP_TIMx_IRQn, 0xF, 0);
HAL_NVIC_EnableIRQ(PTP_TIMx_IRQn);
}
#endif
#ifdef DISP_TIMx
if(htim->Instance == DISP_TIMx)
{
DISP_TIMx_CLK_ENABLE();
HAL_NVIC_SetPriority(DISP_TIMx_IRQn, 0xF, 0);
HAL_NVIC_EnableIRQ(DISP_TIMx_IRQn);
}
#endif
#ifdef USB_TIMx
if(htim->Instance == USB_TIMx)
{
USB_TIMx_CLK_ENABLE();
HAL_NVIC_SetPriority(USB_TIMx_IRQn, 0x5, 0);
HAL_NVIC_EnableIRQ(USB_TIMx_IRQn);
}
#endif
}
示例11: HAL_TIM_IC_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
if( htim->Instance == TIMx ){
TIMx_CLK_ENABLE();
TIMx_CHANNEL_GPIO_PORT();
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT ;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT ;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL2, &GPIO_InitStruct);
HAL_NVIC_SetPriority(TIMx_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}else if( htim->Instance == TIMx3 ){
TIMx3_CLK_ENABLE();
TIMx3_CHANNEL_GPIO_PORT_CLK();
/* Configure (TIMx_Channel)*/
GPIO_InitStruct.Pin = TIMx3_GPIO_PIN_CHANNEL1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT ;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init(TIMx3_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Pin = TIMx3_GPIO_PIN_CHANNEL4;
GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT ;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init(TIMx3_GPIO_PORT_CHANNEL4, &GPIO_InitStruct);
HAL_NVIC_SetPriority(TIMx3_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(TIMx3_IRQn);
SONAR_TRIG_PORT_CLK();
GPIO_InitStruct.Pin = SONAR_TRIG_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(SONAR_TRIG_PORT, &GPIO_InitStruct);
HAL_GPIO_WritePin(SONAR_TRIG_PORT, SONAR_TRIG_PIN, GPIO_PIN_RESET);
}
}
示例12: HAL_TIM_PWM_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* - DMA configuration for transmission request by peripheral
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
static DMA_HandleTypeDef hdma_tim;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO Channel3/3N Clocks */
TIMx_CHANNEL1_GPIO_CLK_ENABLE();
/* Enable DMA clock */
DMAx_CLK_ENABLE();
/* Configure TIM2_Channel1 in output, push-pull & alternate function mode */
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF_TIMx;
HAL_GPIO_Init(TIMx_GPIO_CHANNEL1_PORT, &GPIO_InitStruct);
/* Set the parameters to be configured */
hdma_tim.Init.Request = TIMx_CC1_DMA_REQUEST;
hdma_tim.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tim.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD ;
hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD ;
hdma_tim.Init.Mode = DMA_NORMAL;
hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
/* Set hdma_tim instance */
hdma_tim.Instance = TIMx_CC1_DMA_INST;
/* Link hdma_tim to hdma[TIM_DMA_ID_UPDATE] (update) */
__HAL_LINKDMA(htim, hdma[TIM_DMA_ID_UPDATE], hdma_tim);
/* Initialize TIMx DMA handle */
HAL_DMA_Init(htim->hdma[TIM_DMA_ID_UPDATE]);
/*##-2- Configure the NVIC for DMA #########################################*/
/* NVIC configuration for DMA transfer complete interrupt */
HAL_NVIC_SetPriority(TIMx_DMA_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIMx_DMA_IRQn);
}
示例13: HAL_TIM_Base_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* The used GPIO (LED2 port) will be configured in the main program through
LED2 initialization method */
/*##-2- Configure the NVIC for TIMx ########################################*/
/* Set the TIMx priority */
HAL_NVIC_SetPriority(TIMx_IRQn, 0, 0);
/* Enable the TIMx global Interrupt */
HAL_NVIC_EnableIRQ(TIMx_IRQn);
}
示例14: HAL_TIM_OC_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOB_CLK_ENABLE();
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIM1 Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO Channels Clock */
TIMx_CHANNEL_GPIO_PORT;
/*##-2- Configure I/Os #####################################################*/
/* Configure PA.08 (TIM1_Channel1), PA.09 (TIM1_Channel2), PA.10 (TIM1_Channel3),
PA.11 (TIM1_Channel4) in output, pull-up, alternate function mode
*/
/* Common configuration for all channels */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL1;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL2;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL2, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL3;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL3;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL3, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL4;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL4;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL4, &GPIO_InitStruct);
/* Configure PB.02 in output push-pull, gpio function mode */
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
示例15: HAL_TIM_OC_MspInit
/**
* @brief TIM MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param htim: TIM handle pointer
* @retval None
*/
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIM1 Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO Channels Clock */
TIMx_CHANNEL123_GPIO_PORT;
TIMx_CHANNEL4_GPIO_PORT;
/*##-2- Configure I/Os #####################################################*/
/* Configure PA.08 (TIM1_Channel1), PA.09 (TIM1_Channel2), PA.10 (TIM1_Channel3),
PE.14 (TIM1_Channel4) in output, pull-up, alternate function mode
*/
/* Common configuration for all channels */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL1;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL2;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL2, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL3;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL3;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL3, &GPIO_InitStruct);
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL4;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL4;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL4, &GPIO_InitStruct);
/*##-3- Enable the TIM2 global Interrupt & set priority ####################*/
HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
}