这篇教程C++ usart_set_baudrate函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usart_set_baudrate函数的典型用法代码示例。如果您正苦于以下问题:C++ usart_set_baudrate函数的具体用法?C++ usart_set_baudrate怎么用?C++ usart_set_baudrate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usart_set_baudrate函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: usart_setupstatic void usart_setup(void){ /* Setup USART2 parameters. */ usart_set_baudrate(USART2, 38400); usart_set_databits(USART2, 8); usart_set_stopbits(USART2, USART_STOPBITS_1); usart_set_mode(USART2, USART_MODE_TX); usart_set_parity(USART2, USART_PARITY_NONE); usart_set_flow_control(USART2, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(USART2);}
开发者ID:BuFran,项目名称:libopencm3-examples,代码行数:13,
示例2: usart_peripheral_setupvoid usart_peripheral_setup(void) { gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9); gpio_set_af(GPIOA, GPIO_AF7, GPIO9); usart_set_baudrate(USART1, 38400); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_mode(USART1, USART_MODE_TX); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_enable(USART1);}
开发者ID:adamgreig,项目名称:wombat,代码行数:13,
示例3: run_baudrate_test/** * /brief Test setting different baud rates of the USART module * * This function calls the set function and check that the correct baud-rate has * been set in the register. * * /param test Current test case. */static void run_baudrate_test(const struct test_case *test){ bool success; uint32_t baud; uint32_t cpu_hz; uint32_t ubrr = 0; /* Get the system cpu frequency */ cpu_hz = sysclk_get_cpu_hz(); /* Test for baud rate equal to 2400 */ baud = 2400; usart_set_baudrate(&CONF_UNIT_USART, baud, cpu_hz); ubrr = calculate_baudrate(baud, cpu_hz); success = CONF_UNIT_USART.UBRR == ubrr; test_assert_true(test, success, "Setting baud rate to 2400 failed"); /* Test for baud rate equal to 9600 */ baud = 9600; usart_set_baudrate(&CONF_UNIT_USART, baud, cpu_hz); ubrr = calculate_baudrate(baud, cpu_hz); success = CONF_UNIT_USART.UBRR == ubrr; test_assert_true(test, success, "Setting baud rate to 9600 failed"); /* Test for baud rate equal to 19200 */ baud = 19200; usart_set_baudrate(&CONF_UNIT_USART, baud, cpu_hz); ubrr = calculate_baudrate(baud, cpu_hz); success = CONF_UNIT_USART.UBRR == ubrr; test_assert_true(test, success, "Setting baud rate to 19200 failed"); /* Test for baud rate equal to 38400 */ baud = 38400; usart_set_baudrate(&CONF_UNIT_USART, baud, cpu_hz); ubrr = calculate_baudrate(baud, cpu_hz); success = CONF_UNIT_USART.UBRR == ubrr; test_assert_true(test, success, "Setting baud rate to 38400 failed");}
开发者ID:marekr,项目名称:asf,代码行数:47,
示例4: usart_initvoid usart_init(uint32_t arg_usart, uint32_t baudrate){ usart_set_baudrate(arg_usart, baudrate); usart_set_databits(arg_usart, 8); usart_set_flow_control(arg_usart, USART_FLOWCONTROL_NONE); usart_set_mode(arg_usart, USART_MODE_TX | USART_MODE_RX); usart_set_parity(arg_usart, USART_PARITY_NONE); usart_set_stopbits(arg_usart, USART_STOPBITS_1); usart_enable_rx_interrupt(arg_usart); usart_enable(arg_usart); usart = arg_usart;}
开发者ID:libusbhost,项目名称:libusbhost,代码行数:13,
示例5: glue_set_line_coding_cbint glue_set_line_coding_cb(uint32_t baud, uint8_t databits, enum usb_cdc_line_coding_bParityType cdc_parity, enum usb_cdc_line_coding_bCharFormat cdc_stopbits){ int uart_parity; int uart_stopbits; if (databits < 8 || databits > 9) { return 0; } /* Be careful here, ST counts parity as a data bit */ switch (cdc_parity) { case USB_CDC_NO_PARITY: uart_parity = USART_PARITY_NONE; break; case USB_CDC_ODD_PARITY: uart_parity = USART_PARITY_ODD; databits++; break; case USB_CDC_EVEN_PARITY: uart_parity = USART_PARITY_EVEN; databits++; break; default: return 0; } switch (cdc_stopbits) { case USB_CDC_1_STOP_BITS: uart_stopbits = USART_STOPBITS_1; break; case USB_CDC_2_STOP_BITS: uart_stopbits = USART_STOPBITS_2; break; default: return 0; } /* Disable the UART while we mess with its settings */ usart_disable(USART2); /* Set communication parameters */ usart_set_baudrate(USART2, baud); usart_set_databits(USART2, databits); usart_set_parity(USART2, uart_parity); usart_set_stopbits(USART2, uart_stopbits); /* Back to work. */ usart_enable(USART2); return 1;}
开发者ID:karlp,项目名称:libopencm3-tests,代码行数:51,
示例6: usart_setupstatic void usart_setup(void) { /* Setup GPIO pin GPIO_USART1_RE_TX on GPIO port A for transmit. */ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_TX); /* Setup UART parameters. */ usart_set_baudrate(USART1, 57600); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_set_mode(USART1, USART_MODE_TX); /* Finally enable the USART. */ usart_enable(USART1);}
开发者ID:GBert,项目名称:misc,代码行数:14,
示例7: usart_init_rs232int usart_init_rs232(volatile avr32_usart_t *usart, const usart_options_t *opt, long pba_hz){ // Reset the USART and shutdown TX and RX. usart_reset(usart); // Check input values. if (!opt) // Null pointer. return USART_INVALID_INPUT; if (opt->charlength < 5 || opt->charlength > 9 || opt->paritytype > 7 || opt->stopbits > 2 + 255 || opt->channelmode > 3) return USART_INVALID_INPUT; if (usart_set_baudrate(usart, opt->baudrate, pba_hz) == USART_INVALID_INPUT) return USART_INVALID_INPUT; if (opt->charlength == 9) { // Character length set to 9 bits. MODE9 dominates CHRL. usart->mr |= AVR32_USART_MR_MODE9_MASK; } else { // CHRL gives the character length (- 5) when MODE9 = 0. usart->mr |= (opt->charlength - 5) << AVR32_USART_MR_CHRL_OFFSET; } usart->mr |= (opt->channelmode << AVR32_USART_MR_CHMODE_OFFSET) | (opt->paritytype << AVR32_USART_MR_PAR_OFFSET); if (opt->stopbits > USART_2_STOPBITS) { // Set two stop bits usart->mr |= AVR32_USART_MR_NBSTOP_2 << AVR32_USART_MR_NBSTOP_OFFSET; // and a timeguard period gives the rest. usart->ttgr = opt->stopbits - USART_2_STOPBITS; } else // Insert 1, 1.5 or 2 stop bits. usart->mr |= opt->stopbits << AVR32_USART_MR_NBSTOP_OFFSET; // Setup complete; enable communication. // Enable input and output. usart->cr |= AVR32_USART_CR_TXEN_MASK | AVR32_USART_CR_RXEN_MASK; return USART_SUCCESS;}
开发者ID:AldenHiggins,项目名称:ELEC424-Lab06-Scheduling-with-FreeRTOS,代码行数:49,
示例8: usart_init_iso7816int usart_init_iso7816(volatile avr32_usart_t *usart, const iso7816_options_t *opt, int t, long pba_hz){ // Reset the USART and shutdown TX and RX. usart_reset(usart); // Check input values. if (!opt) // Null pointer. return USART_INVALID_INPUT; if (t == 0) { // Set USART mode to ISO7816, T=0. // The T=0 protocol always uses 2 stop bits. usart->mr = (USART_MODE_ISO7816_T0 << AVR32_USART_MR_MODE_OFFSET) | (AVR32_USART_MR_NBSTOP_2 << AVR32_USART_MR_NBSTOP_OFFSET) | (opt->bit_order << AVR32_USART_MR_MSBF_OFFSET); // Allow MSBF in T=0. } else if (t == 1) { // Only LSB first in the T=1 protocol. // max_iterations field is only used in T=0 mode. if (opt->bit_order != 0 || opt->max_iterations != 0) return USART_INVALID_INPUT; // Set USART mode to ISO7816, T=1. // The T=1 protocol always uses 1 stop bit. usart->mr = (USART_MODE_ISO7816_T1 << AVR32_USART_MR_MODE_OFFSET) | (AVR32_USART_MR_NBSTOP_1 << AVR32_USART_MR_NBSTOP_OFFSET); } else return USART_INVALID_INPUT; if (usart_set_baudrate(usart, opt->iso7816_hz, pba_hz) == USART_INVALID_INPUT) return USART_INVALID_INPUT; // Set FIDI register: bit rate = selected clock/FI_DI_ratio/16. usart->fidi = opt->fidi_ratio; // Set ISO7816 spesific options in the MODE register. usart->mr |= (opt->inhibit_nack << AVR32_USART_MR_INACK_OFFSET) | (opt->dis_suc_nack << AVR32_USART_MR_DSNACK_OFFSET) | (opt->max_iterations << AVR32_USART_MR_MAX_ITERATION_OFFSET) | AVR32_USART_MR_CLKO_MASK; // Enable clock output. // Setup complete; enable input. // Leave TX disabled for now. usart->cr |= AVR32_USART_CR_RXEN_MASK; return USART_SUCCESS;}
开发者ID:AldenHiggins,项目名称:ELEC424-Lab06-Scheduling-with-FreeRTOS,代码行数:49,
示例9: usart_set_parameters/** Set up USART parameters for particular USART. * /param usart USART to set up parameters for. * /param baud Baud rate to set. */void usart_set_parameters(u32 usart, u32 baud){ /* Setup UART parameters. */ baud = baud; usart_disable(usart); usart_set_baudrate(usart, baud); usart_set_databits(usart, 8); usart_set_stopbits(usart, USART_STOPBITS_1); usart_set_parity(usart, USART_PARITY_NONE); usart_set_flow_control(usart, USART_FLOWCONTROL_NONE); usart_set_mode(usart, USART_MODE_TX_RX); /* Enable the USART. */ usart_enable(usart);}
开发者ID:EmuxEvans,项目名称:piksi_firmware,代码行数:19,
示例10: init_usartstatic void init_usart(void){ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN | RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN); gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_TX); gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_USART1_RX); usart_set_baudrate(USART1, 115200); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_mode(USART1, USART_MODE_TX_RX); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_enable(USART1);}
开发者ID:karlp,项目名称:libopencm3-examples,代码行数:15,
示例11: usart_initvoid usart_init(void){ gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10); gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10); rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN); usart_enable(USART1); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_mode(USART1, USART_MODE_TX_RX); usart_set_baudrate(USART1, 9600); usart_enable_rx_interrupt(USART1); nvic_enable_irq(NVIC_USART1_IRQ);}
开发者ID:bgamari,项目名称:solar-charger-v2,代码行数:15,
示例12: usart_setupstatic void usart_setup(void){ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART2_TX); usart_set_baudrate(USART_CONSOLE, 115200); usart_set_databits(USART_CONSOLE, 8); usart_set_stopbits(USART_CONSOLE, USART_STOPBITS_1); usart_set_mode(USART_CONSOLE, USART_MODE_TX); usart_set_parity(USART_CONSOLE, USART_PARITY_NONE); usart_set_flow_control(USART_CONSOLE, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(USART_CONSOLE);}
开发者ID:paulfertser,项目名称:libopencm3-examples,代码行数:15,
示例13: gps_peripheral_setupvoid gps_peripheral_setup(void) { gpio_mode_setup(GPS_USART_GPIO, GPIO_MODE_AF, GPIO_PUPD_NONE, GPS_USART_PINS); // Set this manually for now, due to a libopencm3 bug /*gpio_set_af(GPS_USART_GPIO, GPS_USART_AF, GPS_USART_PINS);*/ GPIOA_AFRL = (7 << 2*4) | (7 << 3*4); usart_set_baudrate(GPS_USART, 38400); usart_set_databits(GPS_USART, 8); usart_set_stopbits(GPS_USART, USART_STOPBITS_1); usart_set_mode(GPS_USART, USART_MODE_TX_RX); usart_set_parity(GPS_USART, USART_PARITY_NONE); usart_set_flow_control(GPS_USART, USART_FLOWCONTROL_NONE); usart_enable(GPS_USART);}
开发者ID:cuspaceflight,项目名称:wombat,代码行数:16,
示例14: _debug_initvoid _debug_init(){ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO9); gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO10); usart_set_baudrate(USART1, 115200); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_mode(USART1, USART_MODE_TX); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_enable(USART1);}
开发者ID:cuspaceflight,项目名称:DorMouse,代码行数:16,
示例15: ar_setupvoid ar_setup(void){ rcc_periph_clock_enable(RCC_USART1); artx_setup(); arrx_setup(); usart_set_baudrate(USART1, 921600); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_mode(USART1, USART_MODE_TX_RX); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_disable_overrun(USART1); usart_enable(USART1);}
开发者ID:flukso,项目名称:flx03,代码行数:16,
示例16: usart_setupstatic void usart_setup(void){ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9); gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10); /* Setup UART parameters. */ usart_set_baudrate(USART1, 9600); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_set_mode(USART1, USART_MODE_TX); /* Finally enable the USART. */ usart_enable(USART1);}
开发者ID:paulfertser,项目名称:libopencm3-examples,代码行数:16,
示例17: UART_Initializevoid UART_Initialize(){ /* Enable clocks for GPIO port containing _USART and USART */ rcc_periph_clock_enable(get_rcc_from_port(UART_CFG.uart)); rcc_periph_clock_enable(get_rcc_from_pin(UART_CFG.rx)); rcc_periph_clock_enable(get_rcc_from_pin(UART_CFG.tx)); /* Enable DMA clock */ rcc_periph_clock_enable(get_rcc_from_port(USART_DMA.dma)); /* Setup GPIO pin GPIO_USARTX_TX on USART GPIO port for transmit. Set normal function to input as this is mode reverted to in half-duplex receive */ GPIO_setup_input(UART_CFG.rx, ITYPE_FLOAT); GPIO_setup_output_af(UART_CFG.tx, OTYPE_PUSHPULL, UART_CFG.uart); /* Setup UART parameters. */ UART_SetDataRate(0); UART_SetFormat(8, UART_PARITY_NONE, UART_STOPBITS_1); UART_SetDuplex(UART_DUPLEX_FULL); usart_set_flow_control(UART_CFG.uart, USART_FLOWCONTROL_NONE); usart_set_mode(UART_CFG.uart, USART_MODE_TX_RX); /* Finally enable the USART. */ usart_enable(UART_CFG.uart); nvic_set_priority(get_nvic_dma_irq(USART_DMA), 3); nvic_enable_irq(get_nvic_dma_irq(USART_DMA));#if HAS_AUDIO_UART /* Enable clocks for GPIO port C (for GPIO_UART5_TX) and UART5. */ rcc_periph_clock_enable(get_rcc_from_port(AUDIO_UART_CFG.uart)); rcc_periph_clock_enable(get_rcc_from_pin(AUDIO_UART_CFG.tx)); /* Setup GPIO pins to use UART5 */ GPIO_setup_output_af(AUDIO_UART_CFG.tx, OTYPE_PUSHPULL, AUDIO_UART_CFG.uart); /* Setup UART5 parameters. */ usart_set_baudrate(AUDIO_UART_CFG.uart, 9600); usart_set_databits(AUDIO_UART_CFG.uart, 8); usart_set_stopbits(AUDIO_UART_CFG.uart, USART_STOPBITS_1); usart_set_parity(AUDIO_UART_CFG.uart, USART_PARITY_NONE); usart_set_mode(AUDIO_UART_CFG.uart, USART_MODE_TX); /* Finally enable the AUDIO_UART_CFG.uart. */ usart_enable(AUDIO_UART_CFG.uart);#endif}
开发者ID:goebish,项目名称:deviation,代码行数:47,
示例18: usbuart_initvoid usbuart_init(void){#if defined(BLACKMAGIC) /* On mini hardware, UART and SWD share connector pins. * Don't enable UART if we're being debugged. */ if ((platform_hwversion() == 1) && (SCS_DEMCR & SCS_DEMCR_TRCENA)) return;#endif rcc_peripheral_enable_clock(&USBUSART_APB_ENR, USBUSART_CLK_ENABLE); UART_PIN_SETUP(); /* Setup UART parameters. */ usart_set_baudrate(USBUSART, 38400); usart_set_databits(USBUSART, 8); usart_set_stopbits(USBUSART, USART_STOPBITS_1); usart_set_mode(USBUSART, USART_MODE_TX_RX); usart_set_parity(USBUSART, USART_PARITY_NONE); usart_set_flow_control(USBUSART, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(USBUSART); /* Enable interrupts */ USBUSART_CR1 |= USART_CR1_RXNEIE; nvic_set_priority(USBUSART_IRQ, IRQ_PRI_USBUSART); nvic_enable_irq(USBUSART_IRQ); /* Setup timer for running deferred FIFO processing */ USBUSART_TIM_CLK_EN(); timer_reset(USBUSART_TIM); timer_set_mode(USBUSART_TIM, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); timer_set_prescaler(USBUSART_TIM, rcc_ppre2_frequency / USBUART_TIMER_FREQ_HZ * 2 - 1); timer_set_period(USBUSART_TIM, USBUART_TIMER_FREQ_HZ / USBUART_RUN_FREQ_HZ - 1); /* Setup update interrupt in NVIC */ nvic_set_priority(USBUSART_TIM_IRQ, IRQ_PRI_USBUSART_TIM); nvic_enable_irq(USBUSART_TIM_IRQ); /* turn the timer on */ timer_enable_counter(USBUSART_TIM);}
开发者ID:FlyingCampDesign,项目名称:blackmagic,代码行数:46,
示例19: setup_consolevoid setup_console(void){ // Clock rcc_periph_clock_enable(RCC_UART4); // GPIO gpio_init_pins(usart1_pins, usart1_pin_count); // USART usart_set_baudrate(CONSOLE_UART, CONSOLE_BAUD); usart_set_databits(CONSOLE_UART, 8); usart_set_stopbits(CONSOLE_UART, USART_STOPBITS_1); usart_set_mode(CONSOLE_UART, USART_MODE_TX_RX); usart_set_parity(CONSOLE_UART, USART_PARITY_NONE); usart_set_flow_control(CONSOLE_UART, USART_FLOWCONTROL_NONE); usart_enable(CONSOLE_UART);}
开发者ID:esden,项目名称:1bitsy-examples,代码行数:17,
示例20: usart_set_baudratevoidBoard_FY20AP::com_init(unsigned speed){ /* configure UART */ usart_set_baudrate(USART1, speed); usart_set_databits(USART1, 8); usart_set_stopbits(USART1, USART_STOPBITS_1); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_set_mode(USART1, USART_MODE_TX_RX); /* enable receive interrupt */ usart_enable_rx_interrupt(USART1); /* and enable the UART */ usart_enable(USART1);}
开发者ID:px4dev,项目名称:mavmon,代码行数:17,
示例21: usart_setupstatic void usart_setup(void){ /* Setup GPIO pins for USART2 transmit. */ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO2); /* Setup USART2 TX pin as alternate function. */ gpio_set_af(GPIOA, GPIO_AF7, GPIO2); usart_set_baudrate(USART_CONSOLE, 115200); usart_set_databits(USART_CONSOLE, 8); usart_set_stopbits(USART_CONSOLE, USART_STOPBITS_1); usart_set_mode(USART_CONSOLE, USART_MODE_TX); usart_set_parity(USART_CONSOLE, USART_PARITY_NONE); usart_set_flow_control(USART_CONSOLE, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(USART_CONSOLE);}
开发者ID:ChuckM,项目名称:libopencm3-examples,代码行数:18,
示例22: console_setup/* * Set up the GPIO subsystem with an "Alternate Function" * on some of the pins, in this case connected to a * USART. */void console_setup(void){ /* MUST enable the GPIO clock in ADDITION to the USART clock */ rcc_periph_clock_enable(RCC_GPIOA); /* This example uses PD9 and PD10 for Tx and Rx respectively * but other pins are available for this role on USART1 (our chosen * USART) as well, we are using them because they are connected over * jumpers to the programmer. */ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10); /* Actual Alternate function number (in this case 7) is part * depenedent, check the data sheet for the right number to * use. */ gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10); /* This then enables the clock to the USART1 peripheral which is * attached inside the chip to the APB1 bus. Different peripherals * attach to different buses, and even some UARTS are attached to * APB1 and some to APB2, again the data sheet is useful here. * We are using the rcc_periph_clock_enable function that knows which * peripheral is on which clock bus and sets things up accordingly. */ rcc_periph_clock_enable(RCC_USART1); /* Set up USART/UART parameters using the libopencm3 helper functions */ usart_set_baudrate(CONSOLE_UART, 115200); usart_set_databits(CONSOLE_UART, 8); usart_set_stopbits(CONSOLE_UART, USART_STOPBITS_1); usart_set_mode(CONSOLE_UART, USART_MODE_TX_RX); usart_set_parity(CONSOLE_UART, USART_PARITY_NONE); usart_set_flow_control(CONSOLE_UART, USART_FLOWCONTROL_NONE); usart_enable(CONSOLE_UART); /* Enable interrupts from the USART */ nvic_enable_irq(NVIC_USART1_IRQ); /* Specifically enable recieve interrupts */ usart_enable_rx_interrupt(CONSOLE_UART);}
开发者ID:ChuckM,项目名称:libopencm3-examples,代码行数:49,
示例23: usart_setupstatic void usart_setup(void){ /* Setup GPIO pin GPIO_USART2_TX and GPIO_USART2_RX. */ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART2_TX); gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_USART2_RX); /* Setup UART parameters. */ usart_set_baudrate(USART2, 9600); usart_set_databits(USART2, 8); usart_set_stopbits(USART2, USART_STOPBITS_1); usart_set_mode(USART2, USART_MODE_TX_RX); usart_set_parity(USART2, USART_PARITY_NONE); usart_set_flow_control(USART2, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(USART2);}
开发者ID:BuFran,项目名称:libopencm3-examples,代码行数:19,
示例24: console_setup/* * console_setup(int baudrate) * * Set the pins and clocks to create a console that we can * use for serial messages and getting text from the user. */void console_setup(int baud){ /* MUST enable the GPIO clock in ADDITION to the USART clock */ rcc_periph_clock_enable(RCC_GPIOA); /* This example uses PD5 and PD6 for Tx and Rx respectively * but other pins are available for this role on USART1 (our chosen * USART) as well, such as PA2 and PA3. You can also split them * so PA2 for Tx, PD6 for Rx but you would have to enable both * the GPIOA and GPIOD clocks in that case */ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10); /* Actual Alternate function number (in this case 7) is part * depenedent, CHECK THE DATA SHEET for the right number to * use. */ gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10); /* This then enables the clock to the USART1 peripheral which is * attached inside the chip to the APB2 bus. Different peripherals * attach to different buses, and even some UARTS are attached to * APB1 and some to APB2, again the data sheet is useful here. */ rcc_periph_clock_enable(RCC_USART1); /* Set up USART/UART parameters using the libopencm3 helper functions */ usart_set_baudrate(CONSOLE_UART, baud); usart_set_databits(CONSOLE_UART, 8); usart_set_stopbits(CONSOLE_UART, USART_STOPBITS_1); usart_set_mode(CONSOLE_UART, USART_MODE_TX_RX); usart_set_parity(CONSOLE_UART, USART_PARITY_NONE); usart_set_flow_control(CONSOLE_UART, USART_FLOWCONTROL_NONE); usart_enable(CONSOLE_UART); /* Enable interrupts from the USART */ nvic_enable_irq(NVIC_USART1_IRQ); /* Specifically enable receive interrupts */ usart_enable_rx_interrupt(CONSOLE_UART);}
开发者ID:Guiller87,项目名称:libopencm3-examples,代码行数:48,
示例25: usart_set_baudratestatic FILE *usart_setup(uint32_t dev){ /* Setup USART2 parameters. */ usart_set_baudrate(dev, 38400); usart_set_databits(dev, 8); usart_set_parity(dev, USART_PARITY_NONE); usart_set_stopbits(dev, USART_CR2_STOP_1_0BIT); usart_set_mode(dev, USART_MODE_TX_RX); usart_set_flow_control(dev, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(dev); cookie_io_functions_t stub = { _iord, _iowr, NULL, NULL }; FILE *fp = fopencookie((void *)dev, "rw+", stub); /* Do not buffer the serial line */ setvbuf(fp, NULL, _IONBF, 0); return fp;}
开发者ID:BuFran,项目名称:libopencm3-examples,代码行数:20,
示例26: uart_initvoid uart_init(int baud){ uart_init_gpio(); nvic_enable_irq(NVIC_USART1_IRQ); nvic_set_priority(NVIC_USART1_IRQ, 2); usart_set_baudrate(USART1, baud); usart_set_databits(USART1, 8); usart_set_parity(USART1, USART_PARITY_NONE); usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); usart_set_stopbits(USART1, USART_CR2_STOPBITS_1); usart_set_mode(USART1, USART_MODE_TX_RX); usart_enable_rx_interrupt(USART1); usart_enable(USART1); /* This ensures stdio doesn't use its own buffers */ setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);}
开发者ID:jimmyH,项目名称:contiki,代码行数:20,
示例27: usart_setupvoid usart_setup(void) { /* Enable clocks for GPIO port A (for GPIO_USART2_TX) and USART2. */ rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN); rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_IOPAEN); /* Setup GPIO pin GPIO_USART2_TX/GPIO9 on GPIO port A for transmit. */ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO2 | GPIO3); gpio_set_af(GPIOA, GPIO_AF7, GPIO2| GPIO3); /* Setup UART parameters. */ usart_set_baudrate(USART2, 115200); usart_set_databits(USART2, 8); usart_set_stopbits(USART2, USART_STOPBITS_1); usart_set_mode(USART2, USART_MODE_TX_RX); usart_set_parity(USART2, USART_PARITY_NONE); usart_set_flow_control(USART2, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(USART2);}
开发者ID:paulfertser,项目名称:libopencm3-examples,代码行数:20,
示例28: usart_setup/** * Set up USART2. * This one is connected via the virtual serial port on the Nucleo Board */static void usart_setup(uint32_t baud){ rcc_periph_clock_enable(RCC_GPIOA); rcc_periph_clock_enable(RCC_AFIO); rcc_periph_clock_enable(RCC_USART2); usart_disable(USART2); gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART2_TX | GPIO_USART2_RX); usart_set_baudrate(USART2, baud); usart_set_databits(USART2, 8); usart_set_stopbits(USART2, USART_STOPBITS_1); usart_set_parity(USART2, USART_PARITY_NONE); usart_set_flow_control(USART2, USART_FLOWCONTROL_NONE); usart_set_mode(USART2, USART_MODE_TX_RX); usart_enable(USART2);}
开发者ID:MHageH,项目名称:atomthreads_custom,代码行数:24,
示例29: usart_initvoidusart_init(int usart, int irq, int baudrate, int over8) { /* Setup USART parameters. */ nvic_disable_irq(irq); usart_disable_rx_interrupt(usart); usart_disable_tx_interrupt(usart); usart_disable(usart); USART_CR1(usart) |= over8; /* This doubles the listed baudrate. */ usart_set_baudrate(usart, baudrate); usart_set_databits(usart, 8); usart_set_stopbits(usart, USART_STOPBITS_1); usart_set_mode(usart, USART_MODE_TX_RX); usart_set_parity(usart, USART_PARITY_NONE); usart_set_flow_control(usart, USART_FLOWCONTROL_NONE); /* Finally enable the USART. */ usart_enable(usart); usart_enable_rx_interrupt(usart); usart_enable_tx_interrupt(usart); nvic_enable_irq(irq);}
开发者ID:henryhallam,项目名称:leitshow,代码行数:20,
注:本文中的usart_set_baudrate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ usart_set_databits函数代码示例 C++ usart_send_blocking函数代码示例 |