91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-10
  • 語言: 其他
  • 標簽: stm32??uart??

資源簡介

stm32 實現串口通訊 uart1 電腦串口發送、接收數據,已測試通過。

資源截圖

代碼片段和文件信息


/*?Includes?------------------------------------------------------------------*/
#include?“stm32f10x_conf.h“
#include?“stm32f10x.h“
#include?“stm32_eval.h“
#include?

//-------------------------------------------GPIO初始化-----------------------------------------//
void?RCC_Config(void)//初始化時鐘??????
{???
??RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1?|?RCC_APB2Periph_GPIOA???
???????????????????????|?RCC_APB2Periph_GPIOB?|?RCC_APB2Periph_AFIO?ENABLE);??
}??

void?GPIO_Config(void)
{
??????GPIO_InitTypeDef?GPIO_InitStructure;???????
??????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_2?|?GPIO_Pin_3?;//|?GPIO_Pin_10?|?GPIO_Pin_9
??????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP;
??????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
??????GPIO_Init(GPIOA?&GPIO_InitStructure);??????
}

void?GPIO_UART1_Config(void)//引腳初始化??
{??
????GPIO_InitTypeDef?GPIO_InitStructure;??
????/*?Configure?USART1?Tx?(PA.09)?as?alternate?function?push-pull?*/????
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_9;????
????GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;????
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;??
????GPIO_Init(GPIOA?&GPIO_InitStructure);??
????/*?Configure?USART1?Rx?(PA.10)?as?input?floating?*/??
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_10;??
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;??
????GPIO_Init(GPIOA?&GPIO_InitStructure);???????
}??

void?USART_Config(void)?//串口初始化??
{??
????USART_InitTypeDef?USART_InitStructure;??
????USART_InitStructure.USART_BaudRate?=?9600;??
????USART_InitStructure.USART_WordLength?=?USART_WordLength_8b;??
????USART_InitStructure.USART_StopBits?=?USART_StopBits_1;??
????USART_InitStructure.USART_Parity?=?USART_Parity_No;??
????USART_InitStructure.USART_HardwareFlowCon

評論

共有 條評論