• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GPIO_PinRemapConfig函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GPIO_PinRemapConfig函数的典型用法代码示例。如果您正苦于以下问题:C++ GPIO_PinRemapConfig函数的具体用法?C++ GPIO_PinRemapConfig怎么用?C++ GPIO_PinRemapConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GPIO_PinRemapConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PIOS_USART_Init

/**
* Initialise a single USART device
*/
int32_t PIOS_USART_Init(uint32_t * usart_id, const struct pios_usart_cfg * cfg)
{
	PIOS_DEBUG_Assert(usart_id);
	PIOS_DEBUG_Assert(cfg);

	struct pios_usart_dev * usart_dev;

	usart_dev = (struct pios_usart_dev *) PIOS_USART_alloc();
	if (!usart_dev) goto out_fail;

	/* Bind the configuration to the device instance */
	usart_dev->cfg = cfg;

	/* Clear buffer counters */
	fifoBuf_init(&usart_dev->rx, usart_dev->rx_buffer, sizeof(usart_dev->rx_buffer));
	fifoBuf_init(&usart_dev->tx, usart_dev->tx_buffer, sizeof(usart_dev->tx_buffer));

	/* Enable the USART Pins Software Remapping */
	if (usart_dev->cfg->remap) {
		GPIO_PinRemapConfig(usart_dev->cfg->remap, ENABLE);
	}

	/* Initialize the USART Rx and Tx pins */
	GPIO_Init(usart_dev->cfg->rx.gpio, &usart_dev->cfg->rx.init);
	GPIO_Init(usart_dev->cfg->tx.gpio, &usart_dev->cfg->tx.init);

	/* Enable USART clock */
	switch ((uint32_t)usart_dev->cfg->regs) {
	case (uint32_t)USART1:
		RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
		break;
	case (uint32_t)USART2:
		RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
		break;
	case (uint32_t)USART3:
		RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
		break;
	}
  
	/* Configure the USART */
	USART_Init(usart_dev->cfg->regs, &usart_dev->cfg->init);
  
	*usart_id = (uint32_t)usart_dev;

	/* Configure USART Interrupts */
	NVIC_Init(&usart_dev->cfg->irq.init);
	USART_ITConfig(usart_dev->cfg->regs, USART_IT_RXNE, ENABLE);
	USART_ITConfig(usart_dev->cfg->regs, USART_IT_TXE,  ENABLE);
  
	/* Enable USART */
	USART_Cmd(usart_dev->cfg->regs, ENABLE);

	return(0);

out_fail:
	return(-1);
}
开发者ID:gotosteven,项目名称:my_OpenPilot_mods,代码行数:60,代码来源:pios_usart.c


示例2: systemInit

void systemInit(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    uint8_t i;

    gpio_config_t gpio_cfg[] = {
        { LED0_GPIO, LED0_PIN, GPIO_Mode_Out_PP }, // PB3 (LED)
        { LED1_GPIO, LED1_PIN, GPIO_Mode_Out_PP }, // PB4 (LED)
#ifndef FY90Q
        { BEEP_GPIO, BEEP_PIN, GPIO_Mode_Out_OD }, // PA12 (Buzzer)
#endif
    };
    uint8_t gpio_count = sizeof(gpio_cfg) / sizeof(gpio_cfg[0]);

    // Turn on clocks for stuff we use
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4 | RCC_APB1Periph_I2C2, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_TIM1 | RCC_APB2Periph_ADC1 | RCC_APB2Periph_USART1, ENABLE);
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
    RCC_ClearFlag();

    // Make all GPIO in by default to save power and reduce noise
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
    GPIO_Init(GPIOB, &GPIO_InitStructure);
    GPIO_Init(GPIOC, &GPIO_InitStructure);

    // Turn off JTAG port 'cause we're using the GPIO for leds
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);

    // Configure gpio
    for (i = 0; i < gpio_count; i++) {
        GPIO_InitStructure.GPIO_Pin = gpio_cfg[i].pin;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = gpio_cfg[i].mode;
        GPIO_Init(gpio_cfg[i].gpio, &GPIO_InitStructure);
    }

    LED0_OFF;
    LED1_OFF;
    BEEP_OFF;

    // Init cycle counter
    cycleCounterInit();

    // SysTick
    SysTick_Config(SystemCoreClock / 1000);

    // Configure the rest of the stuff
    adcInit();
#ifndef FY90Q
    i2cInit(I2C2);
#endif

    // sleep for 100ms
    delay(100);
}
开发者ID:mcu786,项目名称:baseflight-1,代码行数:57,代码来源:drv_system.c


示例3: UsartRcc_Configuration

//rcc-rcc-rcc-rcc-rcc-rcc-rcc-rcc-rcc-rcc-rcc//
void UsartRcc_Configuration(void)
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO,ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO,ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
	GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
}
开发者ID:xuyingjun,项目名称:learngit,代码行数:10,代码来源:stm32f10_usart.c


示例4: GPIO_Configuration

//========================================
void GPIO_Configuration(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;

	GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
	
	GPIO_InitStructure.GPIO_Pin = LED_CLK_PIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(LED_CLK_PORT, &GPIO_InitStructure);

	GPIO_InitStructure.GPIO_Pin = LED_LAT_PIN;
	GPIO_Init(LED_LAT_PORT, &GPIO_InitStructure);
/*	
#if DISPLAY_LED_STATIC	
	GPIO_InitStructure.GPIO_Pin = LED_OE_PIN;
	GPIO_Init(LED_OE_PORT, &GPIO_InitStructure);
#endif
*/
	if(hwConfig.ledType == SCAN_STATIC)
	{
		GPIO_InitStructure.GPIO_Pin = LED_OE_PIN;
		GPIO_Init(LED_OE_PORT, &GPIO_InitStructure);
	}
	// Config PORTA pins
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	// Config PORTB pins
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	// Config PORTB pins
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	// Config PORTB pins
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
	// Config PORTB pins
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
	GPIO_Init(GPIOE, &GPIO_InitStructure);
	// Set default value for control pins
	GPIO_Write(GPIOA,0x0000);
	GPIO_Write(GPIOB,0x0000);
	GPIO_Write(GPIOC,0x0000);
	GPIO_Write(GPIOD,0x0000);
	GPIO_Write(GPIOE,0x0000);

	// Configure USART1 Rx as input floating 
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	// Configure USART1 Tx as alternate function push-pull 
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
}
开发者ID:thaigiang,项目名称:VMS,代码行数:58,代码来源:HardwareConfig.c


示例5: I2C_Configuration

void I2C_Configuration(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	I2C_InitTypeDef I2C_InitStructure;

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);

	GPIO_PinRemapConfig(GPIO_Remap_I2C1, ENABLE);

	GPIO_InitStructure.GPIO_Pin = I2C_SCL_PIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
	GPIO_Init(GPIOB, &GPIO_InitStructure);

	GPIO_ResetBits(GPIOB, I2C_SCL_PIN);
	I2CDelay(SystemCoreClock / 3 / 100000);

	GPIO_InitStructure.GPIO_Pin = I2C_SDA_PIN;
	GPIO_Init(GPIOB, &GPIO_InitStructure);

	GPIO_ResetBits(GPIOB, I2C_SDA_PIN);
	I2CDelay(SystemCoreClock / 3 / 100000);

	GPIO_SetBits(GPIOB, I2C_SCL_PIN);
	I2CDelay(SystemCoreClock / 3 / 100000);

	GPIO_SetBits(GPIOB, I2C_SDA_PIN);
	I2CDelay(SystemCoreClock / 3 / 100000);

	GPIO_InitStructure.GPIO_Pin = I2C_SCL_PIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	
	GPIO_InitStructure.GPIO_Pin = I2C_SDA_PIN;
	GPIO_Init(GPIOB, &GPIO_InitStructure);

	I2C_DeInit(I2C);
	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
	I2C_InitStructure.I2C_OwnAddress1 = I2C_SLAVE_ADDR;
	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;
	I2C_Init(I2C, &I2C_InitStructure);

	I2C_Cmd(I2C, ENABLE);
	
	if (I2C->SR2 & 0x02)	//检测I2C
	{
		while (1)	//DEBUG
		{
		}
	}
}
开发者ID:zhengchangsi,项目名称:RuiSa,代码行数:56,代码来源:I2C.c


