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

C++ GPIO_Init函数代码示例

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

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



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

示例1: xSerialPortInitMinimal

/*
 * See the serial2.h header file.
 */
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn;
UART_InitTypeDef xUART1_Init;
GPIO_InitTypeDef GPIO_InitStructure;
	
	/* Create the queues used to hold Rx characters. */
	xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
	
	/* Create the semaphore used to wake a task waiting for space to become
	available in the FIFO. */
	vSemaphoreCreateBinary( xTxFIFOSemaphore );

	/* If the queue/semaphore was created correctly then setup the serial port
	hardware. */
	if( ( xRxedChars != serINVALID_QUEUE ) && ( xTxFIFOSemaphore != serINVALID_QUEUE ) )
	{
		/* Pre take the semaphore so a task will block if it tries to access
		it. */
		xSemaphoreTake( xTxFIFOSemaphore, 0 );
		
		/* Configure the UART. */
		xUART1_Init.UART_WordLength = UART_WordLength_8D;
		xUART1_Init.UART_StopBits = UART_StopBits_1;
		xUART1_Init.UART_Parity = UART_Parity_No;
		xUART1_Init.UART_BaudRate = ulWantedBaud;
		xUART1_Init.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
		xUART1_Init.UART_Mode = UART_Mode_Tx_Rx;
		xUART1_Init.UART_FIFO = UART_FIFO_Enable;

		/* Enable the UART1 Clock */
		SCU_APBPeriphClockConfig( __UART1, ENABLE );
		
		/* Enable the GPIO3 Clock */
		SCU_APBPeriphClockConfig( __GPIO3, ENABLE );
		
		/* Configure UART1_Rx pin GPIO3.2 */
		GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
		GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
		GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;
		GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ;
		GPIO_Init( GPIO3, &GPIO_InitStructure );
		
		/* Configure UART1_Tx pin GPIO3.3 */
		GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
		GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
		GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
		GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;
		GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ;
		GPIO_Init( GPIO3, &GPIO_InitStructure );
		
		
		portENTER_CRITICAL();
		{		
			/* Configure the UART itself. */
			UART_DeInit( UART1 );		
			UART_Init( UART1, &xUART1_Init );
			UART_ITConfig( UART1, UART_IT_Receive | UART_IT_Transmit, ENABLE );
			UART1->ICR = serCLEAR_ALL_INTERRUPTS;
			UART_LoopBackConfig( UART1, DISABLE );
			UART_IrDACmd( IrDA1, DISABLE );

			/* Configure the VIC for the UART interrupts. */			
			VIC_Config( UART1_ITLine, VIC_IRQ, 9 );
			VIC_ITCmd( UART1_ITLine, ENABLE );

			UART_Cmd( UART1, ENABLE );			
			lTaskWaiting = pdFALSE;
		}
		portEXIT_CRITICAL();
	}
	else
	{
		xReturn = ( xComPortHandle ) 0;
	}

	/* This demo file only supports a single port but we have to return
	something to comply with the standard demo header file. */
	return xReturn;
}
开发者ID:AlexShiLucky,项目名称:freertos,代码行数:84,代码来源:serial.c


示例2: f3d_gyro_interface_init

void f3d_gyro_interface_init() {

  GPIO_InitTypeDef GPIO_InitStructure;

///////////////////////////////////////////////////////  
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

  //SCK Pin PA5  
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA,&GPIO_InitStructure);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_5);

  //MOSI Pin PA6
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA,&GPIO_InitStructure);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_5);

  //MISO Pin PA7
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA,&GPIO_InitStructure);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_5);
//////////////////////////////////////////////////////

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);

  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOE,&GPIO_InitStructure);

  GPIO_SetBits(GPIOE, GPIO_Pin_3);
  ////////////////////////////////////////////////////
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

  SPI_InitTypeDef SPI_InitStructure;
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_Init(SPI1, &SPI_InitStructure);
  SPI_RxFIFOThresholdConfig(SPI1, SPI_RxFIFOThreshold_QF);
  SPI_Cmd(SPI1, ENABLE);
} 
开发者ID:jlwegene,项目名称:Bank-Heist-2013,代码行数:64,代码来源:f3d_gyro.c


示例3: SdkEvalLedInit

/**
 * @brief  Configures LED GPIO.
 * @param  xLed Specifies the Led to be configured.
 *         This parameter can be one of following parameters:
 *         @arg LED1
 *         @arg LED2
 * @retval None.
 */
void SdkEvalLedInit(SdkEvalLed xLed)
{
    /* Configure the GPIO_LED pin */
    GPIO_Init(vectpxGpioPort[xLed], s_vectnGpioPin[xLed], GPIO_Mode_Out_PP_High_Fast);
}
开发者ID:david-kooi,项目名称:eval,代码行数:13,代码来源:SDK_EVAL_Led.c


示例4: main

int main(void)
{

	uint8_t ch;

  /* Enable GPIO clock */
   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

   /* Enable USART3 clock */
   RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
   GPIO_Init(GPIOB, &GPIO_InitStructure);

   GPIO_WriteBit(GPIOB, GPIO_Pin_6, Bit_RESET);
   GPIO_WriteBit(GPIOB, GPIO_Pin_7, Bit_RESET);

   /* Configure USART3 Rx & Tx as alternate function */
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
   GPIO_Init(GPIOC, &GPIO_InitStructure);

   /* GPIOC --> USART3 Rx & Tx */
   GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3);
   GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3);

   USART_InitStructure.USART_BaudRate = 9600;
   USART_InitStructure.USART_WordLength = USART_WordLength_9b;
   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;

   /* USART configuration */
   USART_Init(USART3, &USART_InitStructure);

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

   do {
	   USART_ReceiveData(USART3);
   } while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) != RESET);


   while(1) {
	   /* wait for character to arrive */
	   while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET)
		   ;

	   GPIO_TOGGLE(GPIOB,GPIO_Pin_6);

	   /* read the available data */
	   ch = USART_ReceiveData(USART3);
	   ch++;
          
	   /* Wait while TX is full */
	   while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET)
    	   ;

	   /*transmit data only when TX is empty */
	   USART_SendData(USART3, ch);
	   GPIO_TOGGLE(GPIOB, GPIO_Pin_7);
   }
}
开发者ID:oussemah,项目名称:SecureKB,代码行数:73,代码来源:main.c


示例5: internal_uart_init

OSStatus internal_uart_init( mico_uart_t uart, const mico_uart_config_t* config, ring_buffer_t* optional_rx_buffer )
{
  GPIO_InitTypeDef  gpio_init_structure;
  USART_InitTypeDef usart_init_structure;
  NVIC_InitTypeDef  nvic_init_structure;
  DMA_InitTypeDef   dma_init_structure;
  
#ifndef NO_MICO_RTOS
  mico_rtos_init_semaphore(&uart_interfaces[uart].tx_complete, 1);
  mico_rtos_init_semaphore(&uart_interfaces[uart].rx_complete, 1);
#else
  uart_interfaces[uart].tx_complete = false;
  uart_interfaces[uart].rx_complete = false;
#endif
  
  MicoMcuPowerSaveConfig(false);
  
  /* Enable GPIO peripheral clocks for TX and RX pins */
  RCC_AHB1PeriphClockCmd( uart_mapping[uart].pin_rx->peripheral_clock |
                         uart_mapping[uart].pin_tx->peripheral_clock, ENABLE );
  
  /* Configure USART TX Pin */
  gpio_init_structure.GPIO_Pin   = (uint32_t) ( 1 << uart_mapping[uart].pin_tx->number );
  gpio_init_structure.GPIO_Mode  = GPIO_Mode_AF;
  gpio_init_structure.GPIO_OType = GPIO_OType_PP;
  gpio_init_structure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  gpio_init_structure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init( uart_mapping[uart].pin_tx->bank, &gpio_init_structure );
  GPIO_PinAFConfig( uart_mapping[uart].pin_tx->bank, uart_mapping[uart].pin_tx->number, uart_mapping[uart].gpio_af );
  
  /* Configure USART RX Pin */
  gpio_init_structure.GPIO_Pin   = (uint32_t) ( 1 << uart_mapping[uart].pin_rx->number );
  gpio_init_structure.GPIO_Mode  = GPIO_Mode_AF;
  gpio_init_structure.GPIO_OType = GPIO_OType_OD;
  gpio_init_structure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  GPIO_Init( uart_mapping[uart].pin_rx->bank, &gpio_init_structure );
  GPIO_PinAFConfig( uart_mapping[uart].pin_rx->bank, uart_mapping[uart].pin_rx->number, uart_mapping[uart].gpio_af );
  
#ifndef NO_MICO_RTOS
  if(config->flags & UART_WAKEUP_ENABLE){
    current_uart = uart;
    mico_rtos_init_semaphore( &uart_interfaces[uart].sem_wakeup, 1 );
    mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "UART_WAKEUP", thread_wakeup, 0x100, &current_uart);
  }
#endif
  
  /* Check if any of the flow control is enabled */
  if ( uart_mapping[uart].pin_cts && (config->flow_control == FLOW_CONTROL_CTS || config->flow_control == FLOW_CONTROL_CTS_RTS) )
  {
    /* Enable peripheral clock */
    RCC_AHB1PeriphClockCmd( uart_mapping[uart].pin_cts->peripheral_clock, ENABLE );
    
    /* Configure CTS Pin */
    gpio_init_structure.GPIO_Pin   = (uint32_t) ( 1 << uart_mapping[uart].pin_cts->number );
    gpio_init_structure.GPIO_Mode  = GPIO_Mode_AF;
    gpio_init_structure.GPIO_OType = GPIO_OType_OD;
    gpio_init_structure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
    GPIO_Init( uart_mapping[uart].pin_cts->bank, &gpio_init_structure );
    GPIO_PinAFConfig( uart_mapping[uart].pin_cts->bank, uart_mapping[uart].pin_cts->number, uart_mapping[uart].gpio_af );
  }
  
  if ( uart_mapping[uart].pin_cts && (config->flow_control == FLOW_CONTROL_RTS || config->flow_control == FLOW_CONTROL_CTS_RTS) )
  {
    /* Enable peripheral clock */
    RCC_AHB1PeriphClockCmd( uart_mapping[uart].pin_rts->peripheral_clock, ENABLE );
    
    /* Configure RTS Pin */
    gpio_init_structure.GPIO_Pin   = (uint32_t) ( 1 << uart_mapping[uart].pin_rts->number );
    gpio_init_structure.GPIO_Mode  = GPIO_Mode_AF;
    gpio_init_structure.GPIO_OType = GPIO_OType_OD;
    gpio_init_structure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
    GPIO_Init( uart_mapping[uart].pin_rts->bank, &gpio_init_structure );
    GPIO_PinAFConfig( uart_mapping[uart].pin_rts->bank, uart_mapping[uart].pin_rts->number, uart_mapping[uart].gpio_af );
  }
  
  /* Enable UART peripheral clock */
  uart_mapping[uart].usart_peripheral_clock_func( uart_mapping[uart].usart_peripheral_clock, ENABLE );
  
  /**************************************************************************
  * Initialise STM32 USART registers
  * NOTE:
  * - Both transmitter and receiver are disabled until usart_enable_transmitter/receiver is called.
  * - Only 1 and 2 stop bits are implemented at the moment.
  **************************************************************************/
  usart_init_structure.USART_Mode       = 0;
  usart_init_structure.USART_BaudRate   = config->baud_rate;
  usart_init_structure.USART_WordLength = ( ( config->data_width == DATA_WIDTH_9BIT ) ||
                                           ( ( config->data_width == DATA_WIDTH_8BIT ) && ( config->parity != NO_PARITY ) ) ) ? USART_WordLength_9b : USART_WordLength_8b;
  usart_init_structure.USART_StopBits   = ( config->stop_bits == STOP_BITS_1 ) ? USART_StopBits_1 : USART_StopBits_2;
                                           
  switch ( config->parity )
  {
  case NO_PARITY:
    usart_init_structure.USART_Parity = USART_Parity_No;
    break;
  case EVEN_PARITY:
    usart_init_structure.USART_Parity = USART_Parity_Even;
    break;
  case ODD_PARITY:
    usart_init_structure.USART_Parity = USART_Parity_Odd;
//.........这里部分代码省略.........
开发者ID:agb861,项目名称:STM32F,代码行数:101,代码来源:MicoDriverUart.c


示例6: ADC_Config

/**
  * @brief  ADC configuration
  * @note   This function Configure the ADC peripheral  
            1) Enable peripheral clocks
            2) Configure ADC Channel 12 pin as analog input
            3) DMA2_Stream0 channel2 configuration
            4) Configure ADC1 Channel 12
            5) Configure ADC2 Channel 12
            6) Configure ADC3 Channel 12
  * @param  None
  * @retval None
  */
static void ADC_Config(void)
{
  GPIO_InitTypeDef       GPIO_InitStructure;
  DMA_InitTypeDef        DMA_InitStructure;
  ADC_InitTypeDef        ADC_InitStructure;
  ADC_CommonInitTypeDef  ADC_CommonInitStructure;  
  
  /* Enable peripheral clocks *************************************************/
  RCC_AHB1PeriphClockCmd( ADC1_2_CHANNEL_GPIO_CLK , ENABLE);
  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_DMA2 , ENABLE);
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC1 , ENABLE);
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC2 , ENABLE);
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC3 , ENABLE);  

  /* Configure ADC Channel 12 pin as analog input *****************************/ 
  GPIO_InitStructure.GPIO_Pin = GPIO_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIO_PORT, &GPIO_InitStructure);

  /* DMA2 Stream0 channel0 configuration **************************************/
  DMA_InitStructure.DMA_Channel = DMA_CHANNELx;  
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC_CDR_ADDRESS;
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&aADCTripleConvertedValue;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
  DMA_InitStructure.DMA_BufferSize = 3;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;         
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_Init(DMA_STREAMx, &DMA_InitStructure);

  /* DMA2_Stream0 enable */
  DMA_Cmd(DMA_STREAMx, ENABLE);

  /* ADC Common configuration *************************************************/
  ADC_CommonInitStructure.ADC_Mode = ADC_TripleMode_Interl;
  ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_2;  
  ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; 
  ADC_CommonInit(&ADC_CommonInitStructure);

  /* ADC1 regular channel 12 configuration ************************************/
  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
  ADC_InitStructure.ADC_ScanConvMode = DISABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfConversion = 1;
  ADC_Init(ADC1, &ADC_InitStructure);

  ADC_RegularChannelConfig(ADC1, ADC_CHANNEL, 1, ADC_SampleTime_3Cycles);
  /* Enable ADC1 DMA */
  ADC_DMACmd(ADC1, ENABLE);

  /* ADC2 regular channel 12 configuration ************************************/
  ADC_Init(ADC2, &ADC_InitStructure);
  /* ADC2 regular channel12 configuration */ 
  ADC_RegularChannelConfig(ADC2, ADC_CHANNEL, 1, ADC_SampleTime_3Cycles);

  /* ADC3 regular channel 12 configuration ************************************/
  ADC_Init(ADC3, &ADC_InitStructure); 
  /* ADC3 regular channel12 configuration */
  ADC_RegularChannelConfig(ADC3, ADC_CHANNEL, 1, ADC_SampleTime_3Cycles);

  /* Enable DMA request after last transfer (multi-ADC mode) ******************/
  ADC_MultiModeDMARequestAfterLastTransferCmd(ENABLE);

  /* Enable ADC1 **************************************************************/
  ADC_Cmd(ADC1, ENABLE);

  /* Enable ADC2 **************************************************************/
  ADC_Cmd(ADC2, ENABLE);

  /* Enable ADC3 **************************************************************/
  ADC_Cmd(ADC3, ENABLE);
}  
开发者ID:BswaHuangshan,项目名称:dddd,代码行数:96,代码来源:main.c


