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


C++ USART_CR1函数代码示例

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


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

示例1: MB_USART_ISR

/* Find out what interrupted and get or send data as appropriate */
void MB_USART_ISR(void)
{
    /* Check if we were called because of RXNE. */
    if (((USART_CR1(MB_USART) & USART_CR1_RXNEIE) != 0) && ((USART_SR(MB_USART) & USART_SR_RXNE) != 0))
    {
        pxMBFrameCBByteReceived();
    }
    /* Check if we were called because of TXE. */
    if (((USART_CR1(MB_USART) & USART_CR1_TXEIE) != 0) && ((USART_SR(MB_USART) & USART_SR_TXE) != 0))
    {
        pxMBFrameCBTransmitterEmpty();
        /* Check if we need to disable transmitter*/
        if(!txen)
        {
            USART_SR (MB_USART) &= ~USART_SR_TC;   /* Clear TC flag*/
            USART_CR1(MB_USART) |= USART_CR1_TCIE; /* Enable transfer complite interrupt*/
        }
    }
    /* Disable transmitter on transfer comlite*/
    if (((USART_CR1(MB_USART) & USART_CR1_TCIE) != 0) && ((USART_SR(MB_USART) & USART_SR_TC) != 0))
    {
        USART_CR1(MB_USART) &= ~USART_CR1_TCIE;/* Disble transfer complite interrupt*/
        USART_SR (MB_USART) &= ~USART_SR_TC;   /* Clear TC flag*/
        /* Disable transmitter*/
        gpio_clear(MB_USART_TXEN_PORT, MB_USART_TXEN_PIN);
    }
}
开发者ID:nucleron,项目名称:yaplc,代码行数:28,代码来源:portserial.c

示例2: DBG_USART_ISR

void DBG_USART_ISR(void)
{
    /* Check if we were called because of RXNE. */
    if (((USART_CR1(DBG_USART) & USART_CR1_RXNEIE) != 0) && ((USART_SR(DBG_USART) & USART_SR_RXNE) != 0))
    {
        usart_data = usart_recv(DBG_USART);
        if( !dbg_fifo_write_byte( &usart_rx_buf, usart_data ) )
        {
            usart_disable_rx_interrupt(DBG_USART);
        }
    }
    /* Check if we were called because of TXE. */
    if (((USART_CR1(DBG_USART) & USART_CR1_TXEIE) != 0) && ((USART_SR(DBG_USART) & USART_SR_TXE) != 0))
    {
        /* Put data into the transmit register. */
        if( dbg_fifo_read_byte( &usart_tx_buf, &usart_data ) )
        {
            usart_send(DBG_USART, usart_data);
        }
        else
        {
            /* Disable the TXE interrupt as we don't need it anymore. */
            usart_disable_tx_interrupt(DBG_USART);
        }
    }
}
开发者ID:nucleron,项目名称:yaplc,代码行数:26,代码来源:plc_serial.c

示例3: init

	OPTL_NOINLINE
	void init()
	{
		clk::enable();
		rxpin::clock::enable();
		txpin::clock::enable();

		rxpin::init_alternate(afnum::af);
		txpin::init_alternate(afnum::af);

		rxpin::driver_pushpull();
		txpin::driver_pushpull();

		USART_BRR(base) = ((2 * cpuclock) + baudrate) / (2 * baudrate);
		USART_CR1(base) &= ~USART_CR1_M; /* 8 data bits */
		USART_CR1(base) = (USART_CR1(base) & ~USART_PARITY_MASK) |
				   USART_PARITY_NONE;
		USART_CR2(base) = (USART_CR2(base) & ~USART_CR2_STOPBITS_MASK) |
				   USART_STOPBITS_1;
		USART_CR3(base) = (USART_CR3(base) & ~USART_FLOWCONTROL_MASK) |
				   USART_FLOWCONTROL_NONE;

		USART_CR1(base) = (USART_CR1(base) & ~USART_MODE_MASK) |
				   USART_MODE_TX_RX;

	}
开发者ID:BuFran,项目名称:liboptl,代码行数:26,代码来源:HwSerial_f0234l1.hpp

示例4: usart2_isr

void usart2_isr(void)
{
	/* Check if we were called because of RXNE. */
	if (((USART_CR1(USART2) & USART_CR1_RXNEIE) != 0) &&
	    ((USART_SR(USART2) & USART_SR_RXNE) != 0)) {

		/* Indicate that we got data. */
		gpio_toggle(GPIOA, GPIO8);

		/* Retrieve the data from the peripheral. */
		ring_write_ch(&output_ring, usart_recv(USART2));

		/* Enable transmit interrupt so it sends back the data. */
		USART_CR1(USART2) |= USART_CR1_TXEIE;
	}

	/* Check if we were called because of TXE. */
	if (((USART_CR1(USART2) & USART_CR1_TXEIE) != 0) &&
	    ((USART_SR(USART2) & USART_SR_TXE) != 0)) {

		int32_t data;

		data = ring_read_ch(&output_ring, NULL);

		if (data == -1) {
			/* Disable the TXE interrupt, it's no longer needed. */
			USART_CR1(USART2) &= ~USART_CR1_TXEIE;
		} else {
			/* Put data into the transmit register. */
			usart_send(USART2, data);
		}
	}
}
开发者ID:paulfertser,项目名称:libopencm3-examples,代码行数:33,代码来源:usart_irq_printf.c

示例5: usart1_isr

void usart1_isr(void)
{
    unsigned char c;

	/* Check if we were called because of RXNE. */
	if (((USART_CR1(USART1) & USART_CR1_RXNEIE) != 0) &&
        ((USART_SR(USART1) & USART_SR_RXNE) != 0) &&
        (!serial_rb_full(&srx))) {
        c = serial_recv();
        serial_rb_write(&srx, c);
	}
	/* Check if we were called because of TXE. */
	else if (((USART_CR1(USART1) & USART_CR1_TXEIE) != 0) &&
             ((USART_SR(USART1) & USART_SR_TXE) != 0)) {

        if(!serial_rb_empty(&stx)) {
            serial_send(serial_rb_read(&stx));
        }
        else {
            /* Disable the TXE interrupt, it's no longer needed. */
            USART_CR1(USART1) &= ~USART_CR1_TXEIE;
        }
	}
	else {
        c = serial_recv();
	}
}
开发者ID:ArulPrasathK,项目名称:libemb,代码行数:27,代码来源:main.c

示例6: usart1_isr

void usart1_isr(void)
{
	u8 ch;

	//if Receive interrupt
	if (((USART_CR1(USART1) & USART_CR1_RXNEIE) != 0) &&
			((USART_SR(USART1) & USART_SR_RXNE) != 0))
	{
		ch=usart_recv(USART1);
		buffer_put(&u1rx, ch);
	}

	if (((USART_CR1(USART1) & USART_CR1_TXEIE) != 0) &&
			((USART_SR(USART1) & USART_SR_TXE) != 0))
	{
		if (buffer_get(&u1tx, &ch) == SUCCESS)
		{
			//if char read from buffer
			usart_send(USART1, ch);
		}
		else	//if buffer empty
		{

			//disable Transmit Data Register empty interrupt
			usart_disable_tx_interrupt(USART1);
		}
	}
}
开发者ID:alex-sever-h,项目名称:robot,代码行数:28,代码来源:usart.c

示例7: usart_set_databits

void usart_set_databits(u32 usart, u32 bits)
{
	if (bits == 8)
		USART_CR1(usart) &= ~USART_CR1_M; /* 8 data bits */
	else
		USART_CR1(usart) |= USART_CR1_M;  /* 9 data bits */
}
开发者ID:Dzenik,项目名称:libopencm3,代码行数:7,代码来源:usart_common_all.c

示例8: UART_IRQHandler

void UART_IRQHandler(struct CB_UART* pctl)
{
	/* Receive */
	if ((USART_SR(pctl->iuart) & USART_SR_RXNE) != 0) // Receive reg loaded?
	{  // Here, receive interrupt flag is on. 
		*pctl->rxbuff_in = USART_DR(pctl->iuart);// Read and store char

		/* Advance pointers to line buffers and array of counts and reset when end reached */	
		pctl->rxbuff_in = rxbuff_adv(pctl, pctl->rxbuff_in);	// Advance pointers common routine
	}

	/* Transmit */
	if ( (USART_CR1(pctl->iuart) & USART_CR1_TXEIE) != 0)
	{  // Here, yes.  Transmit interrupts are enabled so check if a tx interrupt
		if ( (USART_SR(pctl->iuart) & USART_SR_TXE) != 0) // Transmit register empty?
		{ // Here, yes.
			USART_DR(pctl->iuart) = *pctl->txbuff_out;// Send next char, step pointer

			/* Advance output pointer */
			pctl->txbuff_out = txbuff_adv(pctl, pctl->txbuff_out);

			/* Was the last byte loaded the last to send? */		
			if (pctl->txbuff_out == pctl->txbuff_in)
			{ // Here yes. 
				USART_CR1(pctl->iuart) &= ~USART_CR1_TXEIE;		// Disable Tx interrupt	
			}	
		}
	}
	return;
}
开发者ID:GliderWinchCommons,项目名称:mc,代码行数:30,代码来源:bsp_uart.c

示例9: usart1_isr

void usart1_isr(void)
{
	static uint8_t data = 'A';

	/* Check if we were called because of RXNE. */
	if (((USART_CR1(USART1) & USART_CR1_RXNEIE) != 0) &&
		((USART_SR(USART1) & USART_SR_RXNE) != 0)) {
		/* Indicate that we got data. */
		gpio_toggle(GPIOA, GPIO6);

		/* Retrieve the data from the peripheral. */
		data = usart_recv(USART1);

		/* Enable transmit interrupt so it sends back the data. */
		USART_CR1(USART1) |= USART_CR1_TXEIE;
	}

	/* Check if we were called because of TXE. */
	if (((USART_CR1(USART1) & USART_CR1_TXEIE) != 0) &&
		((USART_SR(USART1) & USART_SR_TXE) != 0)) {
		/* Indicate that we are sending out data. */
		gpio_toggle(GPIOA, GPIO7);

		/* Put data into the transmit register. */
		usart_send(USART1, data);

		/* Disable the TXE interrupt as we don't need it anymore. */
		USART_CR1(USART1) &= ~USART_CR1_TXEIE;
	}
}
开发者ID:balshetzer,项目名称:libopencm3-examples,代码行数:30,代码来源:usart_irq.c

示例10: usart2_isr

void usart2_isr(void)
{
	static u8 data = 'A';

	/* Check if we were called because of RXNE. */
	if (((USART_CR1(USART2) & USART_CR1_RXNEIE) != 0) &&
	    ((USART_SR(USART2) & USART_SR_RXNE) != 0)) {

		/* Indicate that we got data. */
		gpio_toggle(GPIOD, GPIO12);

		/* Retrieve the data from the peripheral. */
		data = usart_recv(USART2);

		/* Enable transmit interrupt so it sends back the data. */
		usart_enable_tx_interrupt(USART2);
	}

	/* Check if we were called because of TXE. */
	if (((USART_CR1(USART2) & USART_CR1_TXEIE) != 0) &&
	    ((USART_SR(USART2) & USART_SR_TXE) != 0)) {

		/* Put data into the transmit register. */
		usart_send(USART2, data);

		/* Disable the TXE interrupt as we don't need it anymore. */
		usart_disable_tx_interrupt(USART2);
	}
}
开发者ID:CNCBASHER,项目名称:libopencm3,代码行数:29,代码来源:usart_irq.c

示例11: usart_set_databits

void usart_set_databits(uint32_t usart, uint32_t bits)
{
	if (bits == 8) {
		USART_CR1(usart) &= ~USART_CR1_M; /* 8 data bits */
	} else {
		USART_CR1(usart) |= USART_CR1_M;  /* 9 data bits */
	}
}
开发者ID:OliviliK,项目名称:libopencm3,代码行数:8,代码来源:usart.c

示例12: usart_set_mode

void usart_set_mode(uint32_t usart, uint32_t mode)
{
	uint32_t reg32;

	reg32 = USART_CR1(usart);
	reg32 = (reg32 & ~USART_MODE_MASK) | mode;
	USART_CR1(usart) = reg32;
}
开发者ID:brabo,项目名称:unicore-mx,代码行数:8,代码来源:usart_common_all.c

示例13: usart_set_parity

void usart_set_parity(uint32_t usart, uint32_t parity)
{
	uint32_t reg32;

	reg32 = USART_CR1(usart);
	reg32 = (reg32 & ~USART_PARITY_MASK) | parity;
	USART_CR1(usart) = reg32;
}
开发者ID:brabo,项目名称:unicore-mx,代码行数:8,代码来源:usart_common_all.c

示例14: usart_set_parity

void usart_set_parity(u32 usart, u32 parity)
{
	u32 reg32;

	reg32 = USART_CR1(usart);
	reg32 = (reg32 & ~USART_PARITY_MASK) | parity;
	USART_CR1(usart) = reg32;
}
开发者ID:Dzenik,项目名称:libopencm3,代码行数:8,代码来源:usart_common_all.c

示例15: usart_set_mode

void usart_set_mode(u32 usart, u32 mode)
{
	u32 reg32;

	reg32 = USART_CR1(usart);
	reg32 = (reg32 & ~USART_MODE_MASK) | mode;
	USART_CR1(usart) = reg32;
}
开发者ID:Dzenik,项目名称:libopencm3,代码行数:8,代码来源:usart_common_all.c


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