示例6: SD_LowLevel_Init

/**
  * @brief  Initializes the SD_SPI and CS pins.
  * @param  None
  * @retval None
  */
void SD_LowLevel_Init(void)
{
  GPIO_InitTypeDef  GPIO_InitStructure;
  SPI_InitTypeDef   SPI_InitStructure;

  /*!< SD_SPI_CS_GPIO, SD_SPI_MOSI_GPIO, SD_SPI_MISO_GPIO, SD_SPI_DETECT_GPIO
       and SD_SPI_SCK_GPIO Periph clock enable */
  RCC_APB2PeriphClockCmd(SD_CS_GPIO_CLK | SD_SPI_MOSI_GPIO_CLK | SD_SPI_MISO_GPIO_CLK |
                         SD_SPI_SCK_GPIO_CLK | SD_DETECT_GPIO_CLK, ENABLE);

  /*!< SD_SPI Periph clock enable */
  RCC_APB1PeriphClockCmd(SD_SPI_CLK, ENABLE);
  /*!< AFIO Periph clock enable */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
  /*!< Remap SPI3 Pins */
  GPIO_PinRemapConfig(GPIO_Remap_SPI3,ENABLE);

  /*!< Configure SD_SPI pins: SCK */
  GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);

  /*!< Configure SD_SPI pins: MOSI */
  GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN;
  GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);

  /*!< Configure SD_SPI pins: MISO */
  GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);

  /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */
  GPIO_InitStructure.GPIO_Pin = SD_CS_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure);

  /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
  GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);

  /*!< SD_SPI Config */
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  SPI_Init(SD_SPI, &SPI_InitStructure);

  SPI_Cmd(SD_SPI, ENABLE); /*!< SD_SPI enable */
}
开发者ID:szymon2103,项目名称:Stm32,代码行数:61,代码来源:stm3210c_eval.c


示例7: Tim1_Configuration

void Tim1_Configuration(void)
{

    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
    TIM_OCInitTypeDef TIM_OCInitStructure;
	u16 CCR1_Val = 75;      //前面的电机
 	u16 CCR2_Val = 75;	  	 //后面的电机
 	u16 CCR3_Val = 75;		 //左面的电机
 	u16 CCR4_Val = 75;		 //右面的电机
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE);
	GPIO_PinRemapConfig(GPIO_FullRemap_TIM1, ENABLE);  
     TIM_DeInit(TIM1); //重设为缺省值

	/*TIM1时钟配置*/
	TIM_TimeBaseStructure.TIM_Prescaler = 6;      //预分频(时钟分频)72M/4000=18K
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  //向上计数
	TIM_TimeBaseStructure.TIM_Period = 999;       //装载值 18k/144=125hz 就是说向上加的144便满了
	TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;   //设置了时钟分割 不懂得不管
	TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0;    //周期计数器值 不懂得不管
	TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);    //初始化TIMx的时间基数单位
	
	/* Channel 1 Configuration in PWM mode 通道一的PWM */
	TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;      //PWM模式2
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //正向通道有效 PA8 
	//TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; //反向通道也有效 PB13
	TIM_OCInitStructure.TIM_Pulse = CCR1_Val;         //占空时间 144 中有40的时间为高,互补的输出正好相反
	TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; //输出极性
	//TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;    //互补端的极性 
	TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset; //空闲状态下的非工作状态 不管
	//TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset; //先不管
	
	TIM_OC1Init(TIM1,&TIM_OCInitStructure);       //数初始化外设TIMx通道1这里2.0库为TIM_OCInit
	
	  /* PWM1 Mode configuration: Channel2 */
	  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	  TIM_OCInitStructure.TIM_Pulse = CCR2_Val;	  //设置通道2的电平跳变值,输出另外一个占空比的PWM
	  TIM_OC2Init(TIM1, &TIM_OCInitStructure);	  //使能通道2
	  TIM_OC2PreloadConfig(TIM1, TIM_OCPreload_Enable);
	
	  /* PWM1 Mode configuration: Channel3 */
	  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	  TIM_OCInitStructure.TIM_Pulse = CCR3_Val;	//设置通道3的电平跳变值,输出另外一个占空比的PWM
	  TIM_OC3Init(TIM1, &TIM_OCInitStructure);	 //使能通道3
	  TIM_OC3PreloadConfig(TIM1, TIM_OCPreload_Enable);
	
	  /* PWM1 Mode configuration: Channel4 */
	  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	  TIM_OCInitStructure.TIM_Pulse = CCR4_Val;	//设置通道4的电平跳变值,输出另外一个占空比的PWM
	  TIM_OC4Init(TIM1, &TIM_OCInitStructure);	//使能通道4
	  TIM_OC4PreloadConfig(TIM1, TIM_OCPreload_Enable);
	/* TIM1 counter enable开定时器 */
	TIM_Cmd(TIM1,ENABLE);
	
	/* TIM1 Main Output Enable 使能TIM1外设的主输出*/
	TIM_CtrlPWMOutputs(TIM1,ENABLE);
}
开发者ID:renjingc,项目名称:robotNew,代码行数:56,代码来源:stepperMoter.c


示例8: modCounter_init_GPIO

/*Init GPIOE (9,14,13) for PWM and GPIOC(6-8) for input*/
void modCounter_init_GPIO(void)
{
	
  GPIO_InitTypeDef GPIO_InitStructure;
 
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
	
	
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
	
	
	GPIO_InitStructure.GPIO_Pin = 0;// очищаем после предыдущего
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;//+5 TOLERANT?!!!!!!!!!!!!!!!!!!1
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
/////////////////////	///////////////////////////////////////////////////////
		GPIO_InitStructure.GPIO_Pin = 0;// очищаем после предыдущего
	  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_14 | GPIO_Pin_13| GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 
	
  GPIO_Init(GPIOE, &GPIO_InitStructure);
	GPIO_PinRemapConfig(GPIO_FullRemap_TIM1, ENABLE);
	
///////////////////////////////////////////////	
	GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE);
	GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
	GPIO_PinRemapConfig(GPIO_Remap_TIM4, ENABLE);

}	
开发者ID:cortex-m3,项目名称:stm32_projects,代码行数:44,代码来源:modCounter.c


示例9: ledInit

void ledInit(){
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
	GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
	GPIO_InitTypeDef gpioInit;
	gpioInit.GPIO_Pin = ledPins[0] | ledPins[1] | ledPins[2] | ledPins[3];
	gpioInit.GPIO_Mode = GPIO_Mode_Out_PP;
	gpioInit.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_Init(GPIOB, &gpioInit);
}
开发者ID:jachu51,项目名称:sumo,代码行数:10,代码来源:led.cpp


示例10: SPI_GPIO_Configuration

/**
  * @brief  配置指定SPI的引脚
  * @param  SPIx 需要使用的SPI
  * @retval None
  */
static void SPI_GPIO_Configuration(SPI_TypeDef* SPIx , u8 Remap )
{
	GPIO_InitTypeDef GPIO_InitStruct;
		if(Remap==0)   //SPI没有重映射
		{
			if(SPIx==SPI1){					 					 
		GPIO_InitStruct.GPIO_Pin =  GPIO_Pin_5 | GPIO_Pin_6|GPIO_Pin_7;
		GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; 
		GPIO_Init(GPIOA, &GPIO_InitStruct);
		//初始化片选输出引脚
		GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
		GPIO_Init(GPIOA, &GPIO_InitStruct);
		GPIO_SetBits(GPIOA,GPIO_Pin_4);
	}else{
		GPIO_InitStruct.GPIO_Pin =  GPIO_Pin_13 | GPIO_Pin_14|GPIO_Pin_15;
		GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; 
		GPIO_Init(GPIOB, &GPIO_InitStruct);
		//初始化片选输出引脚
		GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
		GPIO_Init(GPIOB, &GPIO_InitStruct);
		GPIO_SetBits(GPIOB,GPIO_Pin_12);
	} 
	}
	
		if(Remap==1)    //SPI有重映射
		{
			GPIO_PinRemapConfig(GPIO_Remap_SPI1, ENABLE);   //SPI1重映射使能
			if(SPIx==SPI1){					 					 
		GPIO_InitStruct.GPIO_Pin =  GPIO_Pin_3 | GPIO_Pin_4|GPIO_Pin_5;
		GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; 
		GPIO_Init(GPIOB, &GPIO_InitStruct);
		//初始化片选输出引脚
		GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
		GPIO_Init(GPIOA, &GPIO_InitStruct);
		GPIO_SetBits(GPIOA,GPIO_Pin_15);
	}else{
		GPIO_InitStruct.GPIO_Pin =  GPIO_Pin_13 | GPIO_Pin_14|GPIO_Pin_15;
		GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; 
		GPIO_Init(GPIOB, &GPIO_InitStruct);
		//初始化片选输出引脚
		GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
		GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
		GPIO_Init(GPIOB, &GPIO_InitStruct);
		GPIO_SetBits(GPIOB,GPIO_Pin_12);
	} 
	}
	
}
开发者ID:Yinhezhang,项目名称:xiaoche,代码行数:60,代码来源:spi_driver.c


示例11: HAL_USART_Begin

void HAL_USART_Begin(HAL_USART_Serial serial, uint32_t baud)
{
    // AFIO clock enable
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

    // Enable USART Clock
    *usartMap[serial]->usart_apbReg |=  usartMap[serial]->usart_clock_en;

    NVIC_InitTypeDef NVIC_InitStructure;

    // Enable the USART Interrupt
    NVIC_InitStructure.NVIC_IRQChannel = usartMap[serial]->usart_int_n;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 7;//USART2_IRQ_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

    // Configure USART Rx as input floating
    HAL_Pin_Mode(usartMap[serial]->usart_rx_pin, INPUT);

    // Configure USART Tx as alternate function push-pull
    HAL_Pin_Mode(usartMap[serial]->usart_tx_pin, AF_OUTPUT_PUSHPULL);

    // Remap USARTn to alternate pins EG. USART1 to pins TX/PB6, RX/PB7
    GPIO_PinRemapConfig(usartMap[serial]->usart_pin_remap, ENABLE);

    // USART default configuration
    // USART configured as follow:
    // - BaudRate = (set baudRate as 9600 baud)
    // - Word Length = 8 Bits
    // - One Stop Bit
    // - No parity
    // - Hardware flow control disabled (RTS and CTS signals)
    // - Receive and transmit enabled
    USART_InitStructure.USART_BaudRate = baud;
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    USART_InitStructure.USART_Parity = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

    // Configure USART
    USART_Init(usartMap[serial]->usart_peripheral, &USART_InitStructure);

    // Enable USART Receive and Transmit interrupts
    USART_ITConfig(usartMap[serial]->usart_peripheral, USART_IT_RXNE, ENABLE);
    USART_ITConfig(usartMap[serial]->usart_peripheral, USART_IT_TXE, ENABLE);

    // Enable the USART
    USART_Cmd(usartMap[serial]->usart_peripheral, ENABLE);

    usartMap[serial]->usart_enabled = true;
    usartMap[serial]->usart_transmitting = false;
}
开发者ID:kbowerma,项目名称:particle,代码行数:55,代码来源:usart_hal.c


示例12: Bsp_Init

void Bsp_Init(void)
{
   RCC_Configuration();
		/*********************************************************************************************/
    //
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
    //初始化LED灯
		 led_init_com();
		 led_init_io();
	
    //初始化串口
	   UART1_NVIC_Configuration();
     UART1_Configuration();
     UART1_GPIO_Configuration();
	
		 UART2_NVIC_Configuration();
     UART2_Configuration();
     UART2_GPIO_Configuration();
		 //清除标志位,否则第一位会丢失
		 USART_ClearFlag(USART1,USART_FLAG_TC);
		 USART_ClearFlag(USART2,USART_FLAG_TC);
	
		 //初始化输入输出接口
	   Io_Init();
		 
		 //初始化E13_TLL模块
		 /***
		 E13_Io_Init();

		 
		 //配置E13_TLL模块
		 if (E13_Configuration()==1)            //E13模块配置失效,闪烁发送和接受LED灯,进入死循环 
		 {
			 while(1)
			 {
			 Delay_Ms(25);
			 led_on_com_r();
				 led_on_com_t();
			 Delay_Ms(25);
				 led_off_r();
				 led_off_t();

			 }
		 }
		 *///////////////
		 led_on_in_3();                  //点亮IN3作为电源指示灯
		 
		 //初始化flash
		 data_error =Read_Flash(0x0801fc00);
		 communication_over_time =Read_Flash(0x0801f800);
		 communication_miss =Read_Flash(0x0801f400);
		 power_up=Read_Flash(0x0801f000);
		 //Write_Flash(0x0801fc00,0);
		 //Write_Flash(0x0801f800,0);
}
开发者ID:xinmulan,项目名称:RGB,代码行数:55,代码来源:bsp.c