示例7: USB_OTG_BSP_Init

void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
{
#ifdef USE_STM3210C_EVAL

  RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3);
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ;

#else // USE_STM322xG_EVAL  
  GPIO_InitTypeDef GPIO_InitStructure;   
 #ifdef USE_USB_OTG_FS 
  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE);  
  
   /* Configure SOF ID DM DP Pins */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8  | 
                                GPIO_Pin_11 | 
                                GPIO_Pin_12;
  
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  
  
  GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ;
  GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ; 
  GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ;
  
  /* Configure  VBUS Pin */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);    
  
  /* Configure ID pin */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_10;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;  
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  
  GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ;   
 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ; 
 #else // USE_USB_OTG_HS 

  #ifdef USE_ULPI_PHY // ULPI
  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | 
                         RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOH | 
                           RCC_AHB1Periph_GPIOI, ENABLE);    
  
  
  GPIO_PinAFConfig(GPIOA,GPIO_PinSource3, GPIO_AF_OTG2_HS) ; // D0
  GPIO_PinAFConfig(GPIOA,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // CLK
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // D1
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource1, GPIO_AF_OTG2_HS) ; // D2
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // D7
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource10,GPIO_AF_OTG2_HS) ; // D3
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // D4
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource12,GPIO_AF_OTG2_HS) ; // D5
  GPIO_PinAFConfig(GPIOB,GPIO_PinSource13,GPIO_AF_OTG2_HS) ; // D6
  GPIO_PinAFConfig(GPIOH,GPIO_PinSource4, GPIO_AF_OTG2_HS) ; // NXT
  GPIO_PinAFConfig(GPIOI,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // DIR
  GPIO_PinAFConfig(GPIOC,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // STP
  
  // CLK
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  
  
  // D0
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3  ; 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  
  
  
  
  // D1 D2 D3 D4 D5 D6 D7
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1  |
    GPIO_Pin_5 | GPIO_Pin_10 | 
      GPIO_Pin_11| GPIO_Pin_12 | 
        GPIO_Pin_13 ;
  
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOB, &GPIO_InitStructure);  
  
  
  // STP
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0  ;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_Init(GPIOC, &GPIO_InitStructure);  
//.........这里部分代码省略.........
开发者ID:andrecurvello,项目名称:stm32f4xx,代码行数:101,代码来源:usb_bsp.c


示例8: LCD_SC_DeInit

void LCD_SC_DeInit(void)
{
	GPIO_Init(GPIO_PORT_COM0, GPIO_PIN_COM0, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_COM1, GPIO_PIN_COM1, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_COM2, GPIO_PIN_COM2, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_COM3, GPIO_PIN_COM3, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S0, GPIO_PIN_S0, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S1, GPIO_PIN_S1, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S2, GPIO_PIN_S2, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S3, GPIO_PIN_S3, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S4, GPIO_PIN_S4, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S5, GPIO_PIN_S5, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S6, GPIO_PIN_S6, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S7, GPIO_PIN_S7, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S8, GPIO_PIN_S8, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S9, GPIO_PIN_S9, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S10, GPIO_PIN_S10, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S11, GPIO_PIN_S11, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S12, GPIO_PIN_S12, GPIO_Mode_Out_PP_Low_Fast);
	GPIO_Init(GPIO_PORT_S13, GPIO_PIN_S13, GPIO_Mode_Out_PP_Low_Fast);
}
开发者ID:glocklueng,项目名称:SmartAmmeter_STM8L,代码行数:21,代码来源:lcd_sc.c


示例9: I2C_Initialize1

static void I2C_Initialize1()
{
  I2C_InitTypeDef I2C_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure; 
  NVIC_InitTypeDef NVIC_InitStructure;
  
  RCC_AHB1PeriphClockCmd(I2C1_DMA_CLK, ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
  RCC_AHB1PeriphClockCmd(I2C1_GPIO_CLK, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);
  
  I2C_StructInit(&I2C_InitStructure);
  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  I2C_InitStructure.I2C_OwnAddress1 = I2C1_OWN_ADDRESS;
  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  I2C_InitStructure.I2C_ClockSpeed = 100000;

  I2C_Cmd(I2C1, ENABLE);
  I2C_Init(I2C1, &I2C_InitStructure);
  
  /* Initialize I2C1 on PB8 and PB9 */
  
  GPIO_PinAFConfig(I2C1_SCL_PORT, I2C1_SCL_PIN_SOURCE, GPIO_AF_I2C1);
  GPIO_PinAFConfig(I2C1_SDA_PORT, I2C1_SDA_PIN_SOURCE, GPIO_AF_I2C1);
  
  GPIO_InitStructure.GPIO_Pin = I2C1_SCL_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  
  GPIO_InitStructure.GPIO_Pin = I2C1_SDA_PIN;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  
  DMA_ClearFlag(I2C1_DMA_STREAM_RX, I2C1_DMA_RX_FLAG_FEIF | I2C1_DMA_RX_FLAG_DMEIF | I2C1_DMA_RX_FLAG_TEIF |
                              I2C1_DMA_RX_FLAG_HTIF | I2C1_DMA_RX_FLAG_TCIF);
  DMA_Cmd(I2C1_DMA_STREAM_RX, DISABLE);
  DMA_DeInit(I2C1_DMA_STREAM_RX);
  DMA_StructInit(&I2C1_DMA_InitStructure);
  I2C1_DMA_InitStructure.DMA_Channel = I2C1_DMA_CHANNEL_RX;
  I2C1_DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &(I2C1->DR);
  I2C1_DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)0;    /* This parameter will be configured durig communication */;
  I2C1_DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; /* This parameter will be configured durig communication */
  I2C1_DMA_InitStructure.DMA_BufferSize = 0xFFFF;              /* This parameter will be configured durig communication */
  I2C1_DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  I2C1_DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  I2C1_DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  I2C1_DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  I2C1_DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  I2C1_DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
  I2C1_DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
  I2C1_DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
  I2C1_DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  I2C1_DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_Init(I2C1_DMA_STREAM_RX, &I2C1_DMA_InitStructure);
  
  DMA_ClearFlag(I2C1_DMA_STREAM_TX, I2C1_DMA_TX_FLAG_FEIF | I2C1_DMA_TX_FLAG_DMEIF | I2C1_DMA_TX_FLAG_TEIF |
                              I2C1_DMA_TX_FLAG_HTIF | I2C1_DMA_TX_FLAG_TCIF);
  DMA_Cmd(I2C1_DMA_STREAM_TX, DISABLE);
  
  DMA_DeInit(I2C1_DMA_STREAM_TX);
  I2C1_DMA_InitStructure.DMA_Channel = I2C1_DMA_CHANNEL_TX;
  DMA_Init(I2C1_DMA_STREAM_TX, &I2C1_DMA_InitStructure);
  
  /* Setup interrupts */
  NVIC_InitStructure.NVIC_IRQChannel = I2C1_DMA_RX_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = I2C1_DMA_PREPRIO;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = I2C1_DMA_SUBPRIO;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = I2C1_DMA_TX_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = I2C1_DMA_PREPRIO;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = I2C1_DMA_SUBPRIO;
  NVIC_Init(&NVIC_InitStructure);  
  
  /* Enable TC Interrupts */
  DMA_ITConfig(I2C1_DMA_STREAM_TX, DMA_IT_TC, ENABLE);
  DMA_ITConfig(I2C1_DMA_STREAM_RX, DMA_IT_TC, ENABLE);      
  
  I2C1_DMA_RX_Semaphore = 0;
  I2C1_DMA_TX_Semaphore = 0;
}
开发者ID:drahosj,项目名称:avionics-software,代码行数:89,代码来源:i2c.c


示例10: CONF_PWMIN

void CONF_PWMIN(void)
{

	  GPIO_InitTypeDef GPIO_InitStructure;
	   NVIC_InitTypeDef NVIC_InitStructure;

	   /* TIM2 clock enable */
	   RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

	   /* GPIOB clock enable */
	   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

	   /* TIM2 chennel2 configuration : PA.01 */
	   GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_7;
	   GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
	   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	   GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP ;
	   GPIO_Init(GPIOC, &GPIO_InitStructure);

	   /* Connect TIM pin to AF1 */
	   GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_2);

	   TIM_TimeBaseStructure.TIM_Prescaler = 360;
	   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	   TIM_TimeBaseStructure.TIM_Period = 65535;
	   TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	   TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
	   /* Enable the TIM2 global Interrupt */
	   NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
	   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
	   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	   NVIC_Init(&NVIC_InitStructure);
	   //////
	   TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
	   TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
	   TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
	   TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
	   TIM_ICInitStructure.TIM_ICFilter = 0x0;

	   TIM_PWMIConfig(TIM3, &TIM_ICInitStructure);

	   /* Select the TIM2 Input Trigger: TI2FP2 */
	   TIM_SelectInputTrigger(TIM3, TIM_TS_TI2FP2);

	   /* Select the slave Mode: Reset Mode */
	   TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_Reset);
	   TIM_SelectMasterSlaveMode(TIM3,TIM_MasterSlaveMode_Enable);

	   /* TIM enable counter */
	   TIM_Cmd(TIM3, ENABLE);

	   /* Enable the CC2 Interrupt Request */
	    TIM_ITConfig(TIM3, TIM_IT_CC2, ENABLE);


	    ////TIM4
		   /* TIM2 clock enable */
		   RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);

		   /* GPIOB clock enable */
		   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);

		   /* TIM2 chennel2 configuration : PA.01 */
		   GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_13;
		   GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
		   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
		   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
		   GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP ;
		   GPIO_Init(GPIOD, &GPIO_InitStructure);

		   /* Connect TIM pin to AF1 */
		   GPIO_PinAFConfig(GPIOD, GPIO_PinSource13, GPIO_AF_2);

		   TIM_TimeBaseStructure.TIM_Prescaler = 360;
		   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
		   TIM_TimeBaseStructure.TIM_Period = 65535;
		   TIM_TimeBaseStructure.TIM_ClockDivision = 0;
		   TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
		   /* Enable the TIM2 global Interrupt */
		   NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
		   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
		   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
		   NVIC_Init(&NVIC_InitStructure);
		   //////
		   TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
		   TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
		   TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
		   TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
		   TIM_ICInitStructure.TIM_ICFilter = 0x0;

		   TIM_PWMIConfig(TIM4, &TIM_ICInitStructure);

		   /* Select the TIM2 Input Trigger: TI2FP2 */
		   TIM_SelectInputTrigger(TIM4, TIM_TS_TI2FP2);

		   /* Select the slave Mode: Reset Mode */
		   TIM_SelectSlaveMode(TIM4, TIM_SlaveMode_Reset);
		   TIM_SelectMasterSlaveMode(TIM4,TIM_MasterSlaveMode_Enable);

