TI中文支持网
TI专业的中文技术问题搜集分享网站

EK TM4C123GH6PM UART0小练–基于uartstdio.c的函数

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/fpu.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/rom.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Bit-Banding (bitband)</h1>
//!
//! This example application demonstrates the use of the bit-banding
//! capabilities of the Cortex-M4F microprocessor.  All of SRAM and all of the
//! peripherals reside within bit-band regions, meaning that bit-banding
//! operations can be applied to any of them.  In this example, a variable in
//! SRAM is set to a particular value one bit at a time using bit-banding
//! operations (it would be more efficient to do a single non-bit-banded write;
//! this simply demonstrates the operation of bit-banding).
//
//*****************************************************************************


//*****************************************************************************
//
// The value that is to be modified via bit-banding.
//
//*****************************************************************************
static volatile uint32_t g_ui32Value;

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{while(1){//// Hang on runtime error.//}
}
#endif

//*****************************************************************************
//
// Configure the UART and its pins.  This must be called before UARTprintf().
//
//*****************************************************************************
void
ConfigureUART(void)
{//// Enable the GPIO Peripheral used by the UART.//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);//// Enable UART0//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);//// Configure GPIO Pins for UART mode.//ROM_GPIOPinConfigure(GPIO_PA0_U0RX);ROM_GPIOPinConfigure(GPIO_PA1_U0TX);ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);//// Use the internal 16MHz oscillator as the UART clock source.//UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);//// Initialize the UART for console I/O.//UARTStdioConfig(0, 115200, 16000000);
}

//*****************************************************************************
//
// This example demonstrates the use of bit-banding to set individual bits
// within a word of SRAM.
//
//*****************************************************************************
int
main(void)
{// Set the clocking to run directly from the crystal.//ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);//// Initialize the UART interface.//ConfigureUART();UARTprintf("Hello this is TM4C123H6PM USART0!\n");UARTprintf("USART0 by stdio.h!\n");// Loop forever.//while(1){}
}

xyz549040622:

例程基于"utils/uartstdio.h"这个函数,一定要包含这个头文件才可以的。
注意UARTStdioConfig(0, 115200, 16000000);第一个参数只能配置为0,1,2三个参数,即只能配置为串口0,串口1,串口2.

user5579324:

回复 xyz549040622:

请问uartstdio.h在哪里可以下载,我发现您的例程基本都有用到这个,但是我找不到这个头文件

xyz549040622:

回复 user5579324:

在TIVA 的库中,具体地址如下:
C:\ti\TivaWare_C_Series-2.1.4.178\utils

赞(0)
未经允许不得转载:TI中文支持网 » EK TM4C123GH6PM UART0小练–基于uartstdio.c的函数
分享到: 更多 (0)