97
97
*
98
98
******************************************************************************
99
99
*/
100
-
100
+ #if defined( TIM1_BASE ) && defined( UART_EMUL_RX ) && defined( UART_EMUL_TX )
101
101
/* Includes ------------------------------------------------------------------*/
102
102
#include "hal_uart_emul.h"
103
103
@@ -687,7 +687,7 @@ static void UART_Emul_ReceiveFrame(UART_Emul_HandleTypeDef *huart, uint32_t *pDa
687
687
uint32_t tmp_size = 0 ;
688
688
uint32_t tmp_arr = 0 ;
689
689
690
- tmp_arr = UART_EMUL_RX_TIMER_INSTANCE -> ARR ;
690
+ tmp_arr = UART_EMUL_RX_TIMER_INSTANCE -> ARR ;
691
691
tmp_ds = (uint32_t )pData ;
692
692
tmp_sr = (uint32_t ) & (huart -> RxPortName -> IDR );
693
693
tmp_size = __HAL_UART_EMUL_FRAME_LENGTH (huart );
@@ -698,6 +698,16 @@ static void UART_Emul_ReceiveFrame(UART_Emul_HandleTypeDef *huart, uint32_t *pDa
698
698
/* Enable the transfer Error interrupt */
699
699
__HAL_DMA_ENABLE_IT (& hdma_rx , DMA_IT_TE );
700
700
701
+ #if defined (STM32F0xx ) || defined (STM32F3xx )
702
+ /* Configure DMA Stream data length */
703
+ hdma_rx .Instance -> CNDTR = tmp_size ;
704
+
705
+ /* Configure DMA Stream source address */
706
+ hdma_rx .Instance -> CPAR = tmp_sr ;
707
+
708
+ /* Configure DMA Stream destination address */
709
+ hdma_rx .Instance -> CMAR = tmp_ds ;
710
+ #else
701
711
/* Configure DMA Stream data length */
702
712
hdma_rx .Instance -> NDTR = tmp_size ;
703
713
@@ -706,7 +716,7 @@ static void UART_Emul_ReceiveFrame(UART_Emul_HandleTypeDef *huart, uint32_t *pDa
706
716
707
717
/* Configure DMA Stream destination address */
708
718
hdma_rx .Instance -> M0AR = tmp_ds ;
709
-
719
+ #endif
710
720
/* Enable the Peripheral */
711
721
__HAL_DMA_ENABLE (& hdma_rx );
712
722
@@ -795,18 +805,20 @@ static void UART_Emul_SetConfig_DMATx(void)
795
805
796
806
/*##-1- Configure DMA For UART Emulation TX #############################*/
797
807
/* Set the parameters to be configured */
798
- hdma_tx .Init .Channel = DMA_Channel_Tx ; /* Channel used */
799
808
hdma_tx .Init .Direction = DMA_MEMORY_TO_PERIPH ; /* Transfer mode */
800
809
hdma_tx .Init .PeriphInc = DMA_PINC_DISABLE ; /* Peripheral increment mode Disable */
801
810
hdma_tx .Init .MemInc = DMA_MINC_ENABLE ; /* Memory increment mode Enable */
802
811
hdma_tx .Init .PeriphDataAlignment = DMA_PDATAALIGN_WORD ; /* Peripheral data alignment : Word */
803
812
hdma_tx .Init .MemDataAlignment = DMA_MDATAALIGN_WORD ; /* memory data alignment : Word */
804
813
hdma_tx .Init .Mode = DMA_NORMAL ; /* Normal DMA mode */
805
814
hdma_tx .Init .Priority = DMA_PRIORITY_HIGH ; /* Priority level : High */
815
+ #ifdef STM32F4xx
816
+ hdma_tx .Init .Channel = DMA_Channel_Tx ; /* Channel used */
806
817
hdma_tx .Init .FIFOMode = DMA_FIFOMODE_DISABLE ; /* FIFO mode disable */
807
818
hdma_tx .Init .FIFOThreshold = DMA_FIFO_THRESHOLD_FULL ; /* FIFO threshold level */
808
819
hdma_tx .Init .MemBurst = DMA_MBURST_SINGLE ; /* Memory Burst transfer */
809
820
hdma_tx .Init .PeriphBurst = DMA_PBURST_SINGLE ; /* Periph Burst transfer */
821
+ #endif
810
822
811
823
/* Set hdma_tim instance */
812
824
hdma_tx .Instance = DMA_Stream_Tx ;
@@ -832,19 +844,20 @@ static void UART_Emul_SetConfig_DMARx(void)
832
844
{
833
845
/*##-1- Configure DMA For UART Emulation RX #############################*/
834
846
/* Set the parameters to be configured */
835
- hdma_rx .Init .Channel = DMA_Channel_Rx ; /* Channel used */
836
847
hdma_rx .Init .Direction = DMA_PERIPH_TO_MEMORY ; /* Transfer mode */
837
848
hdma_rx .Init .PeriphInc = DMA_PINC_DISABLE ; /* Peripheral increment mode Disable */
838
849
hdma_rx .Init .MemInc = DMA_MINC_ENABLE ; /* Memory increment mode Enable */
839
850
hdma_rx .Init .PeriphDataAlignment = DMA_PDATAALIGN_WORD ; /* Peripheral data alignment : Word */
840
851
hdma_rx .Init .MemDataAlignment = DMA_MDATAALIGN_WORD ; /* memory data alignment : Word */
841
852
hdma_rx .Init .Mode = DMA_NORMAL ; /* Normal DMA mode */
842
853
hdma_rx .Init .Priority = DMA_PRIORITY_VERY_HIGH ; /* Priority level : very High */
854
+ #if defined(STM32F4xx )
855
+ hdma_rx .Init .Channel = DMA_Channel_Rx ; /* Channel used */
843
856
hdma_rx .Init .FIFOMode = DMA_FIFOMODE_DISABLE ; /* FIFO mode disable */
844
857
hdma_rx .Init .FIFOThreshold = DMA_FIFO_THRESHOLD_FULL ; /* FIFO threshold level */
845
858
hdma_rx .Init .MemBurst = DMA_MBURST_SINGLE ; /* Memory Burst transfer */
846
859
hdma_rx .Init .PeriphBurst = DMA_PBURST_SINGLE ; /* Periph Burst transfer */
847
-
860
+ #endif
848
861
/* Set hdma_tim instance */
849
862
hdma_rx .Instance = DMA_Stream_Rx ;
850
863
@@ -1071,6 +1084,16 @@ static void UART_Emul_TransmitFrame(UART_Emul_HandleTypeDef *huart)
1071
1084
1072
1085
tmp_size = __HAL_UART_EMUL_FRAME_LENGTH (huart );
1073
1086
1087
+ #if defined (STM32F0xx ) || defined (STM32F3xx )
1088
+ /* Configure DMA Stream data length */
1089
+ hdma_rx .Instance -> CNDTR = tmp_size ;
1090
+
1091
+ /* Configure DMA Stream source address */
1092
+ hdma_rx .Instance -> CPAR = tmp_sr ;
1093
+
1094
+ /* Configure DMA Stream destination address */
1095
+ hdma_rx .Instance -> CMAR = tmp_ds ;
1096
+ #else
1074
1097
/* Configure DMA Stream data length */
1075
1098
hdma_tx .Instance -> NDTR = tmp_size ;
1076
1099
@@ -1079,6 +1102,7 @@ static void UART_Emul_TransmitFrame(UART_Emul_HandleTypeDef *huart)
1079
1102
1080
1103
/* Configure DMA Stream source address */
1081
1104
hdma_tx .Instance -> M0AR = tmp_sr ;
1105
+ #endif
1082
1106
1083
1107
/* Enable the transfer complete interrupt */
1084
1108
__HAL_DMA_ENABLE_IT (& hdma_tx , DMA_IT_TC );
@@ -1209,5 +1233,5 @@ __weak void HAL_UART_Emul_ErrorCallback(UART_Emul_HandleTypeDef *huart)
1209
1233
/**
1210
1234
* @}
1211
1235
*/
1212
-
1236
+ #endif //TIM1_BASE && UART_EMUL_RX && UART_EMUL_TX
1213
1237
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments