Exemplo n.º 1
0
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
{
    struct stm32_uart *uart;

    RT_ASSERT(serial != RT_NULL);
    uart = (struct stm32_uart *)serial->parent.user_data;

    switch (cmd)
    {
    case RT_DEVICE_CTRL_CLR_INT:
        /* disable rx irq */
        UART_DISABLE_IRQ(uart->irq);
        /* disable interrupt */
        USART_ITConfig(uart->uart_device, USART_IT_RXNE, DISABLE);
        break;
    case RT_DEVICE_CTRL_SET_INT:
        /* enable rx irq */
        UART_ENABLE_IRQ(uart->irq);
        /* enable interrupt */
        USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
        break;
    }

    return RT_EOK;
}
Exemplo n.º 2
0
/*
 *  UartDev_UnInit
 */
static int32_t  UartDev_UnInit(uint32_t Ch)
{
    Uart_INFO *p_info;
    int32_t ret;
    
    if (Mfs_Lock(Ch) != ERROR) {
    
        p_info = &UartInfo[Ch];
        if (p_info->State != UART_INITIALIZED) {
            ret = ERROR; /* not initialized */
            
        } else {
            uart_StopRx(p_info);
            
            /* change state */
            p_info->State = UART_UNINITIALIZED;
            
            /* disable NVIC */
            UART_DISABLE_IRQ(p_info->RxIRQn);
            UART_DISABLE_IRQ(p_info->TxIRQn);
            
            /* uninitialize */
            uart_UnInit(Ch, p_info);
            
            Mfs_Close(Ch);
            
            ret = SUCCESS;
        }
        
        Mfs_UnLock(Ch);
        
    } else {
        ret = ERROR; /* Mfs_Lock error */
    }
    
    return ret;
}
Exemplo n.º 3
0
static rt_err_t uart47_control(struct rt_serial_device *serial, int cmd, void *arg)
{
	struct uart47_device *uart;

	RT_ASSERT(serial != RT_NULL);	
	uart = (struct uart47_device *)serial->parent.user_data;
	
	switch (cmd)
	{
	case RT_DEVICE_CTRL_CLR_INT:
		/* disable rx irq */
		UART_DISABLE_IRQ(uart->rx_irq);
		break;
	case RT_DEVICE_CTRL_SET_INT:
		/* enable rx irq */
		UART_ENABLE_IRQ(uart->rx_irq);
		break;
	}

	return (RT_EOK);	
}
Exemplo n.º 4
0
static rt_err_t __uart_control(struct rt_serial_device *serial, int cmd, void *arg)
{
	struct uart_device *uartDev = RT_NULL;

	RT_ASSERT(serial != RT_NULL);
	uartDev = (struct uart_device *)serial->parent.user_data;

	switch (cmd)
	{
	case RT_DEVICE_CTRL_CLR_INT: /* disable rx irq */
		UART_DISABLE_IRQ(uartDev->irq);
		break;

	case RT_DEVICE_CTRL_SET_INT: /* enable rx irq */
		UART_ENABLE_IRQ(uartDev->irq);
		break;

	default:
		break;
	}

	return RT_EOK;
}
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
{
    struct stm32_uart* uart;
    rt_uint32_t irq_type = (rt_uint32_t)(arg);

    RT_ASSERT(serial != RT_NULL);
    uart = (struct stm32_uart *)serial->parent.user_data;

    switch (cmd)
    {
        /* disable interrupt */
    case RT_DEVICE_CTRL_CLR_INT:

        if (irq_type == RT_DEVICE_FLAG_INT_RX)
        {
            /* disable rx irq */
            USART_ITConfig(uart->uart_device, USART_IT_RXNE, DISABLE);
        }
        else if (irq_type == RT_DEVICE_FLAG_INT_TX)
        {
            /* disable tx irq */
            USART_ITConfig(uart->uart_device, uart->tx_irq_type, DISABLE);
        }
        else if (irq_type == RT_NULL)
        {
            /* disable irq */
            UART_DISABLE_IRQ(uart->irq);
        }
        break;
        /* enable interrupt */
    case RT_DEVICE_CTRL_SET_INT:
        if (irq_type == RT_DEVICE_FLAG_INT_RX)
        {
            /* enable rx irq */
            USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
        }
        else if (irq_type == RT_DEVICE_FLAG_INT_TX)
        {
            /* enable tx irq */
            USART_ITConfig(uart->uart_device, uart->tx_irq_type, ENABLE);
        }
        else if (irq_type == RT_NULL)
        {
            /* enable irq */
            UART_ENABLE_IRQ(uart->irq);
        }
        break;
        /* get interrupt flag */
    case RT_DEVICE_CTRL_GET_INT:
        if (irq_type == RT_DEVICE_FLAG_INT_RX)
        {
            /* return rx irq flag */
            return USART_GetITStatus(uart->uart_device, USART_IT_RXNE);
        }
        else if (irq_type == RT_DEVICE_FLAG_INT_TX)
        {
            /* return tx irq flag */
            return USART_GetITStatus(uart->uart_device, uart->tx_irq_type);
        }
    break;
         /* get USART flag */
    case RT_DEVICE_CTRL_GET_FLAG:
        if (irq_type == RT_DEVICE_FLAG_INT_RX)
        {
            /* return rx irq flag */
			return USART_GetFlagStatus(uart->uart_device, USART_FLAG_RXNE);
        }
        else if (irq_type == RT_DEVICE_FLAG_INT_TX)
        {
            /* return tx flag */
            if (uart->tx_irq_type == USART_IT_TC)
            {
				return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TC);
            }
            else if (uart->tx_irq_type == USART_IT_TXE)
            {
				return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TXE);
            }
        }
        break;
    }
    return RT_EOK;
}