3 qq_36422902

尚未进行身份认证

暂无相关描述

等级
TA的下载次数 2

stm32串口1和串口3数据互通

stm32串口1和串口3数据互通,经测试同时发256字节不丢包 void usart3_init(u32 bound) { NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; RCC_APB2PeriphClockCmd&#40;RCC_APB2Periph_GPIOB, ENABLE&#41;; // GPIOBʱÖÓ RCC_APB1PeriphClockCmd&#40;RCC_APB1Periph_USART3,ENABLE&#41;; //´®¿Ú3ʱÖÓʹÄÜ USART_DeInit(USART3); //¸´Î»´®¿Ú3 //USART3_TX PB10 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PB10 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //¸´ÓÃÍÆÍìÊä³ö GPIO_Init(GPIOB, &GPIO;_InitStructure); //³õʼ»¯PB10 //USART3_RX PB11 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//¸¡¿ÕÊäÈë GPIO_Init(GPIOB, &GPIO;_InitStructure); //³õʼ»¯PB11 USART_InitStructure.USART_BaudRate = bound;//²¨ÌØÂÊÒ»°ãÉèÖÃΪ9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×Ö³¤Îª8λÊý¾Ý¸ñʽ 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_Init(USART3, &USART;_InitStructure); //³õʼ»¯´®¿Ú 3 USART_Cmd&#40;USART3, ENABLE&#41;; //ʹÄÜ´®¿Ú //ʹÄܽÓÊÕÖÐ¶Ï USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);//¿ªÆôÖÐ¶Ï //ÉèÖÃÖжÏÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ;//ÇÀÕ¼ÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //×ÓÓÅÏȼ¶3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨµÀʹÄÜ NVIC_Init(&NVIC;_InitStructure); //¸ù¾ÝÖ¸¶¨µÄ²ÎÊý³õʼ»¯VIC¼Ä´æÆ÷ TIM4_Int_Init(1000-1,7200-1); //10msÖÐ¶Ï USART3_RX_STA=0; //ÇåÁã TIM_Cmd&#40;TIM4,DISABLE&#41;; //¹Ø±Õ¶¨Ê±Æ÷7 } //´®¿Ú3,printf º¯Êý //È·±£Ò»´Î·¢ËÍÊý¾Ý²»³¬¹ýUSART3_MAX_SEND_LEN×Ö½Ú void u3_printf(char* fmt,...) { u16 i,j; va_list ap; va_start(ap,fmt); vsprintf((char*)USART3_TX_BUF,fmt,ap); va_end(ap); i=strlen((const char*)USART3_TX_BUF); //´Ë´Î·¢ËÍÊý¾ÝµÄ³¤¶È for(j=0;j<i;j++) //Ñ­»··¢ËÍÊý¾Ý { while(USART_GetFlagStatus(USART3,USART_FLAG_TC)==RESET); //Ñ­»··¢ËÍ,Ö±µ½·¢ËÍÍê±Ï USART_SendData(USART3,USART3_TX_BUF[j]); } }

2018-04-19

STM32指纹识别程序

unsigned char LCD_ID_11[16] = {" Huan Ying "}; unsigned char LCD_ID_22[16] = {" Shi Bai "}; unsigned char LCD_ID_33[16] = {" Qing Shi Yong "}; void FPMXX_Check_Module() { unsigned int i=0; FPMXX_Cmd_Check(); for(i=0;i<12;i++) { FPMXX_RECEICE_BUFFER[i] = UART_Receive_Byte();//UART Receive a byteg } if(FPMXX_RECEICE_BUFFER[8]==0x03) { for(i=0;i<556;i++) { switch(i) { case 37:FPMXX_RECEICE_BUFFER[1] = UART_Receive_Byte();break; case 38:FPMXX_RECEICE_BUFFER[2] = UART_Receive_Byte();break; case 39:FPMXX_RECEICE_BUFFER[3] = UART_Receive_Byte();break; case 40:FPMXX_RECEICE_BUFFER[4] = UART_Receive_Byte();break; case 41:FPMXX_RECEICE_BUFFER[5] = UART_Receive_Byte();break; default:FPMXX_RECEICE_BUFFER[0] = UART_Receive_Byte(); } } //判断指纹识别模块型号 if(FPMXX_RECEICE_BUFFER[1] == 0x46 && + FPMXX_RECEICE_BUFFER[2] == 0x50 && + FPMXX_RECEICE_BUFFER[3] == 0x4D && + FPMXX_RECEICE_BUFFER[4] == 0x31 && + FPMXX_RECEICE_BUFFER[5] == 0x30) { L1602_string(1,1,LCD_ID_11); while(1) { if(KEY0 == 0) { Delay_Ms(10); while(KEY0 == 0); Delay_Ms(100); break; } Delay_Ms(100); } } } }

2018-04-16
勋章 我的勋章
    暂无奖章