标签:its usart ini alt init mod pull hardware tst
1 u8 _data1[4]; 2 void Configuration(void) 3 { 4 USART_InitTypeDef USART_InitStructure; 5 DMA_InitTypeDef DMA_InitStructure; 6 GPIO_InitTypeDef GPIO_InitStructure; 7 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); 8 //TX 9 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 10 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 11 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 12 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; 13 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 14 GPIO_Init(GPIOB, &GPIO_InitStructure); 15 //RX 16 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; 17 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 18 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 19 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 20 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 21 GPIO_Init(GPIOB, &GPIO_InitStructure); 22 23 GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3); 24 GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3); 25 26 DMA_InitStructure.DMA_Channel = DMA_Channel_4; 27 DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(USART3->DR); 28 DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)_data1; 29 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; 30 DMA_InitStructure.DMA_BufferSize = 4; 31 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; 32 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; 33 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; 34 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; 35 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; 36 DMA_InitStructure.DMA_Priority = DMA_Priority_High; 37 DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; 38 DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; 39 DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; 40 DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; 41 DMA_Init(DMA1_Stream1, &DMA_InitStructure); 42 DMA_Cmd(DMA1_Stream1, ENABLE); 43 44 USART_OverSampling8Cmd(USART3, ENABLE); 45 USART_InitStructure.USART_BaudRate = 38400; 46 USART_InitStructure.USART_WordLength = USART_WordLength_8b; 47 USART_InitStructure.USART_StopBits = USART_StopBits_1; 48 USART_InitStructure.USART_Parity = USART_Parity_No; 49 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 50 USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx; 51 USART_Init(USART3, &USART_InitStructure); 52 USART_DMACmd(USART3, USART_DMAReq_Rx, ENABLE); 53 DMA_Cmd(DMA1_Stream1, ENABLE); 54 USART_Cmd(USART3, ENABLE); 55 }
标签:its usart ini alt init mod pull hardware tst
原文地址:https://www.cnblogs.com/penuel/p/11264369.html