<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > STM32串口通信和I/O口簡(jiǎn)單代碼

STM32串口通信和I/O口簡(jiǎn)單代碼

作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò ) 收藏
#include
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"



int main(void)
{
u8 k; //點(diǎn)亮的燈位數
u8 i;
Stm32_Clock_Init(9); //系統時(shí)鐘初始化
delay_init(72); //延時(shí)初始化
uart_init(72,9600); //串口初始化
led_init(); //燈I/O配置初始化
while(1)
{
if(USART_RX_STA&0x80) //接受到數據判斷
{
printf("you send massage is :");
for(i=0;i<(USART_RX_STA&0x3f);i++)
{
USART1->DR=USART_RX_BUF[i]; //把接受到的數據傳給電腦
k=USART_RX_BUF[2]-0x30; //接受到要開(kāi)發(fā)的燈泡值
}
USART_RX_STA=0; //接受位清零
}
if(k==1)LED1=0; //判斷點(diǎn)亮那個(gè)燈
if(k==2)LED2=0;
if(k==3)LED3=0;
if(k==4)LED4=0;
if(k==5)LED5=0;
if(k==6)LED6=0;
if(k==7)LED7=0;
if(k==8)LED8=0;

}
}

//-------------------------------------燈配置庫函數---------------

#include
#include "led.h"


void led_init()
{
RCC->APB2ENR|=1<<3; //時(shí)能PORTB時(shí)鐘
GPIOB->CRL&=0x00000000; //清空寄存器值
GPIOB->CRL|=0x33333333; //推挽輸出
GPIOB->ODR=0xffff;

}


#ifndef _led_h
#define _led_h


void led_init(void);
#define LED1 PBout(0)
#define LED2 PBout(1)
#define LED3 PBout(2)
#define LED4 PBout(3)
#define LED5 PBout(4)
#define LED6 PBout(5)
#define LED7 PBout(6)
#define LED8 PBout(7)

#endif



關(guān)鍵詞: STM32串口通信IO

評論


技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>