示例13: RCC_Configuration

static void RCC_Configuration(void)
{
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

#ifdef RT_USING_UART1
	/* Enable USART1 and GPIOA clocks */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
#endif

#ifdef RT_USING_UART2

#if (defined(STM32F10X_LD) || defined(STM32F10X_MD)) //|| defined(STM32F10X_CL))--2011del
    /* Enable AFIO and GPIOD clock */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOD, ENABLE);

    /* Enable the USART2 Pins Software Remapping */
    GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
#else
    /* Enable AFIO and GPIOA clock */
   // RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE);
    GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOD, ENABLE);
#endif

	/* Enable USART2 clock */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
#endif

#ifdef RT_USING_UART3
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
	/* Enable USART3 clock */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

	/* DMA clock enable */
	//RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
#endif
#ifdef RT_USING_UART4

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
#endif
}
开发者ID:nodeboy,项目名称:nodeboyRepo,代码行数:42,代码来源:usart.c


示例14: GPIO_Configuration

/**
  * @brief  Configures the different GPIO ports.
  * @param  None
  * @retval None
  */
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

#ifdef USE_STM3210E_EVAL
  /* Disable the JTAG interface and enable the SWJ interface
      This operation is not necessary for Connectivity-Line devices since
      SPI3 I/Os can be remapped on other GPIO pins */
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#endif /* USE_STM3210E_EVAL */ 

  /* Configure SPI2 pins: CK, WS and SD ---------------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

#ifdef USE_STM3210C_EVAL
  
  /* Remap SPI3 on PC10-PC11-PC12-PA4 GPIO pins ------------------------*/
  GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
  
  /* Configure SPI3 pins: CK and SD ------------------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_12;
  GPIO_Init(GPIOC, &GPIO_InitStructure);

  /* Configure SPI3 pins: WS -------------------------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  
#elif defined (USE_STM3210E_EVAL)
  
  /* Configure SPI3 pins: CK and SD ------------------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  /* Configure SPI3 pins: WS -------------------------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  
#endif /* USE_STM3210C_EVAL */ 
}
开发者ID:EvanLind,项目名称:WingProject,代码行数:47,代码来源:main.c


示例15: rccInit

static void rccInit(void)
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);

  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
}
开发者ID:xlongfeng,项目名称:watertower,代码行数:11,代码来源:main.c


示例16: uart_Init

static int uart_Init(const uart_cfg_t *cfg)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	USART_InitTypeDef uartinfo;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
#ifdef CONFIG_STM32F10X_CL
	/*configure PD5<uart2.tx>, PD6<uart2.rx>*/
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE);
	GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
#else
	/*configure PA2<uart2.tx>, PA3<uart2.rx>*/
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif

	/*init serial port*/
	USART_StructInit(&uartinfo);
	uartinfo.USART_BaudRate = cfg->baud;
	USART_Init(uart, &uartinfo);

#ifdef ENABLE_TX_DMA
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	uart_SetupTxDMA(uart_fifo_tx, 0);
	USART_DMACmd(uart, USART_DMAReq_Tx, ENABLE);
	uart_fifo_tn = 0;
	uart_fifo_tp = 0;
#endif

#ifdef ENABLE_RX_DMA
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	uart_SetupRxDMA(uart_fifo_rx, RX_FIFO_SZ);
	USART_DMACmd(uart, USART_DMAReq_Rx, ENABLE);
	uart_fifo_rn = 0;
#endif

	USART_Cmd(uart, ENABLE);
	return 0;
}
开发者ID:miaofng,项目名称:ulp,代码行数:54,代码来源:uart2_stm32.c


示例17: I2CInit

/* ---------------------------------------------------------------------------
** Initialize the HW modules needed for I2C communication
** -------------------------------------------------------------------------*/
void I2CInit(void)
{
    I2C_InitTypeDef  I2C_InitStructure;
    GPIO_InitTypeDef  GPIO_InitStructure;

#ifdef I2C_REMAP

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB,ENABLE);

#else

    /*!< I2C_SCL_GPIO_CLK and I2C_SDA_GPIO_CLK Periph clock enable */
    RCC_APB2PeriphClockCmd(RCC_APB1Periph_I2C1 | RCC_APB2Periph_GPIOB, ENABLE);

#endif

    /*!< I2C Periph clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);


    /*!< GPIO configuration */

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;

#ifdef I2C_REMAP

    GPIO_PinRemapConfig(GPIO_Remap_I2C1, ENABLE);
    /*!< Configure I2C pins: SCL -- PB8,  SDA -- PB9*/
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;

#else

    /*!< Configure I2C pins: SCK -- PB6, SDA -- PB7*/
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;

#endif

    GPIO_Init(GPIOB, &GPIO_InitStructure);
//	#endif

    /*!< I2C configuration */
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;

    /* I2C Peripheral Enable */
    I2C_Cmd(I2C1, ENABLE);
    /* Apply I2C configuration after enabling it */
    I2C_Init(I2C1, &I2C_InitStructure);

}
开发者ID:abyssxsy,项目名称:uav-aloa,代码行数:57,代码来源:I2C.c


示例18: uart3_init

void uart3_init( void ) {

  /* init RCC */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

  /* Enable USART3 interrupts */
  NVIC_InitTypeDef nvic;
  nvic.NVIC_IRQChannel = USART3_IRQn;
  nvic.NVIC_IRQChannelPreemptionPriority = 2;
  nvic.NVIC_IRQChannelSubPriority = 1;
  nvic.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&nvic);

  /* Init GPIOS */
  GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);
  GPIO_InitTypeDef gpio;
  /* GPIOC: GPIO_Pin_10 USART3 Tx push-pull */
  gpio.GPIO_Pin   = UART3_TxPin;
  gpio.GPIO_Mode  = GPIO_Mode_AF_PP;
  gpio.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(UART3_TxPort, &gpio);
  /* GPIOC: GPIO_Pin_11 USART3 Rx pin as floating input */
  gpio.GPIO_Pin   = UART3_RxPin;
  gpio.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
  GPIO_Init(UART3_RxPort, &gpio);

  /* Configure USART3 */
  USART_InitTypeDef usart;
  usart.USART_BaudRate            = UART3_BAUD;
  usart.USART_WordLength          = USART_WordLength_8b;
  usart.USART_StopBits            = USART_StopBits_1;
  usart.USART_Parity              = USART_Parity_No;
  usart.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  usart.USART_Mode                = USART_Mode_Rx | USART_Mode_Tx;
  USART_Init(USART3, &usart);
  /* Enable USART3 Receive interrupts */
  USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);

  pprz_usart_set_baudrate(USART3, UART3_BAUD);

  /* Enable the USART3 */
  USART_Cmd(USART3, ENABLE);

  // initialize the transmit data queue
  uart3_tx_extract_idx = 0;
  uart3_tx_insert_idx = 0;
  uart3_tx_running = FALSE;

  // initialize the receive data queuenn
  uart3_rx_extract_idx = 0;
  uart3_rx_insert_idx = 0;

}
开发者ID:hwarm,项目名称:paparazzi,代码行数:54,代码来源:uart_arch.c


示例19: main

/* The core is running at 72MHz */
int main(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;

    /* Set the Vector Table base adress at 0x8004000 */
    NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000);

    RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOA , ENABLE); 
	
    /* Full SWJ Disabled (JTAG-DP + SW-DP) */
    GPIO_PinRemapConfig (GPIO_Remap_SWJ_Disable, ENABLE);  	
	
	
   	//LED0 -> PB0, LED1 -> PB1 
	  // Reset GPIO init structure
    GPIO_StructInit(&GPIO_InitStructure);	
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 
    GPIO_Init(GPIOB, &GPIO_InitStructure);

	
		// Configure PA1 as input floating
    // Reset GPIO init structure
    GPIO_StructInit(&GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//GPIO_Mode_IPD;
    GPIO_Init(GPIOA, &GPIO_InitStructure);


	
 	  USART1_Init();

    ADC_Configuration();

    while (1)
	  {
		    /* LED0-ON LED1-OFF */
		    GPIO_SetBits(GPIOB , GPIO_Pin_0);
 		    GPIO_ResetBits(GPIOB , GPIO_Pin_1);
	    	Delay(0xfffff);       
		    /* LED0-OFF LED1-ON */
		    GPIO_ResetBits(GPIOB , GPIO_Pin_0);
		    GPIO_SetBits(GPIOB , GPIO_Pin_1);
		    Delay(0xfffff);              
			
        /* Print the ADC PA1 DIP Switch value to USART */
        USART1_Print_Int(readDIPSwitch());
			
			  if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1) == 1) USART1_Print(", ON\n");
			  else USART1_Print(", OFF\n");
    }			
}
开发者ID:MBARM,项目名称:MatchboxARM,代码行数:55,代码来源:main.c


示例20: TIM3_PWM_In_Init

/*
 * 函数名:TIM3_PWM_In_Init
 * 描述  :定时器3输入捕获初始化函数
 * 输入  :arr:自动重装载寄存器周期的值;psc:时钟频率除数的预分频值
 * 输出  :无
 */ 
void TIM3_PWM_In_Init(u16 arr,u16 psc)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
	TIM_ICInitTypeDef  TIM3_ICInitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);  	//使能GPIOB时钟
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);		//使能TIM3时钟
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); 
	GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3,ENABLE);
 	
	GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_4 | GPIO_Pin_5;  												
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;           										
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	
	GPIO_ResetBits(GPIOB,GPIO_Pin_4);
	GPIO_ResetBits(GPIOB,GPIO_Pin_5);

	//初始化TIM3	 
	TIM_TimeBaseStructure.TIM_Period = arr;    																		 //设定计数器自动重装值 
	TIM_TimeBaseStructure.TIM_Prescaler =psc; 																		 //预分频器   
	TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; 											 //设置时钟分割
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; 									 //TIM向上计数模式
	TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);                                //初始化TIMx的时间基数单位
  
	//初始化TIM3通道1输入捕获参数
	TIM3_ICInitStructure.TIM_Channel = TIM_Channel_1 ; 														 //选择输入端 IC1映射到TI1上
  TIM3_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;									 //上升沿捕获
  TIM3_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; 							 //映射到TI1上
 	TIM3_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;	                       //配置输入分频,不分频 
 	TIM3_ICInitStructure.TIM_ICFilter = 0x00;																			 //配置输入滤波器,不滤波
  TIM_ICInit(TIM3, &TIM3_ICInitStructure);
//初始化TIM3通道2输入捕获参数
	TIM3_ICInitStructure.TIM_Channel = TIM_Channel_2 ; 														 //选择输入端 IC1映射到TI1上
  TIM3_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;									 //上升沿捕获
  TIM3_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; 							 //映射到TI1上
  TIM3_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;	 											 //配置输入分频,不分频 
  TIM3_ICInitStructure.TIM_ICFilter = 0x00;																			 //配置输入滤波器 不滤波
  TIM_ICInit(TIM3, &TIM3_ICInitStructure);
		
	//中断分组初始化
	NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn  ;  														 //TIM3中断
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;  										 //先占优先级
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;  												 	 //从优先级
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 															 //IRQ通道被使能
	NVIC_Init(&NVIC_InitStructure);  																							 //初始化外设NVIC寄存器 

	TIM_ITConfig(TIM3,TIM_IT_Update | TIM_IT_CC1 | TIM_IT_CC2,ENABLE);								 //允许更新中断 ,允许CC1IE捕获中断	
	
 	TIM_Cmd(TIM3,ENABLE ); 																												 //使能定时器3
}
开发者ID:Strongc,项目名称:FourAxis-M,代码行数:59,代码来源:pwm_in.c



注:本文中的GPIO_PinRemapConfig函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GPIO_SetBits函数代码示例发布时间:2022-05-30
下一篇:
C++ GPIO_PinAFConfig函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap