您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GPIO_Init函数代码示例

51自学网 2021-06-01 20:54:40
  C++
这篇教程C++ GPIO_Init函数代码示例写得很实用,希望能帮到您。

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

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


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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();/////////// PrzyciskiRCC_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,


示例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 orderFLASH_ProgramOptionByte(0x4803, 0xFD);     // byte OPT2 resides at address x4803, write a 1 to bit 7.  This will also write to the NOPT2 complement byteFLASH_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,


示例15: GPIO_Config

void GPIO_Config(void){ GPIO_InitTypeDef  GPIO_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_AHBPeriphClockCmd(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_APB2PeriphClockCmd(SD_SPI_CLK, ENABLE);  /*!< Configure SD_SPI pins: SCK */  GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN;  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(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);  /*!< Configure SD_SPI pins: MISO */  GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN;  GPIO_Init(SD_SPI_MISO_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_CS_PIN pin: SD Card CS pin */  GPIO_InitStructure.GPIO_Pin = SD_CS_PIN;  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;  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_IN;  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;  GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);  /* Connect PXx to SD_SPI_SCK */  GPIO_PinAFConfig(SD_SPI_SCK_GPIO_PORT, SD_SPI_SCK_SOURCE, SD_SPI_SCK_AF);  /* Connect PXx to SD_SPI_MISO */  GPIO_PinAFConfig(SD_SPI_MISO_GPIO_PORT, SD_SPI_MISO_SOURCE, SD_SPI_MISO_AF);  /* Connect PXx to SD_SPI_MOSI */  GPIO_PinAFConfig(SD_SPI_MOSI_GPIO_PORT, SD_SPI_MOSI_SOURCE, SD_SPI_MOSI_AF); /**************************************/  /* MCO config */  //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);  //GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_MCO);  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);  /* Output clock on MCO pin ---------------------------------------------*//*  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;  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_NOPULL;  GPIO_Init(GPIOA, &GPIO_InitStructure);  // pick one of the clocks to spew  //RCC_MCOConfig(RCC_MCOSource_SYSCLK); // Put on MCO pin the: System clock selected  RCC_MCOConfig(RCC_MCOSource_PLLCLK,RCC_MCODiv_1);  */}
开发者ID:pawelc06,项目名称:STM32,代码行数:76,


示例16: NAND_Init

/**  * @brief  Configures the FSMC and GPIOs to interface with the NAND memory.  *         This function must be called before any write/read operation on the   *         NAND.  * @param  None  * @retval None  */void NAND_Init(void){  GPIO_InitTypeDef GPIO_InitStructure;   FSMC_NAND_PCCARDTimingInitTypeDef  p;  FSMC_NANDInitTypeDef FSMC_NANDInitStructure;    /*FSMC总线使用的GPIO组时钟使能*/  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOE |                         RCC_AHB1Periph_GPIOF, ENABLE);  //RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);  RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);    /*FSMC CLE, ALE, D0->D3, NOE, NWE and NCE2初始化,推挽复用输出*/  /* GPIOD configuration */  GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource4, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource7, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource11, GPIO_AF_FSMC);   GPIO_PinAFConfig(GPIOD, GPIO_PinSource12, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource13, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FSMC);  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 |                                 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_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(GPIOD, &GPIO_InitStructure);  /* GPIOE configuration */  GPIO_PinAFConfig(GPIOE, GPIO_PinSource0 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource1 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource2 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource3 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource4 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource5 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource6 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource7 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource8 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource9 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource10 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource11 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource12 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource13 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource14 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOE, GPIO_PinSource15 , GPIO_AF_FSMC);  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_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);  /* GPIOF configuration */  GPIO_PinAFConfig(GPIOF, GPIO_PinSource0 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource1 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource2 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource3 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource4 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource5 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource12 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource13 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource14 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOF, GPIO_PinSource15 , GPIO_AF_FSMC);  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);  /* GPIOG configuration */  GPIO_PinAFConfig(GPIOG, GPIO_PinSource0 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOG, GPIO_PinSource1 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOG, GPIO_PinSource2 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOG, GPIO_PinSource3 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOG, GPIO_PinSource4 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOG, GPIO_PinSource5 , GPIO_AF_FSMC);  GPIO_PinAFConfig(GPIOG, GPIO_PinSource9 , GPIO_AF_FSMC);//.........这里部分代码省略.........
开发者ID:lxalxy,项目名称:SysID_Slave_MCU,代码行数:101,


示例17: PIOS_Board_Init

//.........这里部分代码省略.........            break;        case HWSETTINGS_RM_MAINPORT_DSMX11BIT:            proto = PIOS_DSM_PROTO_DSMX11BIT;            break;        default:            PIOS_Assert(0);            break;        }        // Force binding to zero on the main port        hwsettings_DSMxBind = 0;        // TODO: Define the various Channelgroup for Revo dsm inputs and handle here        PIOS_Board_configure_dsm(&pios_usart_dsm_main_cfg, &pios_dsm_main_cfg,                                 &pios_usart_com_driver, &proto, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT, &hwsettings_DSMxBind);    }    break;    case HWSETTINGS_RM_MAINPORT_DEBUGCONSOLE:#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)        {            PIOS_Board_configure_com(&pios_usart_main_cfg, 0, PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_debug_id);        }#endif /* PIOS_INCLUDE_DEBUG_CONSOLE */        break;    case HWSETTINGS_RM_MAINPORT_COMBRIDGE:        PIOS_Board_configure_com(&pios_usart_main_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_bridge_id);        break;    case HWSETTINGS_RM_MAINPORT_OSDHK:        PIOS_Board_configure_com(&pios_usart_hkosd_main_cfg, PIOS_COM_HKOSD_RX_BUF_LEN, PIOS_COM_HKOSD_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_hkosd_id);        break;    } /*        hwsettings_rm_mainport */    if (hwsettings_mainport != HWSETTINGS_RM_MAINPORT_SBUS) {        GPIO_Init(pios_sbus_cfg.inv.gpio, &pios_sbus_cfg.inv.init);        GPIO_WriteBit(pios_sbus_cfg.inv.gpio, pios_sbus_cfg.inv.init.GPIO_Pin, pios_sbus_cfg.gpio_inv_disable);    }    /* Configure FlexiPort */    uint8_t hwsettings_flexiport;    HwSettingsRM_FlexiPortGet(&hwsettings_flexiport);    switch (hwsettings_flexiport) {    case HWSETTINGS_RM_FLEXIPORT_DISABLED:        break;    case HWSETTINGS_RM_FLEXIPORT_TELEMETRY:        PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id);        break;    case HWSETTINGS_RM_FLEXIPORT_I2C:#if defined(PIOS_INCLUDE_I2C)        {            if (PIOS_I2C_Init(&pios_i2c_flexiport_adapter_id, &pios_i2c_flexiport_adapter_cfg)) {                PIOS_Assert(0);            }        }#endif /* PIOS_INCLUDE_I2C */        break;    case HWSETTINGS_RM_FLEXIPORT_GPS:        PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_GPS_RX_BUF_LEN, -1, &pios_usart_com_driver, &pios_com_gps_id);        break;    case HWSETTINGS_RM_FLEXIPORT_DSM2:    case HWSETTINGS_RM_FLEXIPORT_DSMX10BIT:    case HWSETTINGS_RM_FLEXIPORT_DSMX11BIT:    {        enum pios_dsm_proto proto;        switch (hwsettings_flexiport) {        case HWSETTINGS_RM_FLEXIPORT_DSM2:            proto = PIOS_DSM_PROTO_DSM2;
开发者ID:MorS25,项目名称:OpenPilot,代码行数:67,


示例18: CAN_Config

/**  * @brief  Configures the CAN.  * @param  None  * @retval None  */static void CAN_Config(void){  GPIO_InitTypeDef  GPIO_InitStructure;  NVIC_InitTypeDef  NVIC_InitStructure;  CAN_InitTypeDef   CAN_InitStructure;    /* CAN GPIOs configuration **************************************************/  /* Enable GPIO clock */  RCC_AHBPeriphClockCmd(CAN_GPIO_CLK, ENABLE);  /* Connect CAN pins to AF7 */  GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_RX_SOURCE, CAN_AF_PORT);  GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_TX_SOURCE, CAN_AF_PORT);     /* Configure CAN RX and TX pins */  GPIO_InitStructure.GPIO_Pin = CAN_RX_PIN | CAN_TX_PIN;  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(CAN_GPIO_PORT, &GPIO_InitStructure);  /* CAN NVIC  configuration **************************************************/    NVIC_InitStructure.NVIC_IRQChannel = CEC_CAN_IRQn;  NVIC_InitStructure.NVIC_IRQChannelPriority = 0;  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;  NVIC_Init(&NVIC_InitStructure);    /* CAN configuration ********************************************************/    /* Enable CAN clock */  RCC_APB1PeriphClockCmd(CAN_CLK, ENABLE);    /* CAN register init */  CAN_DeInit(CANx);  CAN_StructInit(&CAN_InitStructure);  /* CAN cell init */  CAN_InitStructure.CAN_TTCM = DISABLE;  CAN_InitStructure.CAN_ABOM = DISABLE;  CAN_InitStructure.CAN_AWUM = DISABLE;  CAN_InitStructure.CAN_NART = DISABLE;  CAN_InitStructure.CAN_RFLM = ENABLE;  CAN_InitStructure.CAN_TXFP = ENABLE;  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;      /* CAN Baudrate = 1MBps (CAN clocked at 36 MHz) */  CAN_InitStructure.CAN_BS1 = CAN_BS1_9tq;  CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq;  CAN_InitStructure.CAN_Prescaler = 2;  CAN_Init(CANx, &CAN_InitStructure);  /* CAN filter init "FIFO0" */  CAN_FilterInitStructure.CAN_FilterNumber = 0;  CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdList;  CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;  CAN_FilterInitStructure.CAN_FilterIdHigh = 0x6420;  CAN_FilterInitStructure.CAN_FilterIdLow = 0x2461;  CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;  CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;  CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;  CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;  CAN_FilterInit(&CAN_FilterInitStructure);    /* Transmit Structure preparation */  TxMessage.StdId = 0x321;  TxMessage.ExtId = 0x00;  TxMessage.RTR = CAN_RTR_DATA;  TxMessage.IDE = CAN_ID_STD;  TxMessage.DLC = 1;      /* Enable FIFO 0 full Interrupt */  CAN_ITConfig(CANx, CAN_IT_FF0, ENABLE);    /* Enable FIFO 1 full Interrupt */  CAN_ITConfig(CANx, CAN_IT_FF1, ENABLE);}
开发者ID:Lee-Kevin,项目名称:MotorBridgeCapeFirmwareSourceCode,代码行数:83,


示例19: main

int main(){	SysTick_Config(SystemCoreClock / 2000);  // 0.5ms	// NEED OF KEY AND LED	RCC_ClockSecuritySystemCmd(ENABLE);	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);	GPIO_InitTypeDef GPIO_InitStructure;	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;	GPIO_Init(GPIOB, &GPIO_InitStructure);	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;	GPIO_Init(GPIOB, &GPIO_InitStructure);	// Init LCD	LCD_Cmd_InitFSMC();	LCD_Cmd_Init();	LCD_Cmd_InitBacklight();	// Put some background//	LCD_FillRectangle_RGB565(0, 0, 240, 320, C_RGB565(0x80, 0x80, 0x80));	Painter_PutImage(res_img_res_lp_jpg,0,0,0xff);//	Painter_SetupContextBitmask(240, 320, 0);//	benchmark(2);	// A circle to overlay long shadow	LCD_FillCircle_RGB4444(120, 120, 100+18, 0x88fa);	// now you can see it	long_shadow();	// an alternative shadow//	LCD_FillCircle(120+1, 120+1, 100+2, 0x8886, 0);//	LCD_FillCircle(120, 120, 100+2, 0x8886, 0);//	LCD_FillCircle(120, 120, 100+1, 0x8886, 0);	// Put my clock panel on screen	LCD_FillCircle_RGB565(120, 120, 100, C_RGB565(0, 0, 0));	LCD_FillCircle_RGB565(120, 120, 90, C_RGB565(0xff, 0xff, 0xff));	// Clock frame need some shadow!	Painter_SetupContextBitmask(210, 210, 0);	u16 x, y, i;	u32 t;	for (x=0;x<200;x++) for (y=0;y<200;y++){		t = (x-100)*(x-100)+(y-100)*(y-100);		if ((t>=91*91)&&(t<100*100)) LCD_SetBitMask(_d_dl_ctx.bm, x, y, 210);	}	// Draw ticks and numbers	const s8 TICK_XI[] = { 0,  42,  73,  85,  73,  42,   0, -42, -73, -85, -73, -42};	const s8 TICK_YI[] = {-85, -73, -42,   0,  42,  73,  85,  73,  42,   0, -42, -73};	const s8 TICK_XO[] = { 0,  44,  77,  90,  77,  45,   0, -44, -77, -90, -77, -45};	const s8 TICK_YO[] = {-90, -77, -45,   0,  44,  77,  90,  77,  45,   0, -44, -77};	const u16 *text[] = {res_string_0/*_FSTR_0*/,			res_string_1/*_FSTR_1*/,			res_string_2/*_FSTR_2*/,			res_string_3/*_FSTR_3*/,			res_string_4/*_FSTR_4*/,			res_string_5/*_FSTR_5*/,			res_string_6/*_FSTR_6*/,			res_string_7/*_FSTR_7*/,			res_string_8/*_FSTR_8*/,			res_string_9/*_FSTR_9*/,			res_string_11/*_FSTR_10*/,			res_string_12/*_FSTR_11*/,			res_string_13/*_FSTR_12*/			};	const u16 *col = res_string_14/*_FSTR_:*/;	const u16 *space = res_string_15/*_FSTR_ */;	u16 time[20];	for (i=0;i<12;i++){		Painter_LocateContextBitmask(100+TICK_XO[i], 100+TICK_YO[i]);		Painter_DrawLine(120+TICK_XO[i], 120+TICK_YO[i], 120+TICK_XI[i], 120+TICK_YI[i], 0x000f, 5, PAINTER_DRAW_BM_HOLD);		Painter_PutString(text[i?i:12], 14, 0x000f, 0						 , 120+TICK_XI[i]-(TICK_XO[i]-TICK_XI[i])*2-5, 120+TICK_YI[i]-(TICK_YO[i]-TICK_YI[i])*2-8						 , 20, 20, PAINTER_STR_SHADOW*2);	}	// Bravo!	Painter_Fill_BitMaskShadow(30, 30, 230, 230, 0L, 10, 10, 210, 0x0008, 4, 4, 15);	// LET IT RUN!	u8 m, s; // so-called second and minute	bitmask bm;	_UNUSED(bm);	s = 0; m = 0;	Painter_SetupContextBitmask(200, 200, 0); // new context for new shadow	Painter_LocateContextBitmask(100, 100); // start from center	u8 shadow_on;	u16 bg[200*60];	// grab screen region, saving for later repaint	LCD_SetWindow(20, 240, 200, 60);	LCD_GetImage_RGB565(bg, 200*60);	while (1){		// PUSH BUTTON TO RUN REALLY FAST, WITHOUT SHADOW!		shadow_on = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)?PAINTER_STR_SHADOW*2:0;		LCD_FillCircle_RGB565(120, 120, 65, 0xffff); // Clear clock hands, sucks aha~//.........这里部分代码省略.........
开发者ID:MidoriYakumo,项目名称:OURSTM-MINI-demo_clock,代码行数:101,


示例20: servo_init

// PWM// TIM2 and TIM5 have CH1, CH2, CH3, CH4 on PA0-PA3 respectively// they are both 32-bit counters// 16-bit prescaler// TIM2_CH3 also on PB10 (used below)void servo_init(void) {    // TIM2 clock enable    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);    // for PB10    /*    // GPIOB Configuration: TIM2_CH3 (PB10)    GPIO_InitTypeDef GPIO_InitStructure;    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;    GPIO_Init(GPIOB, &GPIO_InitStructure);    // Connect TIM2 pins to AF1    GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_TIM2);    */    // for PA0, PA1, PA2, PA3    {        // GPIOA Configuration: TIM2_CH0, TIM2_CH1 (PA0, PA1)        GPIO_InitTypeDef GPIO_InitStructure;        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;        GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;        GPIO_Init(GPIOA, &GPIO_InitStructure);        // Connect TIM2 pins to AF1        GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_TIM2);        GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_TIM2);        GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_TIM2);        GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_TIM2);    }    // Compute the prescaler value so TIM2 runs at 100kHz    uint16_t PrescalerValue = (uint16_t) ((SystemCoreClock / 2) / 100000) - 1;    // Time base configuration    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;    TIM_TimeBaseStructure.TIM_Period = 2000; // timer cycles at 50Hz    TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;    TIM_TimeBaseStructure.TIM_ClockDivision = 0;    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);    // PWM Mode configuration    TIM_OCInitTypeDef TIM_OCInitStructure;    TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;    TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;    TIM_OCInitStructure.TIM_Pulse = 150; // units of 10us    TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;    TIM_OC1Init(TIM2, &TIM_OCInitStructure); // channel 1    TIM_OC2Init(TIM2, &TIM_OCInitStructure); // channel 2    TIM_OC3Init(TIM2, &TIM_OCInitStructure); // channel 3    TIM_OC4Init(TIM2, &TIM_OCInitStructure); // channel 4    // ?    TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Enable); // channel 1    TIM_OC2PreloadConfig(TIM2, TIM_OCPreload_Enable); // channel 2    TIM_OC3PreloadConfig(TIM2, TIM_OCPreload_Enable); // channel 3    TIM_OC4PreloadConfig(TIM2, TIM_OCPreload_Enable); // channel 4    // ?    TIM_ARRPreloadConfig(TIM2, ENABLE);    // TIM2 enable counter    TIM_Cmd(TIM2, ENABLE);}
开发者ID:genba,项目名称:micropython,代码行数:76,


示例21: LCD_GPIO_Config

/* * 函数名:LCD_GPIO_Config * 描述  :根据FSMC配置LCD的I/O * 输入  :无 * 输出  :无 * 调用  :内部调用         */ void LCD_GPIO_Config(void){    GPIO_InitTypeDef GPIO_InitStructure;        /* Enable the FSMC Clock */    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);        /* config lcd gpio clock base on FSMC */    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE);        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;        /* config tft back_light gpio base on the PT4101 */    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;		    GPIO_Init(GPIOD, &GPIO_InitStructure);        /* config tft rst gpio */    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_13 ; 	     GPIO_Init(GPIOC, &GPIO_InitStructure);  		           /* config tft data lines base on FSMC	 * data lines,FSMC-D0~D15: PD 14 15 0 1,PE 7 8 9 10 11 12 13 14 15,PD 8 9 10	 */	    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |                                   GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;    GPIO_Init(GPIOD, &GPIO_InitStructure);        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);         /* config tft control lines base on FSMC	 * PD4-FSMC_NOE  :LCD-RD   * PD5-FSMC_NWE  :LCD-WR	 * PD7-FSMC_NE1  :LCD-CS   * PD11-FSMC_A16 :LCD-DC	 */    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;     GPIO_Init(GPIOD, &GPIO_InitStructure);        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;     GPIO_Init(GPIOD, &GPIO_InitStructure);        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;     GPIO_Init(GPIOD, &GPIO_InitStructure);          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ;     GPIO_Init(GPIOD, &GPIO_InitStructure);          /* tft control gpio init */	     GPIO_SetBits(GPIOD, GPIO_Pin_13);		 // RST = 1 	    GPIO_SetBits(GPIOC, GPIO_Pin_5);	 	 //	LIGHT    GPIO_SetBits(GPIOD, GPIO_Pin_4);		 // RD = 1      GPIO_SetBits(GPIOD, GPIO_Pin_5);		 // WR = 1     GPIO_SetBits(GPIOD, GPIO_Pin_7);		 //	CS = 1 																			//   BL        RS      CS  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;	  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  GPIO_Init(GPIOA, &GPIO_InitStructure);	GPIO_ResetBits(GPIOA, GPIO_Pin_4);	GPIO_SetBits(GPIOC, GPIO_Pin_13);	 	 //	CS2		GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_7 | GPIO_Pin_5|GPIO_Pin_11;	  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  GPIO_Init(GPIOD, &GPIO_InitStructure);	GPIO_ResetBits(GPIOD, GPIO_Pin_7);}
开发者ID:txl0591,项目名称:PileDevices,代码行数:83,


