当前位置: 首页>>代码示例>>C++>>正文


C++ UART_init函数代码示例

本文整理汇总了C++中UART_init函数的典型用法代码示例。如果您正苦于以下问题:C++ UART_init函数的具体用法?C++ UART_init怎么用?C++ UART_init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UART_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Xbee_init

int Xbee_init() {
    uint8_t garbage;
    int ret;
    //init the serial link
#ifdef ARCH_X86_LINUX
    ret=UART_init(XBEE_UART_PATH,E_115200_8N2);
#elif defined(ARCH_328P_ARDUINO)
    Xbee_rst();
    ret=UART_init(NULL,111111);
#elif defined(ARCH_LM4FXX)
    Xbee_rst();
    ret=UART_init(NULL,111111);
#else
#error "no arch defined for Xbee4sb.c, or arch no available (yet)"
#endif
    if (ret<0) return ret;

    //waits for the Xbee to totally start
    uint32_t sw=0;
    while( testTimeout(10000000,&sw));

    //clear in buffer from remaining bytes
    while ( serialReadEscaped(&garbage,1000)>0 );
    return 0;
}
开发者ID:ENAC-Robotique,项目名称:Robots,代码行数:25,代码来源:Xbee_API.c

示例2: main

int main(void) {
    unsigned char s[80];
	int n;
	
		
    UART_init();	// in UART.c
	sei(); 			// Global interrupt enable
	
	//fdevopen( UART_fputc, UART_fgetc );			// establish buffered I/O callbacks

	for(;;) {
		// this demos the small memory function set. See below for FILE buffered version.
		UART_puts_P(PSTR("Enter text\r\n"));
		n = UART_gets(s, sizeof(s)-2);
		s[strlen(s)-1] = 0;	// drop the ending \r
		UART_puts_P(PSTR("You entered '"));
		UART_puts(s);
		UART_puts_P(PSTR("' length="));
		UART_puts(itoa(n, s, 10));
		UART_puts_P(PSTR("\n\r"));
		
		// uncomment this to use the buffered I/O (memory hog). 
		//   and fdevopen(), above too.
		
		/* Same function as printf() but the format string resides in flash */
		//printf_P(PSTR("Enter text\r\n"));
		//fgets(s, sizeof(s)-1, stdin);
		//s[strlen(s)-2] = 0;	// drop the ending \r\n
		//printf_P(PSTR("\r\nYou entered '%s'\r\n"),s);
	}
}
开发者ID:macambira,项目名称:mircho-avrcode,代码行数:31,代码来源:main.c

示例3: main

int main(void)
{             
  char c;			// odebrany znak
  UART_init();			// inicjalizacja portu szeregowego
  LCD_init();			// inicjalizacja wy�wietlacza LCD
  LCD_PL_chars_init();		// polskie znaki na wy�wietlaczu LCD
  KBD_init();			// inicjalizacja klawiatury
  LED7SEG_init();		// inicjalizacja wy�wietlacza
  sei();                       	// w��cz obs�ug� przerwa�

  while(1)			// p�tla niesko�czona
  {
    PCF8583_get_time(&godz,&min,&sek,&ssek);

    LED7SEG_putU08(sek);	// wy�wietlaj warto�� 

    if (UART_rxlen()>0)	// je�li odebrano znak
    {
      c=UART_getchar();
    	// tu mo�na wstawi� reakcje na komendy steruj�ce np. typu ESC[
      LCD_putchar(c);		// wy�wietl go na LCD
    }
    if (KBD_read())		// je�li naci�ni�to klawisz
    {
      if ((KBD_ascii>='A')&&(KBD_ascii<='D'))
        UART_putstr_P(CURSOR);	// sterowanie kursorem
      UART_putchar(KBD_ascii);	// wy�lij go na port szeregowy
      KBD_wait();		// czekaj na zwolnienie klawisza
    }
  }
}
开发者ID:rimek,项目名称:aquarium,代码行数:31,代码来源:full.c

示例4: main

int main(void)
{
    uint16_t adc_result;
	int i;
	char value[10];
	sbi(DDRB, 4);
	sbi(DDRC, 5);
	cbi(PORTB,4);
	sbi(PORTC,5);	
    UART_init(250000);
	InitADC();
	sei();
	
	
	
	while(1)
	{
	adc_result=ReadADC(2);           // Read Analog value from channel-2
    // Voltage = adc_result*5/1024
	// Temperature = (V  -  1035 mV)/(-5.5 (mV/oC))
	itoa(adc_result,value,10);
	for(i=0;i<=2;i++){
	UART_TxChar(value[i]);}
	UART_TxStr("\n\r\0");
	PORTB ^= (1<<PB4);	
	_delay_ms(100);
	}
	
}
开发者ID:akshaypm,项目名称:iot-school,代码行数:29,代码来源:adc_raw.c

示例5: main

int main(void)
{
 	int SYSm;

    /* Initialise MPU, I/O and SysTick */
    SCS_init();
    UART_init();
    SysTick_init();

    /* Finally change Thread mode to unprivileged
     * but continue using Main Stack Pointer */
    SYSm = __MRS_control();
    SYSm |= 1;
    __MSR_control(SYSm);

    /* Flush and refill pipline with unprivileged permissions */
    __ISB();

    printf("Cortex-M3 Example - Build 3\n");

    /* Loop forever */
    while( 1 )
    {
        Display_80((char*) ".");
    }
}
开发者ID:roland-wilhelm,项目名称:iot,代码行数:26,代码来源:main.c

示例6: SetupUartTask

/**
 * /fn SetupUartTask
 * /brief Setup UART tasks.
 *
 * Task has priority 15 and receives 1kB of stack.
 *
 * /return Always 0. In case of error the system halts.
 */
int SetupUartTask(void) {
	Task_Params taskTransferParams;
	Task_Handle taskTransfer;
	Error_Block eb;

	/* Enable and configure the peripherals used by the UART7 */
	SysCtlPeripheralEnable(GPIO_PORTC_BASE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
	GPIOPinConfigure(GPIO_PC4_U7RX);
	GPIOPinConfigure(GPIO_PC5_U7TX);
	GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);

	/* Enable and configure the peripherals used by the UART6 */
	SysCtlPeripheralEnable(GPIO_PORTP_BASE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
	GPIOPinConfigure(GPIO_PP0_U6RX);
	GPIOPinConfigure(GPIO_PP1_U6TX);
	GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	UART_init();

	InitializeLedUserSwitch();

	Error_init(&eb);
	Task_Params_init(&taskTransferParams);
	taskTransferParams.stackSize = 1024;
	taskTransferParams.priority = 15;
	taskTransfer = Task_create((Task_FuncPtr) TransferFunction,
			&taskTransferParams, &eb);
	if (taskTransfer == NULL) {
		System_abort("UART task create failed");
	}

	return (0);
}
开发者ID:Komisa72,项目名称:ese_wheaterstation_2016,代码行数:43,代码来源:UART_Task.c

示例7: main

int main(void)
{

    Board_init();
    UART_init(UART2_ID,9600);
    printf("\r\nUno Serial Test Harness\r\nAfter this Message the terminal should mirror anything you type.\r\n");
    unsigned char ch = 0;
    int x;
    while (1) {
        if (UART_isTransmitEmpty(UART1_ID) == TRUE){
            if (UART_isReceiveEmpty(UART1_ID) == FALSE){
                ch = UART_getChar(UART1_ID);
                UART_putChar(UART1_ID, ch);
                printf("  Through UART2: ");
                UART_putChar(UART2_ID, ch);
                x = 1024;
                while(--x){
                    if(UART_isReceiveEmpty(UART2_ID) ==FALSE)
                        break;
                }
                if(UART_isReceiveEmpty(UART2_ID) == FALSE){
                    printf("%c\n", UART_getChar(UART2_ID));
                } else{
                    printf("FAILED\n");
                }
                //DELAY(1000)
            }
        }
    }
    return 0;
}
开发者ID:sdajani,项目名称:sdp,代码行数:31,代码来源:Uart.c

示例8: Setup

void Setup(void) {

    PinSetMode();
    // setup internal clock for 72MHz/36MIPS
    // 12 /2 = 6  *24 = 144 / 2=72
    CLKDIVbits.PLLPRE = 0; // PLLPRE (N2) 0=/2c
    CLKDIVbits.DOZE = 0;
    PLLFBD = 22; // pll multiplier (M) = +2
    CLKDIVbits.PLLPOST = 0; // PLLPOST (N1) 0=/2   
    // Initiate Clock Switch to Primary Oscillator with PLL (NOSC = 0b011)
    __builtin_write_OSCCONH(0x03);
    __builtin_write_OSCCONL(OSCCON | 0x01);
    // Wait for Clock switch to occur
    while (OSCCONbits.COSC != 0b011);
    while (!OSCCONbits.LOCK); // wait for PLL ready


    INTCON1bits.NSTDIS = 1; //no nesting of interrupts
    timerOne();
    initADC();
    //timerTwo();
    begin(receiveArray, sizeof (receiveArray), SAS_ADDRESS, false, Send_put, Receive_get, Receive_available, Receive_peek);
    UART_init();
    //UART1_init();
    //begin(receiveArray1, sizeof (receiveArray1), SAS_ADDRESS, false, Send_put1, Receive_get1, Receive_available1, Receive_peek1);

}
开发者ID:OfnyaHoo,项目名称:EV15,代码行数:27,代码来源:Functions.c

示例9: main

void main (void)
{
    //Stop WDT
    WDT_hold(__MSP430_BASEADDRESS_WDT_A__);

    //P3.4,5 = USCI_A0 TXD/RXD
    GPIO_setAsPeripheralModuleFunctionInputPin(__MSP430_BASEADDRESS_PORT3_R__,
        GPIO_PORT_P3,
        GPIO_PIN4 + GPIO_PIN5
        );

    //Initialize USCI UART module
    if ( STATUS_FAIL == UART_init(__MSP430_BASEADDRESS_USCI_A0__,
             UART_CLOCKSOURCE_SMCLK,
             UCS_getSMCLK(__MSP430_BASEADDRESS_UCS__),
             BAUD_RATE,
             UART_NO_PARITY,
             UART_LSB_FIRST,
             UART_ONE_STOP_BIT,
             UART_MODE,
             UART_OVERSAMPLING_BAUDRATE_GENERATION
             )){
        return;
    }

    //Enable UART module for operation
    UART_enable(__MSP430_BASEADDRESS_USCI_A0__);

    //Enable Receive Interrupt
    UART_enableInterrupt(__MSP430_BASEADDRESS_USCI_A0__, UART_RECEIVE_INTERRUPT);

    //Enter LPM3, interrupts enabled
    __bis_SR_register(LPM3_bits + GIE);
    __no_operation();
}
开发者ID:TECHNOTICSROBOTICS,项目名称:mspdev,代码行数:35,代码来源:uart_rx.c

示例10: main

int main(void) {
    OSC_init();
    TRISA = 0b00000000;
    TRISB = 0b00000011;
    TRISC = 0b10000000;
    ANCON0 = 0b11111111;
    ANCON1 = 0b00011111;
    INTCON2bits.RBPU = 0; // Pull-up enable

    timer0_init(3);

    UART_init();
    uint8_t txbuf[100];
    ringbuf_init(&tx_buf, txbuf, sizeof (txbuf));

    INTCONbits.GIE = 1;

    while (1) {
        static int16_t prev_e;
        if (encoder != prev_e) {
            prev_e = encoder;
            if (encoder < 0) {
                tx_send('-');
                tx_sendn(-encoder, 5);
                tx_send('\n');
            } else {
                tx_sendn(encoder, 5);
                tx_send('\n');
            }
        }
    }
    return 0;
}
开发者ID:kerikun11,项目名称:MPLABXProjects,代码行数:33,代码来源:PIC18F27J53-encoder01.c

示例11: main

int main(void)
{
	DDRB = 0xFF;
	PORTB = 0x20;

	// use CLK/1024 prescale value, clear timer/counter on compareA match
	TCCR1B = (1<<CS10) | (1<<CS12) | (1<<WGM12);
	// preset timer1 high/low byte
	OCR1A = ((F_CPU/1024) - 1 );   
	// enable Output Compare 1 overflow interrupt
	//TIMSK  = (1<<OCIE1A);
	// Enable interrupts
	sei();

	UART_init(4800);
	UART_putchar('W');
	UART_putchar('\n');
	UART_putchar('\r');

	UART_puts("Hello World!\n\r");
	UART_puts("This is a longer message!\n\rLet's hope it works well enough...\n\r");
	UART_puts("Hello World! 1\n\r");
	UART_puts("Hello World! 2\n\r");
	UART_puts("Hello World! 3\n\r");
	unsigned int i = 0;
	while (1) {
		i++;
		PORTB ^= 0x20;
		char charbuf[100];
		sprintf(charbuf, "Loop number %d\n\r",i); 
		UART_puts(charbuf);
	}
}
开发者ID:PhirePhly,项目名称:AVRClips,代码行数:33,代码来源:test_libUART.c

示例12: BSP_init

//*****************************************************************************
//
// 板级开发包初始化
//
//*****************************************************************************
void BSP_init(void)
{
    // Set the clocking to run directly from the crystal.
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_8MHZ);

    // Enable processor interrupts.
    IntMasterEnable();

    // Configure SysTick for a periodic interrupt.
    SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
    SysTickEnable();
    SysTickIntEnable();

    // Initialize the DEBUG UART.           (UART0)
    DEBUG_UART_init();

    // Initialize the IO Hardware.          (LED/SOL/I2C_HOTSWAP)
    IO_init();

    // Initialize the UART Hardware.        (ICMB/SOL)
    UART_init();

    // Initialize the SPI Hardware.         (SSIF)
    SPI_init();

    // Initialize the I2C Hardware.         (IPMB/PMB)
    I2C_init();

    // Initialize the Ethernet Hardware.    (LAN)
    ETH_init();
}
开发者ID:redfox-qu,项目名称:ipmi_ucos_6911,代码行数:37,代码来源:main.c

示例13: Xbee_init

uint8_t Xbee_init(uint8_t uartId){
    xbeeUartId = uartId;
    UART_init(uartId,XBEE_BAUD_RATE);
#ifdef XBEE_REPROGRAM_SETTINGS
    if( programMode() == FAILURE){
        while(1);
        return FAILURE;
    }
#else
    /*
    int i = 0;
    char confirm[3];
    DELAY(2000);
    UART_putString(uartId, "+++", 3);
    DELAY(API_DELAY);
    //wait for "OK\r"
    do {
        confirm[i] = UART_getChar(XBEE_UART_ID);
        if (confirm[i] != 0)
            i++;
    } while(i < 3);

    if (!(confirm[0] == 0x4F && confirm[1] == 0x4B && confirm[2] == 0x0D)){
        return FAILURE;
    }
     * */
#endif
    return SUCCESS; 
}
开发者ID:SamChenzx,项目名称:sdp,代码行数:29,代码来源:Xbee.c

示例14: __main

void __main(void)
{
	uint8_t k;
	uint32_t i;

	UART_init();
	TMR16_Init();
	GPIO_init();

	if ( SysTick_Config(12000000) ) {
		while(1);
	}

	__enable_irq();

	puts("LPC1114 UART Test\r\n");

	while(1) {
		for ( k = 0; k < 8*3; k++ ) {
			LPC_TMR16B1->MR0 = Freq[k];
			LPC_TMR16B1->TCR = 1;

			for (i = 0xfffff; i !=0; i--);
			LPC_TMR16B1->TCR = 0;
			LPC_TMR16B1->TCR |= (1 << 1);
		}
	}
}
开发者ID:matsumotokohei,项目名称:Tamagotchi,代码行数:28,代码来源:main.c

示例15: EZDSP5535_UART_open

/*
 *  UART_open( )
 *    Open UART handle and configure it for 115200 baud
 * 
 */
Int16 EZDSP5535_UART_open( )
{
    CSL_Status        status;
    CSL_UartConfig 		    Config;

    /*  
     * Configuring for baud rate of 115200
     * Divisor = UART input clock frequency / (Desired baud rate*16)
     * = 100MHz / 115200 / 16
     * = 54 = 0x36
     */
    Config.DLL = 0x36;  // Set baud rate
    Config.DLH = 0x00;
        
    Config.FCR = 0x0000;            // Clear UART TX & RX FIFOs
    Config.LCR = 0x0003;            // 8-bit words,
                                    // 1 STOP bit generated,
                                    // No Parity, No Stick paritiy,
                                    // No Break control
    Config.MCR = 0x0000;            // RTS & CTS disabled,
                                    // Loopback mode disabled,
                                    // Autoflow disabled

    status = UART_init(&uartObj, CSL_UART_INST_0, UART_INTERRUPT);
    hUart = (CSL_UartHandle)&uartObj;
    status |= UART_reset(hUart);
    status |= UART_config(hUart,&Config);
    status |= UART_resetOff(hUart);        

    CSL_SYSCTRL_REGS->EBSR &= ~0xF000;   //
    CSL_SYSCTRL_REGS->EBSR |=  0x1000;   // Set parallel port to mode 1 (SPI, GPIO, UART, and I2S2)
    
	return status;
}
开发者ID:raulbehl,项目名称:C5535-eZdsp,代码行数:39,代码来源:ezdsp5535_uart.c


注:本文中的UART_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。