//.........这里部分代码省略.........
开发者ID:lennytraviano,项目名称:quadrocopter,代码行数:101,代码来源:main.c


示例11: LCD_FSMCConfig

static void LCD_FSMCConfig(void)
{
    FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
    FSMC_NORSRAMTimingInitTypeDef  Timing_read,Timing_write;

    /* FSMC GPIO configure */
    {
        GPIO_InitTypeDef GPIO_InitStructure;
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF
                               | RCC_APB2Periph_GPIOG, ENABLE);
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

        GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF_PP;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

        /*
        FSMC_D0 ~ FSMC_D3
        PD14 FSMC_D0   PD15 FSMC_D1   PD0  FSMC_D2   PD1  FSMC_D3
        */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_14 | GPIO_Pin_15;
        GPIO_Init(GPIOD,&GPIO_InitStructure);

        /*
        FSMC_D4 ~ FSMC_D12
        PE7 ~ PE15  FSMC_D4 ~ FSMC_D12
        */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10
                                      | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
        GPIO_Init(GPIOE,&GPIO_InitStructure);

        /* FSMC_D13 ~ FSMC_D15   PD8 ~ PD10 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
        GPIO_Init(GPIOD,&GPIO_InitStructure);

        /*
        FSMC_A0 ~ FSMC_A5   FSMC_A6 ~ FSMC_A9
        PF0     ~ PF5       PF12    ~ PF15
        */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3
                                      | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
        GPIO_Init(GPIOF,&GPIO_InitStructure);

        /* FSMC_A10 ~ FSMC_A15  PG0 ~ PG5 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
        GPIO_Init(GPIOG,&GPIO_InitStructure);

        /* FSMC_A16 ~ FSMC_A18  PD11 ~ PD13 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
        GPIO_Init(GPIOD,&GPIO_InitStructure);

        /* RD-PD4 WR-PD5 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
        GPIO_Init(GPIOD,&GPIO_InitStructure);

        /* NBL0-PE0 NBL1-PE1 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
        GPIO_Init(GPIOE,&GPIO_InitStructure);

        /* NE1/NCE2 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
        GPIO_Init(GPIOD,&GPIO_InitStructure);
        /* NE2 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
        GPIO_Init(GPIOG,&GPIO_InitStructure);
        /* NE3 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
        GPIO_Init(GPIOG,&GPIO_InitStructure);
        /* NE4 */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
        GPIO_Init(GPIOG,&GPIO_InitStructure);
    }
    /* FSMC GPIO configure */

    /*-- FSMC Configuration -------------------------------------------------*/
    FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &Timing_read;
    FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &Timing_write;
    FSMC_NORSRAMStructInit(&FSMC_NORSRAMInitStructure);

    Timing_read.FSMC_AddressSetupTime = 8;             /* 地址建立时间  */
    Timing_read.FSMC_AddressHoldTime  = 8;             /* 地址保持时间  */
    Timing_read.FSMC_DataSetupTime = 8;                /* 数据建立时间  */
    Timing_read.FSMC_AccessMode = FSMC_AccessMode_A;    /* FSMC 访问模式 */

    Timing_write.FSMC_AddressSetupTime = 8;             /* 地址建立时间  */
    Timing_write.FSMC_AddressHoldTime  = 8;             /* 地址保持时间  */
    Timing_write.FSMC_DataSetupTime = 8;                /* 数据建立时间  */
    Timing_write.FSMC_AccessMode = FSMC_AccessMode_A;   /* FSMC 访问模式 */

    /* Color LCD configuration ------------------------------------
       LCD configured as follow:
          - Data/Address MUX = Disable
          - Memory Type = SRAM
          - Data Width = 16bit
          - Write Operation = Enable
          - Extended Mode = Enable
          - Asynchronous Wait = Disable */
    FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
    FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
    FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
    FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
//.........这里部分代码省略.........
开发者ID:gastonfeng,项目名称:rt-thread,代码行数:101,代码来源:ssd1289.c


示例12: CONF_TIMERS

void CONF_TIMERS(void)
{
	  GPIO_InitTypeDef GPIO_InitStructure;
	   NVIC_InitTypeDef NVIC_InitStructure;

	 RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB| RCC_AHBPeriph_GPIOE, ENABLE);

	  /* GPIOA Configuration: Channel 1, 2, 3 and 4 as alternate function push-pull */
	  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_11 | GPIO_Pin_13 | GPIO_Pin_14;
	  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
	  GPIO_Init(GPIOE, &GPIO_InitStructure);

	  GPIO_PinAFConfig(GPIOE, GPIO_PinSource9, GPIO_AF_2);
	  GPIO_PinAFConfig(GPIOE, GPIO_PinSource11, GPIO_AF_2);
	  GPIO_PinAFConfig(GPIOE, GPIO_PinSource13, GPIO_AF_2);
	  GPIO_PinAFConfig(GPIOE, GPIO_PinSource14, GPIO_AF_2);


	  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 , ENABLE);
	  TIM_TimeBaseStructure.TIM_Prescaler = 10;
	  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_CenterAligned1;
	  TIM_TimeBaseStructure.TIM_Period = 60000;
	  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
	  TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);

	  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
	  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
	  TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
	  TIM_OCInitStructure.TIM_Pulse = 3400;
	  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
	  TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
	  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
	  TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
	  TIM_OC1Init(TIM1, &TIM_OCInitStructure);
	  TIM_OCInitStructure.TIM_Pulse = 3400;

	  TIM_OC2Init(TIM1, &TIM_OCInitStructure);
	  TIM_OCInitStructure.TIM_Pulse = 3400;
	  TIM_OC3Init(TIM1, &TIM_OCInitStructure);
	  TIM_OCInitStructure.TIM_Pulse = 3400;
	  TIM_OC4Init(TIM1, &TIM_OCInitStructure);

	  TIM_Cmd(TIM1, ENABLE);
	  TIM_CtrlPWMOutputs(TIM1, ENABLE);
	  ////////////////////////////////////////////////////////////////////////////////////


	   /* TIM2 clock enable */
	   RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

	   /* GPIOB clock enable */
	   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

	   /* TIM2 chennel2 configuration : PA.01 */
	   GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1;
	   GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
	   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	   GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP ;
	   GPIO_Init(GPIOA, &GPIO_InitStructure);

	   /* Connect TIM pin to AF1 */
	   GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_1);

	   TIM_TimeBaseStructure.TIM_Prescaler = 360;
	   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	   TIM_TimeBaseStructure.TIM_Period = 65535;
	   TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	   TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
	   /* Enable the TIM2 global Interrupt */
	   NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
	   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
	   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	   NVIC_Init(&NVIC_InitStructure);
	   //////
	   TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
	   TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
	   TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
	   TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
	   TIM_ICInitStructure.TIM_ICFilter = 0x0;

	   TIM_PWMIConfig(TIM2, &TIM_ICInitStructure);

	   /* Select the TIM2 Input Trigger: TI2FP2 */
	   TIM_SelectInputTrigger(TIM2, TIM_TS_TI2FP2);

	   /* Select the slave Mode: Reset Mode */
	   TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);
	   TIM_SelectMasterSlaveMode(TIM2,TIM_MasterSlaveMode_Enable);

	   /* TIM enable counter */
	   TIM_Cmd(TIM2, ENABLE);

	   /* Enable the CC2 Interrupt Request */
	    TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE);