示例22: be

/*	GPIOx: where x can be (A..H) to select the GPIO peripheral.	pinNumber: GPIO_Pin_0 ... GPIO_Pin_15, GPIO_Pin_All	GPIO_AF: stm32l1xx_gpio.c, search GPIO_AFSelection.	pinType: GPIO_OType_PP, GPIO_OType_OD - sets the pin type to push / pull  or open drain	pinPull: GPIO_PuPd_NOPULL, GPIO_PuPd_UP, GPIO_PuPd_DOWN	pinSpeed: GPIO_Speed_400KHz, GPIO_Speed_2MHz, GPIO_Speed_10MHz, GPIO_Speed_40MHz	gpio_pinSetup_AF(GPIOA, GPIO_Pin_2, GPIO_AF_TIM9, GPIO_OType_PP, GPIO_PuPd_UP, GPIO_Speed_2MHz);*/void gpio_pinSetup_AF(GPIO_TypeDef* GPIOx, uint32_t pinNumber, uint8_t GPIO_AF, GPIOOType_TypeDef pinType, GPIOPuPd_TypeDef pinPull, GPIOSpeed_TypeDef pinSpeed){	GPIO_InitTypeDef GPIO_setup;	uint32_t pinSource = 0;	/* Check the parameters */	assert_param(IS_GPIO_ALL_PERIPH(GPIOx));	if(GPIOx == GPIOA)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);	}	else if(GPIOx == GPIOB)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);	}	else if(GPIOx == GPIOC)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);	}	else if(GPIOx == GPIOD)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);	}	else if(GPIOx == GPIOE)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);	}	else if(GPIOx == GPIOF)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);	}	else if(GPIOx == GPIOG)	{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOG, ENABLE);	}   	else	{		if(GPIOx == GPIOH)		{		RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOH, ENABLE);		}	}	switch(pinNumber)	{		case GPIO_Pin_0: pinSource = GPIO_PinSource0; break;		case GPIO_Pin_1: pinSource = GPIO_PinSource1; break;		case GPIO_Pin_2: pinSource = GPIO_PinSource2; break;		case GPIO_Pin_3: pinSource = GPIO_PinSource3; break;		case GPIO_Pin_4: pinSource = GPIO_PinSource4; break;		case GPIO_Pin_5: pinSource = GPIO_PinSource5; break;		case GPIO_Pin_6: pinSource = GPIO_PinSource6; break;		case GPIO_Pin_7: pinSource = GPIO_PinSource7; break;		case GPIO_Pin_8: pinSource = GPIO_PinSource8; break;		case GPIO_Pin_9: pinSource = GPIO_PinSource9; break;		case GPIO_Pin_10: pinSource = GPIO_PinSource10; break;		case GPIO_Pin_11: pinSource = GPIO_PinSource11; break;		case GPIO_Pin_12: pinSource = GPIO_PinSource12; break;		case GPIO_Pin_13: pinSource = GPIO_PinSource13; break;		case GPIO_Pin_14: pinSource = GPIO_PinSource14; break;		case GPIO_Pin_15: pinSource = GPIO_PinSource15; break;			}	GPIO_PinAFConfig(GPIOx, pinSource, GPIO_AF);			GPIO_setup.GPIO_Pin		=	pinNumber;	GPIO_setup.GPIO_Mode 	= GPIO_Mode_AF;	GPIO_setup.GPIO_OType	=	pinType;	GPIO_setup.GPIO_PuPd 	=	pinPull;	GPIO_setup.GPIO_Speed	= pinSpeed;	GPIO_Init(GPIOx, &GPIO_setup);}
开发者ID:damogranlabs,项目名称:STM32L1,代码行数:82,


示例23: OSView_InitTarget

void  OSView_InitTarget (INT32U baud_rate){    GPIO_InitTypeDef        gpio_init;    USART_InitTypeDef       usart_init;    USART_ClockInitTypeDef  usart_clk_init;	OSView_TmrInit();                                    /* Initialize the free running timer          */                                                                /* ----------------- INIT USART STRUCT ---------------- */    usart_init.USART_BaudRate            = baud_rate;    usart_init.USART_WordLength          = USART_WordLength_8b;    usart_init.USART_StopBits            = USART_StopBits_1;    usart_init.USART_Parity              = USART_Parity_No ;    usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None;    usart_init.USART_Mode                = USART_Mode_Rx | USART_Mode_Tx;    usart_clk_init.USART_Clock           = USART_Clock_Disable;    usart_clk_init.USART_CPOL            = USART_CPOL_Low;    usart_clk_init.USART_CPHA            = USART_CPHA_2Edge;    usart_clk_init.USART_LastBit         = USART_LastBit_Disable;#if (OS_VIEW_COMM_SEL == OS_VIEW_UART_1)    BSP_PeriphEn(BSP_PERIPH_ID_USART1);                                                                /* ----------------- SETUP USART1 GPIO ---------------- */    BSP_PeriphEn(BSP_PERIPH_ID_IOPA);                                                                /* Configure GPIOA.9 as push-pull                       */    gpio_init.GPIO_Pin   = GPIO_Pin_9;    gpio_init.GPIO_Speed = GPIO_Speed_50MHz;    gpio_init.GPIO_Mode  = GPIO_Mode_AF_PP;    GPIO_Init(GPIOA, &gpio_init);                                                                /* Configure GPIOA.10 as input floating                 */    gpio_init.GPIO_Pin   = GPIO_Pin_10;    gpio_init.GPIO_Mode  = GPIO_Mode_IN_FLOATING;    GPIO_Init(GPIOA, &gpio_init);                                                                /* ------------------ SETUP USART1 -------------------- */    USART_Init(USART1, &usart_init);    USART_ClockInit(USART1, &usart_clk_init);    USART_Cmd(USART1, ENABLE);    BSP_IntVectSet(BSP_INT_ID_USART1, OSView_RxTxISRHandler);    BSP_IntEn(BSP_INT_ID_USART1);#endif#if (OS_VIEW_COMM_SEL == OS_VIEW_UART_2)    BSP_PeriphEn(BSP_PERIPH_ID_USART2);                                                                /* ----------------- SETUP USART2 GPIO ---------------- */    BSP_PeriphEn(BSP_PERIPH_ID_IOPA);                                                                /* Configure GPIOA.2 as push-pull                       */    gpio_init.GPIO_Pin   = GPIO_Pin_2;    gpio_init.GPIO_Speed = GPIO_Speed_50MHz;    gpio_init.GPIO_Mode  = GPIO_Mode_AF_PP;    GPIO_Init(GPIOA, &gpio_init);                                                                /* Configure GPIOA.3 as input floating                  */    gpio_init.GPIO_Pin   = GPIO_Pin_3;    gpio_init.GPIO_Mode  = GPIO_Mode_IN_FLOATING;    GPIO_Init(GPIOA, &gpio_init);                                                                /* ------------------ SETUP USART2 -------------------- */    USART_Init(USART2, &usart_init);    USART_ClockInit(USART2, &usart_clk_init);    USART_Cmd(USART2, ENABLE);    BSP_IntVectSet(BSP_INT_ID_USART2, OSView_RxTxISRHandler);    BSP_IntEn(BSP_INT_ID_USART2);#endif#if (OS_VIEW_COMM_SEL == OS_VIEW_UART_3)    BSP_PeriphEn(BSP_PERIPH_ID_USART3);                                                                /* ----------------- SETUP USART3 GPIO ---------------- */    BSP_PeriphEn(BSP_PERIPH_ID_IOPB);                                                                /* Configure GPIOB.10 as push-pull                      */    gpio_init.GPIO_Pin   = GPIO_Pin_10;    gpio_init.GPIO_Speed = GPIO_Speed_50MHz;    gpio_init.GPIO_Mode  = GPIO_Mode_AF_PP;    GPIO_Init(GPIOB, &gpio_init);                                                                /* Configure GPIOB.11 as input floating                 */    gpio_init.GPIO_Pin   = GPIO_Pin_11;    gpio_init.GPIO_Mode  = GPIO_Mode_IN_FLOATING;    GPIO_Init(GPIOB, &gpio_init);                                                                /* ------------------ SETUP USART3 -------------------- */    USART_Init(USART3, &usart_init);    USART_ClockInit(USART3, &usart_clk_init);    USART_Cmd(USART3, ENABLE);    BSP_IntVectSet(BSP_INT_ID_USART3, OSView_RxTxISRHandler);//.........这里部分代码省略.........
开发者ID:jiraiyav5,项目名称:gprs,代码行数:101,


示例24: TIM_Config

/**  * @brief  Configure the TIM2 Pins.  * @param  None  * @retval None  */static void TIM_Config(void){  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;  TIM_ICInitTypeDef  TIM_ICInitStructure;  TIM_OCInitTypeDef  TIM_OCInitStructure;  GPIO_InitTypeDef GPIO_InitStructure;  /* TIM4 clock enable */  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);  /* GPIOA clock enable */  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);    /* TIM2_CH1 pin (PA.05) and TIM2_CH2 pin (PA.01) configuration */  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_5;  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_NOPULL;  GPIO_Init(GPIOA, &GPIO_InitStructure);  /* Connect TIM pins to AF2 */  GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_2);  GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_2);   /* --------------------------------------------------------------------------    TIM2 configuration: One Pulse mode    The external signal is connected to TIM2_CH2 pin (PA.01),     The Rising edge is used as active edge,    The One Pulse signal is output on TIM2_CH1 pin (PA.05)    The TIM_Pulse defines the delay value     The (TIM_Period -  TIM_Pulse) defines the One Pulse value.         TIM2 input clock (TIM2CLK) is set to APB1 clock (PCLK1)         TIM2CLK = PCLK1        PCLK1 = HCLK        => TIM2CLK = HCLK  = SystemCoreClock     TIM2CLK = SystemCoreClock, we want to get TIM2 counter clock at 24 MHz:     Prescaler = (TIM2CLK / TIM2 counter clock) - 1     Prescaler = (SystemCoreClock  /24 MHz) - 1         The Autoreload value is 65535 (TIM2->ARR), so the maximum frequency value     to trigger the TIM2 input is 24000000/65535 = 366.2 Hz.    The TIM_Pulse defines the delay value, this value is fixed to:        delay =  CCR1/TIM2 counter clock = 682.6 us.         The (TIM_Period - TIM_Pulse) defines the One Pulse value, this value is fixed to:        One Pulse value = (TIM_Period - TIM_Pulse) / TIM2 counter clock = 2.04 ms.    Note:      SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f0xx.c file.     Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate()     function to update SystemCoreClock variable value. Otherwise, any configuration     based on this variable will be incorrect.      --------------------------------------------------------------------------- */  /* Compute the prescaler value */  PrescalerValue = (uint16_t) ((SystemCoreClock ) / 24000000) - 1;    /* Time base configuration */  TIM_TimeBaseStructure.TIM_Period = 65535;  TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;  TIM_TimeBaseStructure.TIM_ClockDivision = 0;  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);  /* TIM2 PWM2 Mode configuration: Channel1 */  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;  TIM_OCInitStructure.TIM_Pulse = 16383;  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;  TIM_OC1Init(TIM2, &TIM_OCInitStructure);  /* TIM4 configuration in Input Capture Mode */  TIM_ICStructInit(&TIM_ICInitStructure);  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 = 0;  TIM_ICInit(TIM2, &TIM_ICInitStructure);  /* One Pulse Mode selection */  TIM_SelectOnePulseMode(TIM2, TIM_OPMode_Single);  /* Input Trigger selection */  TIM_SelectInputTrigger(TIM2, TIM_TS_TI2FP2);//.........这里部分代码省略.........
开发者ID:Azizou,项目名称:stm32f0_devel,代码行数:101,


示例25: USB_OTG_BSP_Init

void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev){  GPIO_InitTypeDef GPIO_InitStructure;#ifndef USE_ULPI_PHY #ifdef USB_OTG_FS_LOW_PWR_MGMT_SUPPORT  EXTI_InitTypeDef EXTI_InitStructure;  NVIC_InitTypeDef NVIC_InitStructure; #endif  #endif    #ifdef USE_USB_OTG_FS   RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE);      /* Configure SOF VBUS ID DM DP Pins */  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8  |     GPIO_Pin_9  |       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_PinSource9,GPIO_AF_OTG1_FS) ;   GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ;   GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ;    /* this for ID line debug */      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:goking,项目名称:mrduino,代码行数:101,


示例26: i2cInit

void i2cInit(){	NVIC_InitTypeDef nvic;	I2C_InitTypeDef i2c;	GPIO_InitTypeDef  GPIO_InitStructure;	//Enable the i2c	RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);	//Reset the Peripheral	RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);	RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);	//Enable the GPIOs for the SCL/SDA Pins	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);	//Configure and initialize the GPIOs	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;	GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;	GPIO_Init(GPIOB, &GPIO_InitStructure);	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;	GPIO_Init(GPIOB, &GPIO_InitStructure);	//Connect GPIO pins to peripheral	GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_I2C1);	GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_I2C1);	// clock out stuff to make sure slaves arent stuck	// This will also configure GPIO as AF_OD at the end	//i2cUnstick();	// Init I2C peripheral	I2C_DeInit(I2C1);	I2C_StructInit(&i2c);	I2C_ITConfig(I2C1, I2C_IT_EVT | I2C_IT_ERR, DISABLE);               // Enable EVT and ERR interrupts - they are enabled by the first request	i2c.I2C_Mode = I2C_Mode_I2C;	i2c.I2C_DutyCycle = I2C_DutyCycle_2;	i2c.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;	i2c.I2C_Ack = I2C_Ack_Enable;	i2c.I2C_OwnAddress1 = 0;	i2c.I2C_ClockSpeed =  100000;	I2C_Init(I2C1, &i2c);	I2C_Cmd(I2C1, ENABLE);	// I2C ER Interrupt	nvic.NVIC_IRQChannel = I2C1_ER_IRQn;	nvic.NVIC_IRQChannelPreemptionPriority = 0;	nvic.NVIC_IRQChannelSubPriority = 2;	nvic.NVIC_IRQChannelCmd = ENABLE;	NVIC_Init(&nvic);	// I2C EV Interrupt	nvic.NVIC_IRQChannel = I2C1_EV_IRQn;	nvic.NVIC_IRQChannelPreemptionPriority = 0;	nvic.NVIC_IRQChannelSubPriority = 2;	NVIC_Init(&nvic);}
开发者ID:tommyleo,项目名称:speedyflight,代码行数:63,


示例27: sens9DInit

void sens9DInit(void){	//PB10/I2C2_SCL, PB11/I2C2_SDA	// XM Read Address 8bit 0x3B, Gyro 8bit Read 0xD7	GPIO_InitTypeDef      GPIO_InitStructure;	I2C_InitTypeDef  I2C_InitStructure;	u8 statOk=!0;	int i;	I2C_DeInit(I2C2);	I2C_Cmd(I2C2, DISABLE);	I2C_SoftwareResetCmd(I2C2, ENABLE);	I2C_SoftwareResetCmd(I2C2, DISABLE);	RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2,ENABLE);	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB,ENABLE);	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_11;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;	GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;	GPIO_Init(GPIOB, &GPIO_InitStructure);	GPIOB->BSRRL=GPIO_Pin_10|GPIO_Pin_11;	i=8;	while( (i--) && ((GPIOB->IDR&GPIO_Pin_11)==0)){		delay_us(200);		GPIOB->BSRRH=GPIO_Pin_10;		delay_us(200);		GPIOB->BSRRL=GPIO_Pin_10;	}	GPIO_PinAFConfig(GPIOB,GPIO_PinSource10, GPIO_AF_I2C2);	GPIO_PinAFConfig(GPIOB,GPIO_PinSource11, GPIO_AF_I2C2);	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;	GPIO_Init(GPIOB, &GPIO_InitStructure);	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;	I2C_InitStructure.I2C_OwnAddress1 = 0x01;	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;	I2C_InitStructure.I2C_ClockSpeed=100e3;	I2C_InitStructure.I2C_DutyCycle=I2C_DutyCycle_16_9;	I2C_Init(I2C2, &I2C_InitStructure);	I2C_StretchClockCmd(I2C2,ENABLE);	//I2C_GeneralCallCmd(I2C1,ENABLE);	//I2C_AnalogFilterCmd(I2C2,ENABLE);	//I2C_DigitalFilterConfig(I2C2,0x02); Not available on 407.. :(	I2C_Cmd(I2C2, ENABLE);	delay_us(1e3);	//CTRL_REG1_G to CTRL_REG5_G 0x20..0x24	//190Hz, 25Hz cut	//0.45Hz HPass	//Full scale 2000dps	//HPass ΝΟΤ selected	//					20h			21h				22h			23h			24h	u8 GyroCTRreg[5]={0b01111111, 0b00100101,	0b00000000,	0b10100000,	0b00000000 };//24h ->0b00000000 disables LPF2 //Enable 0b00000010	I2C_write(Gy_addr,0x20|0x80,GyroCTRreg,5);	// HP filter bypassed	//					1Fh			20h			21h			22h			23h			24h			25h			26h	u8 XM_CTRreg[8]={0b00000000, 0b01111111, 0b11001000, 0b00000000, 0b00000000, 0b11110100, 0b00000000, 0b00000000 };//200Hz, 50HzBW, 4G, Magn:100Hz,2Gauss	I2C_write(XM_addr,0x1F|0x80,XM_CTRreg,8);}
开发者ID:librespacefoundation,项目名称:upsat-adcs-software,代码行数:71,


示例28: spi_init

bool spi_init(){	//  --- clocks ----	GPIO_InitTypeDef GPIO_InitStructure;	/*!< Enable the SPI clock */	RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);	/*!< Enable GPIO clocks */	RCC_AHB1PeriphClockCmd(SPI_SCK_GPIO_CLK | SPI_MISO_GPIO_CLK |						 SPI_MOSI_GPIO_CLK | SPI_CS_GPIO_CLK, ENABLE);	//  --- GPIOs ----	/*!< Connect SPI pins to AF */	GPIO_PinAFConfig(SPI_SCK_GPIO_PORT,  SPI_SCK_GPIO_PINSOURCE,  GPIO_AF_SPI2);	GPIO_PinAFConfig(SPI_MISO_GPIO_PORT, SPI_MISO_GPIO_PINSOURCE, GPIO_AF_SPI2);	GPIO_PinAFConfig(SPI_MOSI_GPIO_PORT, SPI_MOSI_GPIO_PINSOURCE, GPIO_AF_SPI2);	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_DOWN;	/*!< SPI SCK pin configuration */	GPIO_InitStructure.GPIO_Pin = SPI_SCK_GPIO_PIN;	GPIO_Init(SPI_SCK_GPIO_PORT, &GPIO_InitStructure);	/*!< SPI MOSI pin configuration */	GPIO_InitStructure.GPIO_Pin =  SPI_MOSI_GPIO_PIN;	GPIO_Init(SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);	/*!< SPI MISO pin configuration */	GPIO_InitStructure.GPIO_Pin =  SPI_MISO_GPIO_PIN;	GPIO_Init(SPI_MISO_GPIO_PORT, &GPIO_InitStructure);	/*!< Configure CS pin in output pushpull mode ********************/	GPIO_InitStructure.GPIO_Pin = SPI_CS_GPIO_PIN;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;	GPIO_Init(SPI_CS_GPIO_PORT, &GPIO_InitStructure);	// ---- SPI ----	SPI_InitTypeDef  SPI_InitStructure;	/*!< Deselect bus: Chip Select high */	spi_CS_high();	/*!< SPI configuration */	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_64; // lets go slow first	SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;	SPI_InitStructure.SPI_CRCPolynomial = 7;	SPI_Init(SPI2, &SPI_InitStructure);	/*!< Enable the sFLASH_SPI  */	SPI_Cmd(SPI2, ENABLE);	return true;}
开发者ID:hooyah,项目名称:STM32F4x_Quadcopter,代码行数:72,


示例29: uarts_regist

/*************************************************************************************************** * @fn      uarts_regist * * @brief   串口资源注册 * @param   NULL * @return  null ***************************************************************************************************/  void uarts_regist(void){	GPIO_InitTypeDef 	GPIO_InitStructure;	NVIC_InitTypeDef    NVIC_InitStructure;  	USART_InitTypeDef   USART_InitStructure;  	DMA_InitTypeDef     DMA_InitStructure;	uint32_t            temp;	//USART_S_PORT_TxPin	RCC_AHB1PeriphClockCmd(USART_S_PORT_GPIO_CLK, ENABLE);	GPIO_InitStructure.GPIO_Pin = USART_S_PORT_TxPin ;	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(USART_S_PORT_GPIO, &GPIO_InitStructure);	GPIO_PinAFConfig(USART_S_PORT_GPIO, USART_S_PORT_Tx_Pinsource, USART_S_PORT_GPIO_AF);	//USART_S_PORT_RxPin	GPIO_InitStructure.GPIO_Pin = USART_S_PORT_RxPin ;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;	GPIO_Init(USART_S_PORT_GPIO, &GPIO_InitStructure);	GPIO_PinAFConfig(USART_S_PORT_GPIO, USART_S_PORT_Rx_Pinsource, USART_S_PORT_GPIO_AF);	//USARTdbg_TxPin	RCC_AHB1PeriphClockCmd(USARTdbg_GPIO_CLK, ENABLE);	GPIO_InitStructure.GPIO_Pin = USARTdbg_TxPin ;	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(USARTdbg_GPIO, &GPIO_InitStructure);	GPIO_PinAFConfig(USARTdbg_GPIO, USARTdbg_Tx_Pinsource, USARTdbg_GPIO_AF);	//USARTdbg_RxPin	GPIO_InitStructure.GPIO_Pin = USARTdbg_RxPin ;	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;	GPIO_Init(USARTdbg_GPIO, &GPIO_InitStructure);	GPIO_PinAFConfig(USARTdbg_GPIO, USARTdbg_Rx_Pinsource, USARTdbg_GPIO_AF);	//---------------------USART_S_PORT串口功能配置---------------------	//打开串口对应的外设时钟  	RCC_APB1PeriphClockCmd(USART_S_PORT_CLK, ENABLE); 	//串口发DMA配置  	//启动DMA时钟	RCC_AHB1PeriphClockCmd(USART_S_PORT_DMA_CLK, ENABLE);	//DMA1通道配置	//关闭通道	DMA_Cmd(USART_S_PORT_Tx_DMA_STREAM,DISABLE);	DMA_DeInit(USART_S_PORT_Tx_DMA_STREAM);	//通道地址	DMA_InitStructure.DMA_Channel = USART_S_PORT_Tx_DMA_Channel;	//外设地址	DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&USART_S_PORT->DR);	//内存地址	DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)Sport_TxBuffer;	//dma传输方向单向	DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;	//设置DMA在传输时缓冲区的长度	DMA_InitStructure.DMA_BufferSize = S_PORT_TX_BUFF_LEN;	//设置DMA的外设递增模式,一个外设	DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;	//设置DMA的内存递增模式	DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;	//外设数据字长	DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;	//内存数据字长	DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Byte;	//设置DMA的传输模式	DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;	//设置DMA的优先级别	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(USART_S_PORT_Tx_DMA_STREAM,&DMA_InitStructure);	//清中断	DMA_ClearITPendingBit(USART_S_PORT_Tx_DMA_STREAM, USART_S_PORT_Tx_DMA_FLAG);	//使能中断	DMA_ITConfig(USART_S_PORT_Tx_DMA_STREAM,DMA_IT_TC,ENABLE);	//串口收DMA配置  	//关闭通道	DMA_Cmd(USART_S_PORT_Rx_DMA_STREAM,DISABLE);	DMA_DeInit(USART_S_PORT_Rx_DMA_STREAM);	//通道地址	DMA_InitStructure.DMA_Channel = USART_S_PORT_Rx_DMA_Channel;//.........这里部分代码省略.........
开发者ID:tusimbe,项目名称:rc_controller,代码行数:101,



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


C++ GPIO_OUTPUT_SET函数代码示例
C++ GPIO_INPUT_GET函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。