diff --git a/f1/usart/include/usart1.h b/f1/usart/include/usart1.h
new file mode 100644
index 0000000000000000000000000000000000000000..67621a03121af056ba1d0002e2237983b2752878
--- /dev/null
+++ b/f1/usart/include/usart1.h
@@ -0,0 +1,22 @@
+#ifndef USART3_F1_H
+#define USART3_F1_H
+
+#include "stm32f1xx_hal.h"
+#include "usart_common.h"
+#include "comm.h"
+
+/* public functions */
+void usart1_init(TComm *comm_dev,UART_InitTypeDef *conf,TUSART_IRQ_Priorities *priorities);
+void usart1_config(TComm *comm_dev,UART_InitTypeDef *conf);
+void usart1_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities);
+/* IRQ functions */
+unsigned char usart1_send_irq(unsigned char first_byte);
+unsigned char usart1_enable_tx_irq(void);
+unsigned char usart1_receive_irq(void);
+unsigned char usart1_cancel_receive_irq(void);
+/* DMA functions */
+unsigned char usart1_send_dma(unsigned char *data,unsigned short int length);
+unsigned char usart1_receive_dma(unsigned char *data,unsigned short int length);
+unsigned char usart1_cancel_receive_dma(void);
+
+#endif
diff --git a/f1/usart/include/usart3.h b/f1/usart/include/usart3.h
index 9a56aba084c2c5c9749bf69be20b9599128b8eaa..fbc0c3b7063419b2d12b0bf128e6948e8af97300 100644
--- a/f1/usart/include/usart3.h
+++ b/f1/usart/include/usart3.h
@@ -7,6 +7,8 @@
 
 /* public functions */
 void usart3_init(TComm *comm_dev,UART_InitTypeDef *conf,TUSART_IRQ_Priorities *priorities);
+void usart3_config(TComm *comm_dev,UART_InitTypeDef *conf);
+void usart3_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities);
 /* IRQ functions */
 unsigned char usart3_send_irq(unsigned char first_byte);
 unsigned char usart3_enable_tx_irq(void);
diff --git a/f1/usart/src/usart1.c b/f1/usart/src/usart1.c
new file mode 100644
index 0000000000000000000000000000000000000000..d54b562d9f9e0491e87c911d1400c0ccaeea2879
--- /dev/null
+++ b/f1/usart/src/usart1.c
@@ -0,0 +1,339 @@
+#include "usart1.h"
+#include "gpio.h"
+
+#define     USART                    USART1
+#define     USART_ENABLE_CLK         __HAL_RCC_USART1_CLK_ENABLE()
+#define     USART_IRQn               USART1_IRQn
+#define     USART_IRQHandler         USART1_IRQHandler
+
+#define     USART_TX_PIN             GPIO_PIN_6 
+#define     USART_TX_GPIO_PORT       GPIOB
+#define     USART_ENABLE_TX_GPIO_CLK __HAL_RCC_GPIOB_CLK_ENABLE()
+
+#define     USART_RX_PIN             GPIO_PIN_7
+#define     USART_RX_GPIO_PORT       GPIOB
+#define     USART_ENABLE_RX_GPIO_CLK __HAL_RCC_GPIOB_CLK_ENABLE()
+
+/* DMA configuration */
+#define     USART_DMA                DMA1
+#define     USART_ENABLE_DMA_CLK     __HAL_RCC_DMA1_CLK_ENABLE()
+
+#define     USART_TX_DMA_CHANNEL     DMA1_Channel4
+#define     USART_RX_DMA_CHANNEL     DMA1_Channel5
+
+#define     USART_DMA_TX_IRQn        DMA1_Channel4_IRQn
+#define     USART_DMA_RX_IRQn        DMA1_Channel5_IRQn
+#define     USART_DMA_TX_IRQHandler  DMA1_Channel4_IRQHandler
+#define     USART_DMA_RX_IRQHandler  DMA1_Channel5_IRQHandler
+
+// private variables
+UART_HandleTypeDef Uart1Handle;
+DMA_HandleTypeDef usart1_hdma_tx;
+DMA_HandleTypeDef usart1_hdma_rx;
+TComm *usart1_comm_dev;
+
+// interrupt handlers
+void USART_IRQHandler(void)
+{
+  unsigned char data,ret;
+  uint32_t source;
+
+  if(__HAL_UART_GET_FLAG(&Uart1Handle, UART_FLAG_RXNE) != RESET)
+  {
+    if(__HAL_UART_GET_IT_SOURCE(&Uart1Handle, UART_IT_RXNE) !=RESET)
+    {
+      __HAL_UART_CLEAR_FLAG(&Uart1Handle,UART_FLAG_RXNE);
+      data=(uint8_t)(Uart1Handle.Instance->DR & (uint8_t)0x00FF);
+      // call the reception function
+      if(!comm_do_irq_receive(usart1_comm_dev,data))
+        __HAL_UART_DISABLE_IT(&Uart1Handle, UART_IT_RXNE);
+    }
+  }
+  if(__HAL_UART_GET_FLAG(&Uart1Handle, UART_FLAG_TC) != RESET)
+  {
+    if(__HAL_UART_GET_IT_SOURCE(&Uart1Handle, UART_IT_TC) !=RESET)
+    {
+      __HAL_UART_CLEAR_FLAG(&Uart1Handle,UART_FLAG_TC);
+      ret=comm_do_irq_send(usart1_comm_dev,&data);
+      if(ret==0x01)
+        Uart1Handle.Instance->DR=data;
+      else if(ret==0x00)
+        __HAL_UART_DISABLE_IT(&Uart1Handle, UART_IT_TC);
+    }
+  }
+  if(__HAL_UART_GET_FLAG(&Uart1Handle, UART_FLAG_PE) != RESET)// parity error
+  {
+    if(__HAL_UART_GET_IT_SOURCE(&Uart1Handle, UART_IT_PE) !=RESET)
+    {
+      __HAL_UART_CLEAR_PEFLAG(&Uart1Handle);
+    }
+  }
+  source=__HAL_UART_GET_IT_SOURCE(&Uart1Handle, UART_IT_ERR);
+  if(__HAL_UART_GET_FLAG(&Uart1Handle, UART_FLAG_FE) != RESET)// frame error
+  {
+    if(source !=RESET)
+    {
+      __HAL_UART_CLEAR_FEFLAG(&Uart1Handle);
+    }
+  }
+  if(__HAL_UART_GET_FLAG(&Uart1Handle, UART_FLAG_NE) != RESET)// noise error
+  {
+    if(source !=RESET)
+    {
+      __HAL_UART_CLEAR_NEFLAG(&Uart1Handle);
+    }
+  }
+  if(__HAL_UART_GET_FLAG(&Uart1Handle, UART_FLAG_ORE) != RESET)// overrun error
+  {
+    if(source !=RESET)
+    {
+      __HAL_UART_CLEAR_OREFLAG(&Uart1Handle);
+    }
+  }
+}
+
+void USART_DMA_TX_IRQHandler(void)
+{
+  if(__HAL_DMA_GET_FLAG(Uart1Handle.hdmatx,__HAL_DMA_GET_TE_FLAG_INDEX(Uart1Handle.hdmatx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart1Handle.hdmatx, DMA_IT_TE) != RESET)
+    {
+      /* Disable the transfer error interrupt */
+      __HAL_DMA_DISABLE_IT(Uart1Handle.hdmatx, DMA_IT_TE);
+      /* Clear the transfer error flag */
+      __HAL_DMA_CLEAR_FLAG(Uart1Handle.hdmatx, __HAL_DMA_GET_TE_FLAG_INDEX(Uart1Handle.hdmatx));
+    }
+  }
+  if(__HAL_DMA_GET_FLAG(Uart1Handle.hdmatx,__HAL_DMA_GET_TC_FLAG_INDEX(Uart1Handle.hdmatx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart1Handle.hdmatx, DMA_IT_TC) != RESET)
+    {
+      /* Disable the half transfer interrupt */
+      __HAL_DMA_DISABLE_IT(Uart1Handle.hdmatx, DMA_IT_TC);
+      /* Clear the transfer complete flag */
+      __HAL_DMA_CLEAR_FLAG(Uart1Handle.hdmatx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart1Handle.hdmatx));
+      CLEAR_BIT(Uart1Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
+      HAL_DMA_Abort(Uart1Handle.hdmatx);
+      // call the user function
+      comm_do_dma_send(usart1_comm_dev);
+    }
+  }
+  if(__HAL_DMA_GET_FLAG(Uart1Handle.hdmatx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart1Handle.hdmatx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart1Handle.hdmatx, DMA_IT_HT) != RESET)
+    {
+      /* Disable the half transfer interrupt */
+      __HAL_DMA_DISABLE_IT(Uart1Handle.hdmatx, DMA_IT_HT);
+      /* Clear the half transfer complete flag */
+      __HAL_DMA_CLEAR_FLAG(Uart1Handle.hdmatx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart1Handle.hdmatx));
+    }
+  }
+}
+
+void USART_DMA_RX_IRQHandler(void)
+{
+  if(__HAL_DMA_GET_FLAG(Uart1Handle.hdmarx,__HAL_DMA_GET_TE_FLAG_INDEX(Uart1Handle.hdmarx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart1Handle.hdmarx, DMA_IT_TE) != RESET)
+    {
+      /* Disable the transfer error interrupt */
+      __HAL_DMA_DISABLE_IT(Uart1Handle.hdmarx, DMA_IT_TE);
+      /* Clear the transfer error flag */
+      __HAL_DMA_CLEAR_FLAG(Uart1Handle.hdmarx, __HAL_DMA_GET_TE_FLAG_INDEX(Uart1Handle.hdmarx));
+    }
+  }
+  if(__HAL_DMA_GET_FLAG(Uart1Handle.hdmarx,__HAL_DMA_GET_TC_FLAG_INDEX(Uart1Handle.hdmarx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart1Handle.hdmarx, DMA_IT_TC) != RESET)
+    {
+      /* Disable the transfer complete interrupt */
+      __HAL_DMA_DISABLE_IT(Uart1Handle.hdmarx, DMA_IT_TC);
+      /* Clear the transfer complete flag */
+      __HAL_DMA_CLEAR_FLAG(Uart1Handle.hdmarx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart1Handle.hdmarx));
+      CLEAR_BIT(Uart1Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
+      HAL_DMA_Abort(Uart1Handle.hdmarx);
+      // call the user function
+      comm_do_dma_receive(usart1_comm_dev);
+    }
+  }
+  if(__HAL_DMA_GET_FLAG(Uart1Handle.hdmarx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart1Handle.hdmarx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart1Handle.hdmarx, DMA_IT_HT) != RESET)
+    {
+      /* Disable the half transfer interrupt */
+      __HAL_DMA_DISABLE_IT(Uart1Handle.hdmarx, DMA_IT_HT);
+      /* Clear the half transfer complete flag */
+      __HAL_DMA_CLEAR_FLAG(Uart1Handle.hdmarx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart1Handle.hdmarx));
+    }
+  }
+}
+
+/* public functions*/
+void usart1_init(TComm *comm_dev,UART_InitTypeDef *conf,TUSART_IRQ_Priorities *priorities)
+{
+  GPIO_InitTypeDef GPIO_InitStructure;
+
+  /* Enable GPIO clock */
+  USART_ENABLE_TX_GPIO_CLK;
+  USART_ENABLE_RX_GPIO_CLK;
+  USART_ENABLE_DMA_CLK;
+  // configure the GPIO pins
+
+  USART_ENABLE_CLK;
+
+  /* Configure USART Tx and Rx as alternate function push-pull */
+  GPIO_InitStructure.Pin       = USART_TX_PIN;
+  GPIO_InitStructure.Mode      = GPIO_MODE_AF_PP;
+  GPIO_InitStructure.Speed     = GPIO_SPEED_HIGH;
+  HAL_GPIO_Init(USART_TX_GPIO_PORT, &GPIO_InitStructure);
+
+  GPIO_InitStructure.Pin       = USART_RX_PIN;
+  GPIO_InitStructure.Pull      = GPIO_NOPULL;
+  GPIO_InitStructure.Mode      = GPIO_MODE_INPUT;
+  HAL_GPIO_Init(USART_RX_GPIO_PORT, &GPIO_InitStructure);
+
+  Uart1Handle.Instance          = USART;
+  usart1_config(comm_dev,conf);
+
+  if(comm_dev->use_dma)
+  {
+    // configure the DMA channels
+    usart1_hdma_tx.Instance                 = USART_TX_DMA_CHANNEL;
+    usart1_hdma_tx.Init.Direction           = DMA_MEMORY_TO_PERIPH;
+    usart1_hdma_tx.Init.PeriphInc           = DMA_PINC_DISABLE;
+    usart1_hdma_tx.Init.MemInc              = DMA_MINC_ENABLE;
+    usart1_hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+    usart1_hdma_tx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
+    usart1_hdma_tx.Init.Mode                = DMA_NORMAL;
+    usart1_hdma_tx.Init.Priority            = DMA_PRIORITY_LOW;
+
+    HAL_DMA_Init(&usart1_hdma_tx);
+
+    /* Associate the initialized DMA handle to the UART handle */
+    __HAL_LINKDMA(&Uart1Handle, hdmatx, usart1_hdma_tx);
+
+    /* Configure the DMA handler for reception process */
+    usart1_hdma_rx.Instance                 = USART_RX_DMA_CHANNEL;
+    usart1_hdma_rx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
+    usart1_hdma_rx.Init.PeriphInc           = DMA_PINC_DISABLE;
+    usart1_hdma_rx.Init.MemInc              = DMA_MINC_ENABLE;
+    usart1_hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+    usart1_hdma_rx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
+    usart1_hdma_rx.Init.Mode                = DMA_NORMAL;
+    usart1_hdma_rx.Init.Priority            = DMA_PRIORITY_HIGH;
+
+    HAL_DMA_Init(&usart1_hdma_rx);
+
+    /* Associate the initialized DMA handle to the the UART handle */
+    __HAL_LINKDMA(&Uart1Handle, hdmarx, usart1_hdma_rx);
+  }
+  usart1_set_priorities(comm_dev,priorities);
+
+  /* Initialize the comm structure */
+  comm_dev->send_irq=usart1_send_irq;
+  comm_dev->enable_tx_irq=usart1_enable_tx_irq;
+  comm_dev->receive_irq=usart1_receive_irq;
+  comm_dev->cancel_receive_irq=usart1_cancel_receive_irq;
+  if(comm_dev->use_dma)
+  {
+    comm_dev->send_dma=usart1_send_dma;
+    comm_dev->receive_dma=usart1_receive_dma;
+    comm_dev->cancel_receive_dma=usart1_cancel_receive_dma;
+  }
+  comm_dev->irq_send_cb=0x00000000;
+  comm_dev->irq_receive_cb=0x00000000;
+  comm_dev->dma_send_cb=0x00000000;
+  comm_dev->dma_receive_cb=0x00000000;
+
+  /* initialize internal variables */
+  usart1_comm_dev=comm_dev;
+}
+
+void usart1_config(TComm *comm_dev,UART_InitTypeDef *conf)
+{
+  Uart1Handle.Init.BaudRate     = conf->BaudRate;
+  Uart1Handle.Init.WordLength   = conf->WordLength;
+  Uart1Handle.Init.StopBits     = conf->StopBits;
+  Uart1Handle.Init.Parity       = conf->Parity;
+  Uart1Handle.Init.Mode         = conf->Mode;
+  Uart1Handle.Init.HwFlowCtl    = conf->HwFlowCtl;
+  Uart1Handle.Init.OverSampling = conf->OverSampling;
+  HAL_UART_Init(&Uart1Handle);
+}
+
+void usart1_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities)
+{
+  HAL_NVIC_SetPriority(USART_IRQn, priorities->irq_priority,priorities->irq_subpriority);
+  HAL_NVIC_EnableIRQ(USART_IRQn);
+  if(comm_dev->use_dma)
+  {
+    HAL_NVIC_SetPriority(USART_DMA_TX_IRQn, priorities->dma_tx_priority,priorities->dma_tx_subpriority);
+    HAL_NVIC_EnableIRQ(USART_DMA_TX_IRQn);
+    HAL_NVIC_SetPriority(USART_DMA_RX_IRQn, priorities->dma_rx_priority,priorities->dma_rx_subpriority);
+    HAL_NVIC_EnableIRQ(USART_DMA_RX_IRQn);
+  }
+}
+
+/* IRQ functions */
+unsigned char usart1_send_irq(unsigned char first_byte)
+{
+  __HAL_UART_CLEAR_FLAG(&Uart1Handle,UART_FLAG_TC);
+  __HAL_UART_ENABLE_IT(&Uart1Handle, UART_IT_TC);
+  Uart1Handle.Instance->DR=first_byte;
+
+  return 0x00;
+}
+
+unsigned char usart1_enable_tx_irq(void)
+{
+  __HAL_UART_CLEAR_FLAG(&Uart1Handle,UART_FLAG_TC);
+  __HAL_UART_ENABLE_IT(&Uart1Handle, UART_IT_TC);
+
+  return 0x00;
+}
+
+unsigned char usart1_receive_irq(void)
+{
+  /* enable the rx interrupt */
+  __HAL_UART_ENABLE_IT(&Uart1Handle, UART_IT_RXNE);
+
+  return 0x00;
+}
+
+unsigned char usart1_cancel_receive_irq(void)
+{
+  /* disable the rx interrupt */
+  __HAL_UART_DISABLE_IT(&Uart1Handle, UART_IT_RXNE);
+
+  return 0x00;
+}
+
+/* DMA functions */
+unsigned char usart1_send_dma(unsigned char *data,unsigned short int length)
+{
+  HAL_DMA_Start_IT(Uart1Handle.hdmatx,(uint32_t)data,(uint32_t)&Uart1Handle.Instance->DR,length);
+  /* Clear the TC flag in the SR register by writing 0 to it */
+  __HAL_UART_CLEAR_FLAG(&Uart1Handle,UART_FLAG_TC);
+  /* Enable the DMA transfer for transmit request by setting the DMAT bit
+     in the UART CR3 register */
+  SET_BIT(Uart1Handle.Instance->CR3, USART_CR3_DMAT);
+
+  return 0x00;
+}
+
+unsigned char usart1_receive_dma(unsigned char *data,unsigned short int length)
+{
+  HAL_DMA_Start_IT(Uart1Handle.hdmarx,(uint32_t)&Uart1Handle.Instance->DR,(uint32_t)data,length);
+  SET_BIT(Uart1Handle.Instance->CR3, USART_CR3_DMAR);
+
+  return 0x00;
+}
+
+unsigned char usart1_cancel_receive_dma(void)
+{
+  CLEAR_BIT(Uart1Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
+  HAL_DMA_Abort(Uart1Handle.hdmarx);
+
+  return 0x00;
+}
+
diff --git a/f1/usart/src/usart3.c b/f1/usart/src/usart3.c
index 2f1669d626fb30422392f0309d2bcecbb4be0c3f..322b771cafa94c8d325d7710394e0dc6ceac7761 100644
--- a/f1/usart/src/usart3.c
+++ b/f1/usart/src/usart3.c
@@ -26,105 +26,143 @@
 #define     USART_DMA_RX_IRQHandler  DMA1_Channel3_IRQHandler
 
 // private variables
-UART_HandleTypeDef UartHandle;
-DMA_HandleTypeDef hdma_tx;
-DMA_HandleTypeDef hdma_rx;
+UART_HandleTypeDef Uart3Handle;
+DMA_HandleTypeDef usart3_hdma_tx;
+DMA_HandleTypeDef usart3_hdma_rx;
 TComm *usart3_comm_dev;
 
 // interrupt handlers
 void USART_IRQHandler(void)
 {
   unsigned char data,ret;
+  uint32_t source;
 
-  if(__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE) != RESET)
+  if(__HAL_UART_GET_FLAG(&Uart3Handle, UART_FLAG_RXNE) != RESET)
   {
-    if(__HAL_UART_GET_IT_SOURCE(&UartHandle, UART_IT_RXNE) !=RESET)
+    if(__HAL_UART_GET_IT_SOURCE(&Uart3Handle, UART_IT_RXNE) !=RESET)
     {
-      __HAL_UART_CLEAR_FLAG(&UartHandle,UART_FLAG_RXNE);
-      data=(uint8_t)(UartHandle.Instance->DR & (uint8_t)0x00FF);
+      __HAL_UART_CLEAR_FLAG(&Uart3Handle,UART_FLAG_RXNE);
+      data=(uint8_t)(Uart3Handle.Instance->DR & (uint8_t)0x00FF);
       // call the reception function
       if(!comm_do_irq_receive(usart3_comm_dev,data))
-        __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_RXNE);
+        __HAL_UART_DISABLE_IT(&Uart3Handle, UART_IT_RXNE);
     }
   }
-  else if(__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_TC) != RESET)
+  if(__HAL_UART_GET_FLAG(&Uart3Handle, UART_FLAG_TC) != RESET)
   {
-    if(__HAL_UART_GET_IT_SOURCE(&UartHandle, UART_IT_TC) !=RESET)
+    if(__HAL_UART_GET_IT_SOURCE(&Uart3Handle, UART_IT_TC) !=RESET)
     {
-      __HAL_UART_CLEAR_FLAG(&UartHandle,UART_FLAG_TC);
+      __HAL_UART_CLEAR_FLAG(&Uart3Handle,UART_FLAG_TC);
       ret=comm_do_irq_send(usart3_comm_dev,&data);
       if(ret==0x01)
-        UartHandle.Instance->DR=data;
+        Uart3Handle.Instance->DR=data;
       else if(ret==0x00)
-        __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TC);
+        __HAL_UART_DISABLE_IT(&Uart3Handle, UART_IT_TC);
     }
   }
-/*  if(USART_GetITStatus(USART,USART_FLAG_ORE) != RESET)// overrun error
+  if(__HAL_UART_GET_FLAG(&Uart3Handle, UART_FLAG_PE) != RESET)// parity error
   {
-    // cancel any pending reception
-    USART_ITConfig(USART, USART_IT_RXNE, DISABLE);
-    usart3_comm_dev->irq_receiving=0x00;
+    if(__HAL_UART_GET_IT_SOURCE(&Uart3Handle, UART_IT_PE) !=RESET)
+    {
+      __HAL_UART_CLEAR_PEFLAG(&Uart3Handle);
+    }
+  }
+  source=__HAL_UART_GET_IT_SOURCE(&Uart3Handle, UART_IT_ERR);
+  if(__HAL_UART_GET_FLAG(&Uart3Handle, UART_FLAG_FE) != RESET)// frame error
+  {
+    if(source !=RESET)
+    {
+      __HAL_UART_CLEAR_FEFLAG(&Uart3Handle);
+    }
   }
-  if(USART_GetITStatus(USART,USART_IT_PE) != RESET)// parity error
+  if(__HAL_UART_GET_FLAG(&Uart3Handle, UART_FLAG_NE) != RESET)// noise error
   {
-    // cancel any pending reception
-    USART_ITConfig(USART, USART_IT_RXNE, DISABLE);
-    usart3_comm_dev->irq_receiving=0x00;
-  }*/
+    if(source !=RESET)
+    {
+      __HAL_UART_CLEAR_NEFLAG(&Uart3Handle);
+    }
+  }
+  if(__HAL_UART_GET_FLAG(&Uart3Handle, UART_FLAG_ORE) != RESET)// overrun error
+  {
+    if(source !=RESET)
+    {
+      __HAL_UART_CLEAR_OREFLAG(&Uart3Handle);
+    }
+  }
 }
 
 void USART_DMA_TX_IRQHandler(void)
 {
-  if(__HAL_DMA_GET_FLAG(UartHandle.hdmatx,__HAL_DMA_GET_TC_FLAG_INDEX(UartHandle.hdmatx)) != RESET)
+  if(__HAL_DMA_GET_FLAG(Uart3Handle.hdmatx,__HAL_DMA_GET_TE_FLAG_INDEX(Uart3Handle.hdmatx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart3Handle.hdmatx, DMA_IT_TE) != RESET)
+    {
+      /* Disable the transfer error interrupt */
+      __HAL_DMA_DISABLE_IT(Uart3Handle.hdmatx, DMA_IT_TE);
+      /* Clear the transfer error flag */
+      __HAL_DMA_CLEAR_FLAG(Uart3Handle.hdmatx, __HAL_DMA_GET_TE_FLAG_INDEX(Uart3Handle.hdmatx));
+    }
+  }
+  if(__HAL_DMA_GET_FLAG(Uart3Handle.hdmatx,__HAL_DMA_GET_TC_FLAG_INDEX(Uart3Handle.hdmatx)) != RESET)
   {
-    if(__HAL_DMA_GET_IT_SOURCE(UartHandle.hdmatx, DMA_IT_TC) != RESET)
+    if(__HAL_DMA_GET_IT_SOURCE(Uart3Handle.hdmatx, DMA_IT_TC) != RESET)
     {
       /* Disable the half transfer interrupt */
-      __HAL_DMA_DISABLE_IT(UartHandle.hdmatx, DMA_IT_TC);
+      __HAL_DMA_DISABLE_IT(Uart3Handle.hdmatx, DMA_IT_TC);
       /* Clear the transfer complete flag */
-      __HAL_DMA_CLEAR_FLAG(UartHandle.hdmatx, __HAL_DMA_GET_TC_FLAG_INDEX(UartHandle.hdmatx));
-      CLEAR_BIT(UartHandle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
-      HAL_DMA_Abort(UartHandle.hdmatx);
+      __HAL_DMA_CLEAR_FLAG(Uart3Handle.hdmatx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart3Handle.hdmatx));
+      CLEAR_BIT(Uart3Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
+      HAL_DMA_Abort(Uart3Handle.hdmatx);
       // call the user function
       comm_do_dma_send(usart3_comm_dev);
     }
   }
-  if(__HAL_DMA_GET_FLAG(UartHandle.hdmatx, __HAL_DMA_GET_HT_FLAG_INDEX(UartHandle.hdmatx)) != RESET)
+  if(__HAL_DMA_GET_FLAG(Uart3Handle.hdmatx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart3Handle.hdmatx)) != RESET)
   {
-    if(__HAL_DMA_GET_IT_SOURCE(UartHandle.hdmatx, DMA_IT_HT) != RESET)
+    if(__HAL_DMA_GET_IT_SOURCE(Uart3Handle.hdmatx, DMA_IT_HT) != RESET)
     {
       /* Disable the half transfer interrupt */
-      __HAL_DMA_DISABLE_IT(UartHandle.hdmatx, DMA_IT_HT);
+      __HAL_DMA_DISABLE_IT(Uart3Handle.hdmatx, DMA_IT_HT);
       /* Clear the half transfer complete flag */
-      __HAL_DMA_CLEAR_FLAG(UartHandle.hdmatx, __HAL_DMA_GET_HT_FLAG_INDEX(UartHandle.hdmatx));
+      __HAL_DMA_CLEAR_FLAG(Uart3Handle.hdmatx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart3Handle.hdmatx));
     }
   }
 }
 
 void USART_DMA_RX_IRQHandler(void)
 {
-  if(__HAL_DMA_GET_FLAG(UartHandle.hdmarx,__HAL_DMA_GET_TC_FLAG_INDEX(UartHandle.hdmarx)) != RESET)
+  if(__HAL_DMA_GET_FLAG(Uart3Handle.hdmarx,__HAL_DMA_GET_TE_FLAG_INDEX(Uart3Handle.hdmarx)) != RESET)
+  {
+    if(__HAL_DMA_GET_IT_SOURCE(Uart3Handle.hdmarx, DMA_IT_TE) != RESET)
+    {
+      /* Disable the transfer error interrupt */
+      __HAL_DMA_DISABLE_IT(Uart3Handle.hdmarx, DMA_IT_TE);
+      /* Clear the transfer error flag */
+      __HAL_DMA_CLEAR_FLAG(Uart3Handle.hdmarx, __HAL_DMA_GET_TE_FLAG_INDEX(Uart3Handle.hdmarx));
+    }
+  }
+  if(__HAL_DMA_GET_FLAG(Uart3Handle.hdmarx,__HAL_DMA_GET_TC_FLAG_INDEX(Uart3Handle.hdmarx)) != RESET)
   {
-    if(__HAL_DMA_GET_IT_SOURCE(UartHandle.hdmarx, DMA_IT_TC) != RESET)
+    if(__HAL_DMA_GET_IT_SOURCE(Uart3Handle.hdmarx, DMA_IT_TC) != RESET)
     {
       /* Disable the transfer complete interrupt */
-      __HAL_DMA_DISABLE_IT(UartHandle.hdmarx, DMA_IT_TC);
+      __HAL_DMA_DISABLE_IT(Uart3Handle.hdmarx, DMA_IT_TC);
       /* Clear the transfer complete flag */
-      __HAL_DMA_CLEAR_FLAG(UartHandle.hdmarx, __HAL_DMA_GET_TC_FLAG_INDEX(UartHandle.hdmarx));
-      CLEAR_BIT(UartHandle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
-      HAL_DMA_Abort(UartHandle.hdmarx);
+      __HAL_DMA_CLEAR_FLAG(Uart3Handle.hdmarx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart3Handle.hdmarx));
+      CLEAR_BIT(Uart3Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
+      HAL_DMA_Abort(Uart3Handle.hdmarx);
       // call the user function
       comm_do_dma_receive(usart3_comm_dev);
     }
   }
-  if(__HAL_DMA_GET_FLAG(UartHandle.hdmarx, __HAL_DMA_GET_HT_FLAG_INDEX(UartHandle.hdmarx)) != RESET)
+  if(__HAL_DMA_GET_FLAG(Uart3Handle.hdmarx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart3Handle.hdmarx)) != RESET)
   {
-    if(__HAL_DMA_GET_IT_SOURCE(UartHandle.hdmarx, DMA_IT_HT) != RESET)
+    if(__HAL_DMA_GET_IT_SOURCE(Uart3Handle.hdmarx, DMA_IT_HT) != RESET)
     {
       /* Disable the half transfer interrupt */
-      __HAL_DMA_DISABLE_IT(UartHandle.hdmarx, DMA_IT_HT);
+      __HAL_DMA_DISABLE_IT(Uart3Handle.hdmarx, DMA_IT_HT);
       /* Clear the half transfer complete flag */
-      __HAL_DMA_CLEAR_FLAG(UartHandle.hdmarx, __HAL_DMA_GET_HT_FLAG_INDEX(UartHandle.hdmarx));
+      __HAL_DMA_CLEAR_FLAG(Uart3Handle.hdmarx, __HAL_DMA_GET_HT_FLAG_INDEX(Uart3Handle.hdmarx));
     }
   }
 }
@@ -151,60 +189,45 @@ void usart3_init(TComm *comm_dev,UART_InitTypeDef *conf,TUSART_IRQ_Priorities *p
   GPIO_InitStructure.Mode      = GPIO_MODE_INPUT;
   HAL_GPIO_Init(USART_RX_GPIO_PORT, &GPIO_InitStructure);
 
-  UartHandle.Instance          = USART;
-
-  UartHandle.Init.BaudRate     = conf->BaudRate;
-  UartHandle.Init.WordLength   = conf->WordLength;
-  UartHandle.Init.StopBits     = conf->StopBits;
-  UartHandle.Init.Parity       = conf->Parity;
-  UartHandle.Init.Mode         = conf->Mode;
-  UartHandle.Init.HwFlowCtl    = conf->HwFlowCtl;
-  UartHandle.Init.OverSampling = conf->OverSampling; 
-  HAL_UART_Init(&UartHandle);
-
   USART_ENABLE_CLK;
 
-  HAL_NVIC_SetPriority(USART_IRQn, priorities->irq_priority,priorities->irq_subpriority);
-  HAL_NVIC_EnableIRQ(USART_IRQn);
+  Uart3Handle.Instance          = USART;
+  usart3_config(comm_dev,conf);
 
   if(comm_dev->use_dma)
   {
     // configure the DMA channels
-    hdma_tx.Instance                 = USART_TX_DMA_CHANNEL;
-    hdma_tx.Init.Direction           = DMA_MEMORY_TO_PERIPH;
-    hdma_tx.Init.PeriphInc           = DMA_PINC_DISABLE;
-    hdma_tx.Init.MemInc              = DMA_MINC_ENABLE;
-    hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
-    hdma_tx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
-    hdma_tx.Init.Mode                = DMA_NORMAL;
-    hdma_tx.Init.Priority            = DMA_PRIORITY_LOW;
+    usart3_hdma_tx.Instance                 = USART_TX_DMA_CHANNEL;
+    usart3_hdma_tx.Init.Direction           = DMA_MEMORY_TO_PERIPH;
+    usart3_hdma_tx.Init.PeriphInc           = DMA_PINC_DISABLE;
+    usart3_hdma_tx.Init.MemInc              = DMA_MINC_ENABLE;
+    usart3_hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+    usart3_hdma_tx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
+    usart3_hdma_tx.Init.Mode                = DMA_NORMAL;
+    usart3_hdma_tx.Init.Priority            = DMA_PRIORITY_LOW;
 
-    HAL_DMA_Init(&hdma_tx);
+    HAL_DMA_Init(&usart3_hdma_tx);
 
     /* Associate the initialized DMA handle to the UART handle */
-    __HAL_LINKDMA(&UartHandle, hdmatx, hdma_tx);
-
-    HAL_NVIC_SetPriority(USART_DMA_TX_IRQn, priorities->dma_tx_priority,priorities->dma_tx_subpriority);
-    HAL_NVIC_EnableIRQ(USART_DMA_TX_IRQn);
+    __HAL_LINKDMA(&Uart3Handle, hdmatx, usart3_hdma_tx);
 
     /* Configure the DMA handler for reception process */
-    hdma_rx.Instance                 = USART_RX_DMA_CHANNEL;
-    hdma_rx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
-    hdma_rx.Init.PeriphInc           = DMA_PINC_DISABLE;
-    hdma_rx.Init.MemInc              = DMA_MINC_ENABLE;
-    hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
-    hdma_rx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
-    hdma_rx.Init.Mode                = DMA_NORMAL;
-    hdma_rx.Init.Priority            = DMA_PRIORITY_HIGH;
+    usart3_hdma_rx.Instance                 = USART_RX_DMA_CHANNEL;
+    usart3_hdma_rx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
+    usart3_hdma_rx.Init.PeriphInc           = DMA_PINC_DISABLE;
+    usart3_hdma_rx.Init.MemInc              = DMA_MINC_ENABLE;
+    usart3_hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
+    usart3_hdma_rx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
+    usart3_hdma_rx.Init.Mode                = DMA_NORMAL;
+    usart3_hdma_rx.Init.Priority            = DMA_PRIORITY_HIGH;
 
-    HAL_DMA_Init(&hdma_rx);
+    HAL_DMA_Init(&usart3_hdma_rx);
 
     /* Associate the initialized DMA handle to the the UART handle */
-    __HAL_LINKDMA(&UartHandle, hdmarx, hdma_rx);
-
-    HAL_NVIC_SetPriority(USART_DMA_RX_IRQn, priorities->dma_rx_priority,priorities->dma_rx_subpriority);
-    HAL_NVIC_EnableIRQ(USART_DMA_RX_IRQn);
+    __HAL_LINKDMA(&Uart3Handle, hdmarx, usart3_hdma_rx);
   }
+  usart3_set_priorities(comm_dev,priorities);
+
   /* Initialize the comm structure */
   comm_dev->send_irq=usart3_send_irq;
   comm_dev->enable_tx_irq=usart3_enable_tx_irq;
@@ -225,20 +248,45 @@ void usart3_init(TComm *comm_dev,UART_InitTypeDef *conf,TUSART_IRQ_Priorities *p
   usart3_comm_dev=comm_dev;
 }
 
+void usart3_config(TComm *comm_dev,UART_InitTypeDef *conf)
+{
+  Uart3Handle.Init.BaudRate     = conf->BaudRate;
+  Uart3Handle.Init.WordLength   = conf->WordLength;
+  Uart3Handle.Init.StopBits     = conf->StopBits;
+  Uart3Handle.Init.Parity       = conf->Parity;
+  Uart3Handle.Init.Mode         = conf->Mode;
+  Uart3Handle.Init.HwFlowCtl    = conf->HwFlowCtl;
+  Uart3Handle.Init.OverSampling = conf->OverSampling;
+  HAL_UART_Init(&Uart3Handle);
+}
+
+void usart3_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities)
+{
+  HAL_NVIC_SetPriority(USART_IRQn, priorities->irq_priority,priorities->irq_subpriority);
+  HAL_NVIC_EnableIRQ(USART_IRQn);
+  if(comm_dev->use_dma)
+  {
+    HAL_NVIC_SetPriority(USART_DMA_TX_IRQn, priorities->dma_tx_priority,priorities->dma_tx_subpriority);
+    HAL_NVIC_EnableIRQ(USART_DMA_TX_IRQn);
+    HAL_NVIC_SetPriority(USART_DMA_RX_IRQn, priorities->dma_rx_priority,priorities->dma_rx_subpriority);
+    HAL_NVIC_EnableIRQ(USART_DMA_RX_IRQn);
+  }
+}
+
 /* IRQ functions */
 unsigned char usart3_send_irq(unsigned char first_byte)
 {
-  __HAL_UART_CLEAR_FLAG(&UartHandle,UART_FLAG_TC);
-  __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_TC);
-  UartHandle.Instance->DR=first_byte;
+  __HAL_UART_CLEAR_FLAG(&Uart3Handle,UART_FLAG_TC);
+  __HAL_UART_ENABLE_IT(&Uart3Handle, UART_IT_TC);
+  Uart3Handle.Instance->DR=first_byte;
 
   return 0x00;
 }
 
 unsigned char usart3_enable_tx_irq(void)
 {
-  __HAL_UART_CLEAR_FLAG(&UartHandle,UART_FLAG_TC);
-  __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_TC);
+  __HAL_UART_CLEAR_FLAG(&Uart3Handle,UART_FLAG_TC);
+  __HAL_UART_ENABLE_IT(&Uart3Handle, UART_IT_TC);
 
   return 0x00;
 }
@@ -246,7 +294,7 @@ unsigned char usart3_enable_tx_irq(void)
 unsigned char usart3_receive_irq(void)
 {
   /* enable the rx interrupt */
-  __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_RXNE);
+  __HAL_UART_ENABLE_IT(&Uart3Handle, UART_IT_RXNE);
 
   return 0x00;
 }
@@ -254,7 +302,7 @@ unsigned char usart3_receive_irq(void)
 unsigned char usart3_cancel_receive_irq(void)
 {
   /* disable the rx interrupt */
-  __HAL_UART_DISABLE_IT(&UartHandle, UART_IT_RXNE);
+  __HAL_UART_DISABLE_IT(&Uart3Handle, UART_IT_RXNE);
 
   return 0x00;
 }
@@ -262,28 +310,28 @@ unsigned char usart3_cancel_receive_irq(void)
 /* DMA functions */
 unsigned char usart3_send_dma(unsigned char *data,unsigned short int length)
 {
-  HAL_DMA_Start_IT(UartHandle.hdmatx,(uint32_t)data,(uint32_t)&UartHandle.Instance->DR,length);
+  HAL_DMA_Start_IT(Uart3Handle.hdmatx,(uint32_t)data,(uint32_t)&Uart3Handle.Instance->DR,length);
   /* Clear the TC flag in the SR register by writing 0 to it */
-  __HAL_UART_CLEAR_FLAG(&UartHandle,UART_FLAG_TC);
+  __HAL_UART_CLEAR_FLAG(&Uart3Handle,UART_FLAG_TC);
   /* Enable the DMA transfer for transmit request by setting the DMAT bit
      in the UART CR3 register */
-  SET_BIT(UartHandle.Instance->CR3, USART_CR3_DMAT);
+  SET_BIT(Uart3Handle.Instance->CR3, USART_CR3_DMAT);
 
   return 0x00;
 }
 
 unsigned char usart3_receive_dma(unsigned char *data,unsigned short int length)
 {
-  HAL_DMA_Start_IT(UartHandle.hdmarx,(uint32_t)&UartHandle.Instance->DR,(uint32_t)data,length);
-  SET_BIT(UartHandle.Instance->CR3, USART_CR3_DMAR);
+  HAL_DMA_Start_IT(Uart3Handle.hdmarx,(uint32_t)&Uart3Handle.Instance->DR,(uint32_t)data,length);
+  SET_BIT(Uart3Handle.Instance->CR3, USART_CR3_DMAR);
 
   return 0x00;
 }
 
 unsigned char usart3_cancel_receive_dma(void)
 {
-  CLEAR_BIT(UartHandle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
-  HAL_DMA_Abort(UartHandle.hdmarx);
+  CLEAR_BIT(Uart3Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
+  HAL_DMA_Abort(Uart3Handle.hdmarx);
 
   return 0x00;
 }