Exemplo n.º 1
0
void UART2_57600(void)
{
	// Disable UART Receive/Transmit
		UARTDisable(UART2_BASE, UART_TX | UART_RX);

		// Configure UART Baud 57600
		UARTConfigSet(UART2_BASE, 57600, UART_CONFIG_SAMPLE_RATE_DEFAULT | UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_1);

		// Enable UART Receive and Transmit
		UARTEnable(UART2_BASE, UART_TX | UART_RX);
}
Exemplo n.º 2
0
//============================================================================//
//==                          UART初始化函数                                ==//
//============================================================================//
//==入口参数: 无                                                            ==//
//==出口参数: 无                                                            ==//
//==返回值:   无                                                            ==//
//============================================================================//
void UARTInit(void)
{
  SysCtlPeripheralEnable(GPIO_PERIPH);        //使能UART所在GPIO端口
  SysCtlPeripheralEnable(UART_PERIPH);        //使能UART外设
  GPIOPinTypeUART(GPIO_USE_BASE, GPIO_PINS);  //使能UART所在引脚
  
  UARTConfigSet(UART_USE_BASE, BAUDRATE, UART_CONFIG_WLEN_8|
                                         UART_CONFIG_STOP_ONE|
                                         UART_CONFIG_PAR_NONE);
  UARTEnable(UART_USE_BASE);                  //使能UART
}
Exemplo n.º 3
0
void Init_UART0(int baud, int buffer_size)
{
	xtEventCallback UART0_INT_HANDLE = USART0IntHandler;

	// Enable GPIO and UART Clock
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	// Remap UART pin to GPIO Port UART0_RX --> PA2 UART0_TX --> PA1
	xSPinTypeUART(UART0RX, PA1);
	xSPinTypeUART(UART0TX, PA2);

	// Set UART clock
	SysCtlPeripheralClockSourceSet(SYSCTL_PERIPH_UART0_S_MCGPLLCLK_2);

	// Disable UART Receive/Transmit
	UARTDisable(UART0_BASE, UART_TX | UART_RX);

	// Configure UART Baud 115200
	UARTConfigSet(UART0_BASE, baud, UART_CONFIG_SAMPLE_RATE_DEFAULT | UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_1);

	if (OSSemCreate(0, &SerialTX0) != ALLOC_EVENT_OK)
	{
	  // Oh Oh
	  // Não deveria entrar aqui !!!
	  while(1){};
	};

	// Só cria fila se for passado um tamanho maior que 0
	if (buffer_size){
		if (OSQueueCreate(buffer_size, &Serial0) != ALLOC_EVENT_OK)
		{
		  // Oh Oh
		  // Não deveria entrar aqui !!!
		  while(1){};
		};
	}

	UARTIntEnable(UART0_BASE, UART_INT_R);
	UARTIntCallbackInit(UART0_BASE, UART0_INT_HANDLE);

	// Enable UART Receive and Transmit
	UARTEnable(UART0_BASE, UART_TX | UART_RX);

	xIntEnable(28);
}
Exemplo n.º 4
0
void Init_UART2(void)
{
	xtEventCallback UART2_INT_HANDLE = USART2IntHandler;

	// Enable GPIO and UART Clock
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

	// Remap UART pin to GPIO Port UART0_RX --> PA2 UART0_TX --> PA1
	xSPinTypeUART(UART2RX, PE23);
	xSPinTypeUART(UART2TX, PE22);

	// Set UART clock
	SysCtlPeripheralClockSourceSet(SYSCTL_PERIPH_UART0_S_MCGPLLCLK_2);

	// Disable UART Receive/Transmit
	UARTDisable(UART2_BASE, UART_TX | UART_RX);

	// Configure UART Baud 115200
	UARTConfigSet(UART2_BASE, 9600, UART_CONFIG_SAMPLE_RATE_DEFAULT | UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_1);

	if (OSSemCreate(0, &SerialTX2) != ALLOC_EVENT_OK)
	{
	  // Oh Oh
	  // Não deveria entrar aqui !!!
	  while(1){};
	};

	if (OSQueueCreate(128, &Serial2) != ALLOC_EVENT_OK)
	{
	  // Oh Oh
	  // Não deveria entrar aqui !!!
	  while(1){};
	};

	UARTIntEnable(UART2_BASE, UART_INT_R);
	UARTIntCallbackInit(UART2_BASE, UART2_INT_HANDLE);

	// Enable UART Receive and Transmit
	UARTEnable(UART2_BASE, UART_TX | UART_RX);

	xIntEnable(30);
}
Exemplo n.º 5
0
static void vSerialInit( void )
{
	/* Enable the UART.  GPIOA has already been initialised. */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	/* Set GPIO A0 and A1 as peripheral function.  They are used to output the
	UART signals. */
	GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );

	/* Configure the UART for 8-N-1 operation. */
	UARTConfigSet( UART0_BASE, mainBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );

	/* We dont want to use the fifo.  This is for test purposes to generate
	as many interrupts as possible. */
	HWREG( UART0_BASE + UART_O_LCR_H ) &= ~mainFIFO_SET;

	/* Enable both Rx and Tx interrupts. */
	HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
	IntEnable( INT_UART0 );
}
Exemplo n.º 6
0
static void prvSetupHardware( void )
{
	/* Setup the PLL. */
	SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ );

	/* Setup the push button. */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    GPIODirModeSet(GPIO_PORTC_BASE, mainPUSH_BUTTON, GPIO_DIR_MODE_IN);
	GPIOIntTypeSet( GPIO_PORTC_BASE, mainPUSH_BUTTON,GPIO_FALLING_EDGE );
	IntPrioritySet( INT_GPIOC, configKERNEL_INTERRUPT_PRIORITY );
	GPIOPinIntEnable( GPIO_PORTC_BASE, mainPUSH_BUTTON );
	IntEnable( INT_GPIOC );



	/* Enable the UART.  */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	/* Set GPIO A0 and A1 as peripheral function.  They are used to output the
	UART signals. */
	GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );

	/* Configure the UART for 8-N-1 operation. */
	UARTConfigSet( UART0_BASE, mainBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );

	/* We don't want to use the fifo.  This is for test purposes to generate
	as many interrupts as possible. */
	HWREG( UART0_BASE + UART_O_LCR_H ) &= ~mainFIFO_SET;

	/* Enable Tx interrupts. */
	HWREG( UART0_BASE + UART_O_IM ) |= UART_INT_TX;
	IntPrioritySet( INT_UART0, configKERNEL_INTERRUPT_PRIORITY );
	IntEnable( INT_UART0 );


	/* Initialise the LCD> */
    OSRAMInit( false );
    OSRAMStringDraw("www.FreeRTOS.org", 0, 0);
	OSRAMStringDraw("LM3S811 demo", 16, 1);
}
Exemplo n.º 7
0
void vSerialInit( void )
{
	/* Create the queue used to communicate between the UART ISR and the Comms
	Rx task. */
	xCommsQueue = xQueueCreate( commsRX_QUEUE_LEN, sizeof( portCHAR ) );

	/* Enable the UART.  GPIOA has already been initialised. */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	/* Set GPIO A0 and A1 as peripheral function.  They are used to output the
	UART signals. */
	GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );

	/* Configure the UART for 8-N-1 operation. */
	UARTConfigSet( UART0_BASE, commsBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );

	/* We dont want to use the fifo.  This is for test purposes to generate
	as many interrupts as possible. */
	HWREG( UART0_BASE + UART_O_LCR_H ) &= ~commsFIFO_SET;

	/* Enable both Rx and Tx interrupts. */
	HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
	IntEnable( INT_UART0 );
}
Exemplo n.º 8
0
void UART_example(void)
{
    unsigned int i = 0;
    char Rec       = 0;

    //
    // Configure System clock
    //
    xSysCtlClockSet(48000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    SysCtlDelay(1000000);

    //
    // Enable GPIO/UART Clock
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    //
    // Remap UART pin to GPIO Port UART1_RX --> PC3 UART1_TX --> PC4
    xSPinTypeUART(UART1RX, PC3);
    xSPinTypeUART(UART1TX, PC4);

    //
    // Disable UART Receive/Transmit
    //
    UARTDisable(UART1_BASE, UART_TX | UART_RX);

    //
    // Configure UART Baud 9600 8-N-1
    //
    UARTConfigSet(UART1_BASE, 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE |
            UART_CONFIG_STOP_1);

    //
    // Enable UART Receive/Transmit
    //
    UARTEnable(UART1_BASE, UART_TX | UART_RX);

    //
    // print out welcome information
    //

    i = 0;
    while(Begin[i] != '\0')
    {
        UARTCharPut(UART1_BASE, Begin[i++]);
    }

    //
    // Echo user's input information
    //
    while((Rec = UARTCharGet(UART1_BASE)) != '\n')
    {
        UARTCharPut(UART1_BASE, Rec);
    }

    //
    // print out run over information
    //
    i = 0;
    while(End[i] != '\0')
    {
        UARTCharPut(UART1_BASE, End[i++]);
    }

    while(1);                  
}
void UART_example(void)
{
    unsigned int i = 0;

    //
    // Configure System clock
    //
    xSysCtlClockSet(48000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    SysCtlDelay(1000000);

    // Note: Defore call UART0 Function, you must call SysCtlPeripheralClockSourceSet Function.
    // SYSCTL_PERIPH_UART0_S_MCGFLLCLK, SYSCTL_PERIPH_UART0_S_MCGPLLCLK_2,
    // SYSCTL_PERIPH_UART0_S_OSCERCLK, SYSCTL_PERIPH_UART0_S_MCGIRCLK,
    // For UART1/2, just comment it
    SysCtlPeripheralClockSourceSet(SYSCTL_PERIPH_UART0_S_MCGPLLCLK_2);

    //
    // Enable GPIO/UART Clock
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Remap UART pin to GPIO Port UART1_RX --> PC3 UART1_TX --> PC4
    xSPinTypeUART(UART0RX, PA1);
    xSPinTypeUART(UART0TX, PA2);

    //
    // Disable UART Receive/Transmit
    //
    UARTDisable(UART0_BASE, UART_TX | UART_RX);

    //
    // Configure UART Baud 115200 8-N-1
    //
    UARTConfigSet(UART0_BASE, 115200, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE |
                  UART_CONFIG_STOP_1);

    //
    // Enable UART Receive/Transmit
    //
    UARTEnable(UART0_BASE, UART_TX | UART_RX);

    //
    // print out welcome information
    //

    i = 0;
    while(Begin[i] != '\0')
    {
        UARTCharPut(UART0_BASE, Begin[i++]);
    }

    //
    // Echo user's input information
    //
    while((Rec = UARTCharGet(UART0_BASE)) != '\n')
    {
        UARTCharPut(UART0_BASE, Rec);
    }

    //
    // print out run over information
    //
    i = 0;
    while(End[i] != '\0')
    {
        UARTCharPut(UART0_BASE, End[i++]);
    }

    while(1);
}
Exemplo n.º 10
0
//*****************************************************************************
//
//! Initialize the UART module and send characters to the terminal
//!
//! \param None
//!
//! This function initializes the UART including clock source, enables RX and TX.
//! Prints the welcome message and echos characters.
//!
//! \return none
//
//*****************************************************************************
void UART_example_freedomKL25(void)
{
    unsigned int i = 0;
    unsigned char Rec;

    //
    // Configure System clock
    //
    xSysCtlClockSet(48000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);
    SysCtlDelay(1000000);

    //
    // Enable GPIO and UART Clock
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Remap UART pin to GPIO Port UART0_RX --> PA2 UART0_TX --> PA1
    //
    xSPinTypeUART(UART0RX, PA1);
    xSPinTypeUART(UART0TX, PA2);

    //
    // Set UART clock
    //
    SysCtlPeripheralClockSourceSet(SYSCTL_PERIPH_UART0_S_MCGPLLCLK_2);

    //
    // Disable UART Receive/Transmit
    //
    UARTDisable(UART0_BASE, UART_TX | UART_RX);

    //
    // Configure UART Baud 115200
    //
    UARTConfigSet(UART0_BASE, 115200, UART_CONFIG_SAMPLE_RATE_15 | UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_1);

    //
    // Enable UART Receive and Transmit
    //
    UARTEnable(UART0_BASE, UART_TX | UART_RX);

    //
    // Print out welcome information
    //
    i = 0;
    while(Begin[i] != '\0')
    {
        UARTCharPut(UART0_BASE, Begin[i++]);
    }

    //
    // Echo user's input information. End if 0xD (CR)
    //
    while((Rec = UARTCharGet(UART0_BASE)) != 0xD)
    {
        UARTCharPut(UART0_BASE, Rec);
    }

    //
    // print out last message
    //
    i = 0;
    while(End[i] != '\0')
    {
        UARTCharPut(UART0_BASE, End[i++]);
    }

    while(1);                  
}