//.........这里部分代码省略.........
开发者ID:lennytraviano,项目名称:quadrocopter,代码行数:101,代码来源:main.c


示例13: main

int main(void)
{
	int scope1dt,scope1t,scope1s,scope1d,scope1j;
	int scope2dt,scope2t,scope2s,scope2d,scope2j;
	char znakr;
	char znak;
	GPIO_InitTypeDef GPIO_str;
	uint8_t ii;
	uint8_t i = 0;
  /* SysTick end of count event each 0,01ms 0,00001*/// 0,01ms -100000
	  RCC_GetClocksFreq(&RCC_Clocks);
	  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100000);

  /* Accelerometer Configuration */
  Acc_Config();
  Demo_GyroConfig();
  ii = SystemCoreClock;   /* This is a way to read the System core clock */

  CONF_TIMERS();
  CONF_PWMIN();

   confI2C();
   while(1)
   I2C_start();
/////////// Przyciski
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
GPIO_str.GPIO_Pin= GPIO_Pin_4 | GPIO_Pin_5;
GPIO_str.GPIO_Mode=GPIO_Mode_IN;
GPIO_str.GPIO_PuPd=GPIO_PuPd_UP;
GPIO_str.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_str);

ii = 0;
USART2_Init(115200);



 GPIO_SetBits(GPIOD, GPIO_Pin_0);


 	LEFT =3400;
 	RIGHT=3400;
 	FRONT=3400;
 	REAR=3400;
 	//delay_ms(4000);



 while (1)
 {

	esf=SystemCoreClock/360/(TIM2->CCR2);

	esd = (TIM2->CCR1*100);///(TIM2->CCR2);
	throttle=(int)(esd*32.0/156.0-1236.0);
	esf3=SystemCoreClock/360/(TIM3->CCR2);
	if(throttle>6600)
		throttle=3400;
	esd3 = (TIM3->CCR1*100);///(TIM3->CCR2);
	pitch_zadany=(float)(-6.0*esd3/1800.0+100.0)+0.0;
	if(pitch_zadany>40 || pitch_zadany<-40)
		pitch_zadany=0;

	esd4 = (TIM4->CCR1*100);
	roll_zadany=(float)(-6.0*esd4/1800.0+100.0);

	if(roll_zadany>40 || roll_zadany<-40)
		roll_zadany=0;

	//esd5 =(TIM8->CCR2*100)/TIM8->CCR1;
	//yaw_zadany=(float)(-6.0*esd5/1800.0+100.0);





	//if(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_5)==0)
	//flaga=0;









	//IMU///////////////////////////////////////////////////////
	Acc_ReadData(AccBuffer);
	for(i=0;i<3;i++)
	AccBuffer[i] /= 100.0f;
	acc_x=AccBuffer[0];
	acc_y=AccBuffer[1];
	acc_z=AccBuffer[2];
	Demo_GyroReadAngRate(Buffer);
	gyr_x=Buffer[0];
	gyr_y=Buffer[1];
	gyr_z=Buffer[2];
	MadgwickAHRSupdateIMU( -gyr_y*0.01745,  gyr_x*0.01745,  gyr_z*0.01745,  acc_x,  acc_y,  acc_z);
	roll=180/PI*atan2(2*(q2*q3+q0*q1),1-2*(q1*q1+q2*q2));//(q0*q0-q1*q1-q2*q2+q3*q3));
//.........这里部分代码省略.........
开发者ID:lennytraviano,项目名称:quadrocopter,代码行数:101,代码来源:main.c


示例14: main

void main(void)
{
  //CFG->GCR |= 0x01; //disable swim pin
  
  /* Configure the Fcpu to DIV1*/
  CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
  
   /* select Clock = 16 MHz */
  CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
  
  /* Configure the system clock to use HSI clock source and to run at 16Mhz */
  CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);
  
  CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
  
  CLK_HSICmd(ENABLE);
  
  FLASH_Config();
  
  EXTI_DeInit();
  
//You should add:
// Define FLASH programming time 
//FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);

//optbyte1 = FLASH_ReadOptionByte(0x4803); //255 by def
//optbyte2 = FLASH_ReadOptionByte(0x4804); //255 by def
/*
if (optbyte != 765)
{
FLASH_Unlock(FLASH_MEMTYPE_DATA);     // unlock data memory by passing the RASS key in the proper order
FLASH_ProgramOptionByte(0x4803, 0xFD);     // byte OPT2 resides at address x4803, write a 1 to bit 7.  This will also write to the NOPT2 complement byte
FLASH_Lock(FLASH_MEMTYPE_DATA);       // re-lock data memory
}
  */
  
  //General purpose timer
  TIM4_Config(); 

  #ifdef DFS_90
  HotAir_Config();
  #endif
  
  #ifndef DFS_90
  GPIO_Init(CONTROL_GPIO_PORT, CONTROL_GPIO_PIN, GPIO_MODE_OUT_PP_LOW_FAST);
  #endif
  
  Temperature_ADC_Config();  
  
  STM_EVAL_SEGInit(SEG1);
  STM_EVAL_SEGInit(SEG2);
  STM_EVAL_SEGInit(SEG3);
  
  STM_EVAL_LEDInit(LEDA);
  STM_EVAL_LEDInit(LEDB);
  STM_EVAL_LEDInit(LEDC);
  STM_EVAL_LEDInit(LEDD);
  STM_EVAL_LEDInit(LEDE);
  STM_EVAL_LEDInit(LEDF);
  STM_EVAL_LEDInit(LEDG);
  STM_EVAL_LEDInit(LEDP);

#ifndef SOLDERING_VAR2
  //STM_EVAL_LEDInit(LEDP);
#endif
//  STM_EVAL_SEGOn(SEG1);
//  STM_EVAL_SEGOn(SEG2);
//  STM_EVAL_SEGOn(SEG3);
//  
//  STM_EVAL_LEDOn(LEDA);
//  STM_EVAL_LEDOn(LEDB);
//  STM_EVAL_LEDOn(LEDC);
//  STM_EVAL_LEDOn(LEDD);
//  STM_EVAL_LEDOn(LEDE);
//  STM_EVAL_LEDOn(LEDF);
//  STM_EVAL_LEDOn(LEDG);
//  
//  STM_EVAL_LEDOff(LEDA);
//  STM_EVAL_LEDOff(LEDB);
//  STM_EVAL_LEDOff(LEDC);
//  STM_EVAL_LEDOff(LEDD);
//  STM_EVAL_LEDOff(LEDE);
//  STM_EVAL_LEDOff(LEDF);
//  STM_EVAL_LEDOff(LEDG);
//  STM_EVAL_LEDOff(LEDP);
//  
//  STM_EVAL_SEGOff(SEG1);
//  STM_EVAL_SEGOff(SEG2);
//  STM_EVAL_SEGOff(SEG3);
  
  
  //STM_EVAL_LEDOn(LEDP);
  //GPIO_Init(ENC_DN_BUTTON_PORT, ENC_DN_BUTTON_PIN, GPIO_MODE_IN_PU_NO_IT);
  //GPIO_Init(ENC_UP_BUTTON_PORT, ENC_UP_BUTTON_PIN, GPIO_MODE_IN_PU_NO_IT);
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_REED, BUTTON_MODE_GPIO);
  
  ssegInit();
//.........这里部分代码省略.........
开发者ID:ivandevel,项目名称:DSS-80E,代码行数:101,代码来源:main.c


示例15: GPIO_Config

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GPIO_OUTPUT_SET函数代码示例发布时间:2022-05-30
下一篇:
C++ GPIO_INPUT_GET函数代码示例发布时间: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