commit
9f31d19926
@ -45,6 +45,7 @@ struct stm32_uart
|
|||||||
{
|
{
|
||||||
USART_TypeDef *uart_device;
|
USART_TypeDef *uart_device;
|
||||||
IRQn_Type irq;
|
IRQn_Type irq;
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
struct stm32_uart_dma
|
struct stm32_uart_dma
|
||||||
{
|
{
|
||||||
/* dma channel */
|
/* dma channel */
|
||||||
@ -58,9 +59,12 @@ struct stm32_uart
|
|||||||
/* last receive index */
|
/* last receive index */
|
||||||
rt_size_t last_recv_index;
|
rt_size_t last_recv_index;
|
||||||
} dma;
|
} dma;
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
static void DMA_Configuration(struct rt_serial_device *serial);
|
static void DMA_Configuration(struct rt_serial_device *serial);
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
||||||
{
|
{
|
||||||
@ -107,7 +111,6 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
|
|||||||
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
|
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||||
{
|
{
|
||||||
struct stm32_uart* uart;
|
struct stm32_uart* uart;
|
||||||
rt_uint32_t ctrl_arg = (rt_uint32_t)(arg);
|
|
||||||
|
|
||||||
RT_ASSERT(serial != RT_NULL);
|
RT_ASSERT(serial != RT_NULL);
|
||||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||||
@ -128,12 +131,14 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
|
|||||||
/* enable interrupt */
|
/* enable interrupt */
|
||||||
USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
|
USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
|
||||||
break;
|
break;
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
/* USART config */
|
/* USART config */
|
||||||
case RT_DEVICE_CTRL_CONFIG :
|
case RT_DEVICE_CTRL_CONFIG :
|
||||||
if (ctrl_arg == RT_DEVICE_FLAG_DMA_RX) {
|
if ((rt_uint32_t)(arg) == RT_DEVICE_FLAG_DMA_RX) {
|
||||||
DMA_Configuration(serial);
|
DMA_Configuration(serial);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
}
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
@ -182,6 +187,7 @@ static int stm32_getc(struct rt_serial_device *serial)
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
/**
|
/**
|
||||||
* Serial port receive idle process. This need add to uart idle ISR.
|
* Serial port receive idle process. This need add to uart idle ISR.
|
||||||
*
|
*
|
||||||
@ -231,6 +237,7 @@ static void dma_rx_done_isr(struct rt_serial_device *serial) {
|
|||||||
|
|
||||||
DMA_ClearFlag(uart->dma.rx_gl_flag);
|
DMA_ClearFlag(uart->dma.rx_gl_flag);
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uart common interrupt process. This need add to uart ISR.
|
* Uart common interrupt process. This need add to uart ISR.
|
||||||
@ -251,10 +258,12 @@ static void uart_isr(struct rt_serial_device *serial) {
|
|||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||||
}
|
}
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
if(USART_GetITStatus(uart->uart_device, USART_IT_IDLE) != RESET)
|
if(USART_GetITStatus(uart->uart_device, USART_IT_IDLE) != RESET)
|
||||||
{
|
{
|
||||||
dma_uart_rx_idle_isr(serial);
|
dma_uart_rx_idle_isr(serial);
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||||
{
|
{
|
||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
@ -284,6 +293,7 @@ static const struct rt_uart_ops stm32_uart_ops =
|
|||||||
struct stm32_uart uart1 =
|
struct stm32_uart uart1 =
|
||||||
{
|
{
|
||||||
USART1,
|
USART1,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
USART1_IRQn,
|
USART1_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Channel5,
|
DMA1_Channel5,
|
||||||
@ -291,6 +301,7 @@ struct stm32_uart uart1 =
|
|||||||
DMA1_Channel5_IRQn,
|
DMA1_Channel5_IRQn,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial1;
|
struct rt_serial_device serial1;
|
||||||
|
|
||||||
@ -305,6 +316,7 @@ void USART1_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Channel5_IRQHandler(void) {
|
void DMA1_Channel5_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -314,6 +326,8 @@ void DMA1_Channel5_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART1 */
|
#endif /* RT_USING_UART1 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART2)
|
#if defined(RT_USING_UART2)
|
||||||
@ -321,6 +335,7 @@ void DMA1_Channel5_IRQHandler(void) {
|
|||||||
struct stm32_uart uart2 =
|
struct stm32_uart uart2 =
|
||||||
{
|
{
|
||||||
USART2,
|
USART2,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
USART2_IRQn,
|
USART2_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Channel6,
|
DMA1_Channel6,
|
||||||
@ -328,6 +343,7 @@ struct stm32_uart uart2 =
|
|||||||
DMA1_Channel6_IRQn,
|
DMA1_Channel6_IRQn,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial2;
|
struct rt_serial_device serial2;
|
||||||
|
|
||||||
@ -342,6 +358,7 @@ void USART2_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Channel6_IRQHandler(void) {
|
void DMA1_Channel6_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -351,6 +368,8 @@ void DMA1_Channel6_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART2 */
|
#endif /* RT_USING_UART2 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART3)
|
#if defined(RT_USING_UART3)
|
||||||
@ -358,6 +377,7 @@ void DMA1_Channel6_IRQHandler(void) {
|
|||||||
struct stm32_uart uart3 =
|
struct stm32_uart uart3 =
|
||||||
{
|
{
|
||||||
USART3,
|
USART3,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
USART3_IRQn,
|
USART3_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Channel3,
|
DMA1_Channel3,
|
||||||
@ -365,6 +385,7 @@ struct stm32_uart uart3 =
|
|||||||
DMA1_Channel3_IRQn,
|
DMA1_Channel3_IRQn,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial3;
|
struct rt_serial_device serial3;
|
||||||
|
|
||||||
@ -379,6 +400,7 @@ void USART3_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Channel3_IRQHandler(void) {
|
void DMA1_Channel3_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -388,6 +410,8 @@ void DMA1_Channel3_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART3 */
|
#endif /* RT_USING_UART3 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART4)
|
#if defined(RT_USING_UART4)
|
||||||
@ -395,6 +419,7 @@ void DMA1_Channel3_IRQHandler(void) {
|
|||||||
struct stm32_uart uart4 =
|
struct stm32_uart uart4 =
|
||||||
{
|
{
|
||||||
UART4,
|
UART4,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
UART4_IRQn,
|
UART4_IRQn,
|
||||||
{
|
{
|
||||||
DMA2_Channel3,
|
DMA2_Channel3,
|
||||||
@ -402,6 +427,7 @@ struct stm32_uart uart4 =
|
|||||||
DMA2_Channel3_IRQn,
|
DMA2_Channel3_IRQn,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial4;
|
struct rt_serial_device serial4;
|
||||||
|
|
||||||
@ -416,6 +442,7 @@ void UART4_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA2_Channel3_IRQHandler(void) {
|
void DMA2_Channel3_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -425,6 +452,8 @@ void DMA2_Channel3_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART4 */
|
#endif /* RT_USING_UART4 */
|
||||||
|
|
||||||
static void RCC_Configuration(void)
|
static void RCC_Configuration(void)
|
||||||
@ -521,6 +550,7 @@ static void NVIC_Configuration(struct stm32_uart* uart)
|
|||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
static void DMA_Configuration(struct rt_serial_device *serial) {
|
static void DMA_Configuration(struct rt_serial_device *serial) {
|
||||||
struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data;
|
struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data;
|
||||||
struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
|
struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
|
||||||
@ -562,6 +592,7 @@ static void DMA_Configuration(struct rt_serial_device *serial) {
|
|||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
void rt_hw_usart_init(void)
|
void rt_hw_usart_init(void)
|
||||||
{
|
{
|
||||||
|
@ -66,6 +66,7 @@ struct stm32_uart
|
|||||||
{
|
{
|
||||||
USART_TypeDef *uart_device;
|
USART_TypeDef *uart_device;
|
||||||
IRQn_Type irq;
|
IRQn_Type irq;
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
struct stm32_uart_dma
|
struct stm32_uart_dma
|
||||||
{
|
{
|
||||||
/* dma stream */
|
/* dma stream */
|
||||||
@ -81,9 +82,12 @@ struct stm32_uart
|
|||||||
/* last receive index */
|
/* last receive index */
|
||||||
rt_size_t last_recv_index;
|
rt_size_t last_recv_index;
|
||||||
} dma;
|
} dma;
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
static void DMA_Configuration(struct rt_serial_device *serial);
|
static void DMA_Configuration(struct rt_serial_device *serial);
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
||||||
{
|
{
|
||||||
@ -130,7 +134,6 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c
|
|||||||
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
|
static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||||
{
|
{
|
||||||
struct stm32_uart* uart;
|
struct stm32_uart* uart;
|
||||||
rt_uint32_t ctrl_arg = (rt_uint32_t)(arg);
|
|
||||||
|
|
||||||
RT_ASSERT(serial != RT_NULL);
|
RT_ASSERT(serial != RT_NULL);
|
||||||
uart = (struct stm32_uart *)serial->parent.user_data;
|
uart = (struct stm32_uart *)serial->parent.user_data;
|
||||||
@ -149,11 +152,13 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
|
|||||||
/* enable interrupt */
|
/* enable interrupt */
|
||||||
USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
|
USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE);
|
||||||
break;
|
break;
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
/* USART config */
|
/* USART config */
|
||||||
case RT_DEVICE_CTRL_CONFIG :
|
case RT_DEVICE_CTRL_CONFIG :
|
||||||
if (ctrl_arg == RT_DEVICE_FLAG_DMA_RX) {
|
if ((rt_uint32_t)(arg) == RT_DEVICE_FLAG_DMA_RX) {
|
||||||
DMA_Configuration(serial);
|
DMA_Configuration(serial);
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
}
|
}
|
||||||
|
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
@ -190,6 +195,7 @@ static int stm32_getc(struct rt_serial_device *serial)
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
/**
|
/**
|
||||||
* DMA initialize by DMA_InitStruct structure
|
* DMA initialize by DMA_InitStruct structure
|
||||||
*
|
*
|
||||||
@ -278,6 +284,7 @@ static void dma_rx_done_isr(struct rt_serial_device *serial)
|
|||||||
DMA_ClearFlag(uart->dma.rx_stream, uart->dma.rx_flag);
|
DMA_ClearFlag(uart->dma.rx_stream, uart->dma.rx_flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uart common interrupt process. This need add to uart ISR.
|
* Uart common interrupt process. This need add to uart ISR.
|
||||||
@ -296,10 +303,12 @@ static void uart_isr(struct rt_serial_device *serial)
|
|||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||||
}
|
}
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
if(USART_GetITStatus(uart->uart_device, USART_IT_IDLE) != RESET)
|
if(USART_GetITStatus(uart->uart_device, USART_IT_IDLE) != RESET)
|
||||||
{
|
{
|
||||||
dma_uart_rx_idle_isr(serial);
|
dma_uart_rx_idle_isr(serial);
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||||
{
|
{
|
||||||
/* clear interrupt */
|
/* clear interrupt */
|
||||||
@ -325,6 +334,7 @@ static const struct rt_uart_ops stm32_uart_ops =
|
|||||||
struct stm32_uart uart1 =
|
struct stm32_uart uart1 =
|
||||||
{
|
{
|
||||||
USART1,
|
USART1,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
USART1_IRQn,
|
USART1_IRQn,
|
||||||
{
|
{
|
||||||
DMA2_Stream5,
|
DMA2_Stream5,
|
||||||
@ -333,6 +343,7 @@ struct stm32_uart uart1 =
|
|||||||
DMA2_Stream5_IRQn,
|
DMA2_Stream5_IRQn,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial1;
|
struct rt_serial_device serial1;
|
||||||
|
|
||||||
@ -347,6 +358,7 @@ void USART1_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA2_Stream5_IRQHandler(void) {
|
void DMA2_Stream5_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -356,6 +368,8 @@ void DMA2_Stream5_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART1 */
|
#endif /* RT_USING_UART1 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART2)
|
#if defined(RT_USING_UART2)
|
||||||
@ -363,6 +377,7 @@ void DMA2_Stream5_IRQHandler(void) {
|
|||||||
struct stm32_uart uart2 =
|
struct stm32_uart uart2 =
|
||||||
{
|
{
|
||||||
USART2,
|
USART2,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
USART2_IRQn,
|
USART2_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Stream5,
|
DMA1_Stream5,
|
||||||
@ -372,6 +387,7 @@ struct stm32_uart uart2 =
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial2;
|
struct rt_serial_device serial2;
|
||||||
|
|
||||||
@ -386,6 +402,7 @@ void USART2_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Stream5_IRQHandler(void) {
|
void DMA1_Stream5_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -395,6 +412,8 @@ void DMA1_Stream5_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART2 */
|
#endif /* RT_USING_UART2 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART3)
|
#if defined(RT_USING_UART3)
|
||||||
@ -402,6 +421,7 @@ void DMA1_Stream5_IRQHandler(void) {
|
|||||||
struct stm32_uart uart3 =
|
struct stm32_uart uart3 =
|
||||||
{
|
{
|
||||||
USART3,
|
USART3,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
USART3_IRQn,
|
USART3_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Stream1,
|
DMA1_Stream1,
|
||||||
@ -411,6 +431,7 @@ struct stm32_uart uart3 =
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial3;
|
struct rt_serial_device serial3;
|
||||||
|
|
||||||
@ -425,6 +446,7 @@ void USART3_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Stream1_IRQHandler(void) {
|
void DMA1_Stream1_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -434,6 +456,8 @@ void DMA1_Stream1_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART3 */
|
#endif /* RT_USING_UART3 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART4)
|
#if defined(RT_USING_UART4)
|
||||||
@ -441,6 +465,7 @@ void DMA1_Stream1_IRQHandler(void) {
|
|||||||
struct stm32_uart uart4 =
|
struct stm32_uart uart4 =
|
||||||
{
|
{
|
||||||
UART4,
|
UART4,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
UART4_IRQn,
|
UART4_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Stream2,
|
DMA1_Stream2,
|
||||||
@ -450,6 +475,7 @@ struct stm32_uart uart4 =
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial4;
|
struct rt_serial_device serial4;
|
||||||
|
|
||||||
@ -464,6 +490,7 @@ void UART4_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Stream2_IRQHandler(void) {
|
void DMA1_Stream2_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -473,6 +500,8 @@ void DMA1_Stream2_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART4 */
|
#endif /* RT_USING_UART4 */
|
||||||
|
|
||||||
#if defined(RT_USING_UART5)
|
#if defined(RT_USING_UART5)
|
||||||
@ -480,6 +509,7 @@ void DMA1_Stream2_IRQHandler(void) {
|
|||||||
struct stm32_uart uart5 =
|
struct stm32_uart uart5 =
|
||||||
{
|
{
|
||||||
UART5,
|
UART5,
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
UART5_IRQn,
|
UART5_IRQn,
|
||||||
{
|
{
|
||||||
DMA1_Stream0,
|
DMA1_Stream0,
|
||||||
@ -489,6 +519,7 @@ struct stm32_uart uart5 =
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
};
|
};
|
||||||
struct rt_serial_device serial5;
|
struct rt_serial_device serial5;
|
||||||
|
|
||||||
@ -503,6 +534,7 @@ void UART5_IRQHandler(void)
|
|||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
void DMA1_Stream0_IRQHandler(void) {
|
void DMA1_Stream0_IRQHandler(void) {
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
@ -512,6 +544,8 @@ void DMA1_Stream0_IRQHandler(void) {
|
|||||||
/* leave interrupt */
|
/* leave interrupt */
|
||||||
rt_interrupt_leave();
|
rt_interrupt_leave();
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
#endif /* RT_USING_UART5 */
|
#endif /* RT_USING_UART5 */
|
||||||
|
|
||||||
static void RCC_Configuration(void)
|
static void RCC_Configuration(void)
|
||||||
@ -626,6 +660,7 @@ static void NVIC_Configuration(struct stm32_uart *uart)
|
|||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RT_SERIAL_USING_DMA
|
||||||
static void DMA_Configuration(struct rt_serial_device *serial) {
|
static void DMA_Configuration(struct rt_serial_device *serial) {
|
||||||
struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data;
|
struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data;
|
||||||
struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
|
struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
|
||||||
@ -653,6 +688,7 @@ static void DMA_Configuration(struct rt_serial_device *serial) {
|
|||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
|
#endif /* RT_SERIAL_USING_DMA */
|
||||||
|
|
||||||
int stm32_hw_usart_init(void)
|
int stm32_hw_usart_init(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user