Advertisement
vinifr

uart_conf

Apr 14th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1. //*****************************************************************************
  2. //
  3. // Configure the UART and its pins.  This must be called before UARTprintf().
  4. //
  5. //*****************************************************************************
  6. void ConfigureUART(uint32_t ui32SysClock)
  7. {
  8.     //
  9.     // Enable the GPIO Peripheral used by the UART.
  10.     //
  11.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP); // PP0 and PP1
  12.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // PA0 and PA1
  13.  
  14.     //
  15.     // Enable UART6
  16.     //
  17.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
  18.     //
  19.     // Enable UART0
  20.     //
  21.     ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
  22.  
  23.     //
  24.     // Configure GPIO Pins for UART mode.
  25.     // UART6 and UART0
  26.     ROM_GPIOPinConfigure(GPIO_PP0_U6RX);
  27.     ROM_GPIOPinConfigure(GPIO_PP1_U6TX);
  28.     ROM_GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  29.  
  30.     ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
  31.     ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
  32.     ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  33.  
  34.     //
  35.     // Use the system clock for the UART.
  36.     //
  37.     UARTClockSourceSet(UART6_BASE, UART_CLOCK_SYSTEM);
  38.  
  39.     UARTClockSourceSet(UART0_BASE, UART_CLOCK_SYSTEM);
  40.  
  41.     //
  42.     // Initialize the UART for console I/O.
  43.     //
  44.     //
  45.     UARTStdioConfig(UART6_IDX, 9600, ui32SysClock);
  46.  
  47.     UARTStdioConfig(UART0_IDX, 115200, ui32SysClock);
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement