Commit 3d3856c0 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files
parents 16a876a9 c078fa11
...@@ -111,7 +111,7 @@ void UART_DMA_TX_IRQHandler(void) ...@@ -111,7 +111,7 @@ void UART_DMA_TX_IRQHandler(void)
__HAL_DMA_DISABLE_IT(Uart4Handle.hdmatx, DMA_IT_TC); __HAL_DMA_DISABLE_IT(Uart4Handle.hdmatx, DMA_IT_TC);
/* Clear the transfer complete flag */ /* Clear the transfer complete flag */
__HAL_DMA_CLEAR_FLAG(Uart4Handle.hdmatx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart4Handle.hdmatx)); __HAL_DMA_CLEAR_FLAG(Uart4Handle.hdmatx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart4Handle.hdmatx));
CLEAR_BIT(Uart4Handle.Instance->CR3, (UART_CR3_DMAT | UART_CR3_DMAR)); CLEAR_BIT(Uart4Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
HAL_DMA_Abort(Uart4Handle.hdmatx); HAL_DMA_Abort(Uart4Handle.hdmatx);
// call the user function // call the user function
comm_do_dma_send(usart4_comm_dev); comm_do_dma_send(usart4_comm_dev);
...@@ -149,7 +149,7 @@ void UART_DMA_RX_IRQHandler(void) ...@@ -149,7 +149,7 @@ void UART_DMA_RX_IRQHandler(void)
__HAL_DMA_DISABLE_IT(Uart4Handle.hdmarx, DMA_IT_TC); __HAL_DMA_DISABLE_IT(Uart4Handle.hdmarx, DMA_IT_TC);
/* Clear the transfer complete flag */ /* Clear the transfer complete flag */
__HAL_DMA_CLEAR_FLAG(Uart4Handle.hdmarx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart4Handle.hdmarx)); __HAL_DMA_CLEAR_FLAG(Uart4Handle.hdmarx, __HAL_DMA_GET_TC_FLAG_INDEX(Uart4Handle.hdmarx));
CLEAR_BIT(Uart4Handle.Instance->CR3, (UART_CR3_DMAT | UART_CR3_DMAR)); CLEAR_BIT(Uart4Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
HAL_DMA_Abort(Uart4Handle.hdmarx); HAL_DMA_Abort(Uart4Handle.hdmarx);
// call the user function // call the user function
comm_do_dma_receive(usart4_comm_dev); comm_do_dma_receive(usart4_comm_dev);
...@@ -325,7 +325,7 @@ unsigned char usart4_send_dma(unsigned char *data,unsigned short int length) ...@@ -325,7 +325,7 @@ unsigned char usart4_send_dma(unsigned char *data,unsigned short int length)
__HAL_UART_CLEAR_FLAG(&Uart4Handle,UART_FLAG_TC); __HAL_UART_CLEAR_FLAG(&Uart4Handle,UART_FLAG_TC);
/* Enable the DMA transfer for transmit request by setting the DMAT bit /* Enable the DMA transfer for transmit request by setting the DMAT bit
in the UART CR3 register */ in the UART CR3 register */
SET_BIT(Uart4Handle.Instance->CR3, UART_CR3_DMAT); SET_BIT(Uart4Handle.Instance->CR3, USART_CR3_DMAT);
return 0x00; return 0x00;
} }
...@@ -333,14 +333,14 @@ unsigned char usart4_send_dma(unsigned char *data,unsigned short int length) ...@@ -333,14 +333,14 @@ unsigned char usart4_send_dma(unsigned char *data,unsigned short int length)
unsigned char usart4_receive_dma(unsigned char *data,unsigned short int length) unsigned char usart4_receive_dma(unsigned char *data,unsigned short int length)
{ {
HAL_DMA_Start_IT(Uart4Handle.hdmarx,(uint32_t)&Uart4Handle.Instance->DR,(uint32_t)data,length); HAL_DMA_Start_IT(Uart4Handle.hdmarx,(uint32_t)&Uart4Handle.Instance->DR,(uint32_t)data,length);
SET_BIT(Uart4Handle.Instance->CR3, UART_CR3_DMAR); SET_BIT(Uart4Handle.Instance->CR3, USART_CR3_DMAR);
return 0x00; return 0x00;
} }
unsigned char usart4_cancel_receive_dma(void) unsigned char usart4_cancel_receive_dma(void)
{ {
CLEAR_BIT(Uart4Handle.Instance->CR3, (UART_CR3_DMAT | UART_CR3_DMAR)); CLEAR_BIT(Uart4Handle.Instance->CR3, (USART_CR3_DMAT | USART_CR3_DMAR));
HAL_DMA_Abort(Uart4Handle.hdmarx); HAL_DMA_Abort(Uart4Handle.hdmarx);
return 0x00; return 0x00;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
void usart1_init(TComm *comm_dev,UART_InitTypeDef *conf,UART_AdvFeatureInitTypeDef *adv_conf,TUSART_IRQ_Priorities *priorities); void usart1_init(TComm *comm_dev,UART_InitTypeDef *conf,UART_AdvFeatureInitTypeDef *adv_conf,TUSART_IRQ_Priorities *priorities);
void usart1_config(TComm *comm_dev,UART_InitTypeDef *conf,UART_AdvFeatureInitTypeDef *adv_conf); void usart1_config(TComm *comm_dev,UART_InitTypeDef *conf,UART_AdvFeatureInitTypeDef *adv_conf);
void usart1_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities); void usart1_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities);
void usart1_set_baudrate(TComm *comm_dev,unsigned int baudrate);
/* IRQ functions */ /* IRQ functions */
unsigned char usart1_send_irq(unsigned char first_byte); unsigned char usart1_send_irq(unsigned char first_byte);
unsigned char usart1_enable_tx_irq(void); unsigned char usart1_enable_tx_irq(void);
......
...@@ -281,6 +281,12 @@ void usart1_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities) ...@@ -281,6 +281,12 @@ void usart1_set_priorities(TComm *comm_dev,TUSART_IRQ_Priorities *priorities)
} }
} }
void usart1_set_baudrate(TComm *comm_dev,unsigned int baudrate)
{
UartHandle.Init.BaudRate = baudrate;
HAL_UART_Init(&UartHandle);
}
/* IRQ functions */ /* IRQ functions */
unsigned char usart1_send_irq(unsigned char first_byte) unsigned char usart1_send_irq(unsigned char first_byte)
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment