tim4c123g蓝牙小车.txt
#include"stdio.h" #include #include #include "inc/tm4c123gh6pm.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/pwm.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/uart.h" #include "driverlib/interrupt.h" #include "inc/hw_gpio.h" #include "inc/hw_ints.h" // //***************** ***UART_GPIO初始化************************ int uartmain(void) { int i; char thischar; SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_XTAL_16MHZ|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE,GPIO_PIN_0|GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); thischar=UARTCharGet(UART1_BASE); UARTCharPut(UART1_BASE,thischar); if(thischar=='a')//前进 i=123; else if(thischar=='b')//后退 i=789; else if(thischar=='s')//左转 i=456; else if(thischar=='n')//右转 i=258; return i; }
用户评论