Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 6 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | (+++) Declare a DMA handle structure for the Tx/Rx channel. |
38 | (+++) Declare a DMA handle structure for the Tx/Rx channel. |
39 | (+++) Enable the DMAx interface clock. |
39 | (+++) Enable the DMAx interface clock. |
40 | (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. |
40 | (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. |
41 | (+++) Configure the DMA Tx/Rx channel. |
41 | (+++) Configure the DMA Tx/Rx channel. |
42 | (+++) Associate the initialized DMA handle to the IRDA DMA Tx/Rx handle. |
42 | (+++) Associate the initialized DMA handle to the IRDA DMA Tx/Rx handle. |
43 | (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel. |
43 | (+++) Configure the priority and enable the NVIC for the transfer |
- | 44 | complete interrupt on the DMA Tx/Rx channel. |
|
44 | 45 | ||
45 | (#) Program the Baud Rate, Word Length and Parity and Mode(Receiver/Transmitter), |
46 | (#) Program the Baud Rate, Word Length and Parity and Mode(Receiver/Transmitter), |
46 | the normal or low power mode and the clock prescaler in the hirda handle Init structure. |
47 | the normal or low power mode and the clock prescaler in the hirda handle Init structure. |
47 | 48 | ||
48 | (#) Initialize the IRDA registers by calling the HAL_IRDA_Init() API: |
49 | (#) Initialize the IRDA registers by calling the HAL_IRDA_Init() API: |
Line 111... | Line 112... | ||
111 | [..] |
112 | [..] |
112 | The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS when set to 1 |
113 | The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS when set to 1 |
113 | allows the user to configure dynamically the driver callbacks. |
114 | allows the user to configure dynamically the driver callbacks. |
114 | 115 | ||
115 | [..] |
116 | [..] |
116 | Use Function @ref HAL_IRDA_RegisterCallback() to register a user callback. |
117 | Use Function HAL_IRDA_RegisterCallback() to register a user callback. |
117 | Function @ref HAL_IRDA_RegisterCallback() allows to register following callbacks: |
118 | Function HAL_IRDA_RegisterCallback() allows to register following callbacks: |
118 | (+) TxHalfCpltCallback : Tx Half Complete Callback. |
119 | (+) TxHalfCpltCallback : Tx Half Complete Callback. |
119 | (+) TxCpltCallback : Tx Complete Callback. |
120 | (+) TxCpltCallback : Tx Complete Callback. |
120 | (+) RxHalfCpltCallback : Rx Half Complete Callback. |
121 | (+) RxHalfCpltCallback : Rx Half Complete Callback. |
121 | (+) RxCpltCallback : Rx Complete Callback. |
122 | (+) RxCpltCallback : Rx Complete Callback. |
122 | (+) ErrorCallback : Error Callback. |
123 | (+) ErrorCallback : Error Callback. |
Line 127... | Line 128... | ||
127 | (+) MspDeInitCallback : IRDA MspDeInit. |
128 | (+) MspDeInitCallback : IRDA MspDeInit. |
128 | This function takes as parameters the HAL peripheral handle, the Callback ID |
129 | This function takes as parameters the HAL peripheral handle, the Callback ID |
129 | and a pointer to the user callback function. |
130 | and a pointer to the user callback function. |
130 | 131 | ||
131 | [..] |
132 | [..] |
132 | Use function @ref HAL_IRDA_UnRegisterCallback() to reset a callback to the default |
133 | Use function HAL_IRDA_UnRegisterCallback() to reset a callback to the default |
133 | weak (surcharged) function. |
134 | weak (surcharged) function. |
134 | @ref HAL_IRDA_UnRegisterCallback() takes as parameters the HAL peripheral handle, |
135 | HAL_IRDA_UnRegisterCallback() takes as parameters the HAL peripheral handle, |
135 | and the Callback ID. |
136 | and the Callback ID. |
136 | This function allows to reset following callbacks: |
137 | This function allows to reset following callbacks: |
137 | (+) TxHalfCpltCallback : Tx Half Complete Callback. |
138 | (+) TxHalfCpltCallback : Tx Half Complete Callback. |
138 | (+) TxCpltCallback : Tx Complete Callback. |
139 | (+) TxCpltCallback : Tx Complete Callback. |
139 | (+) RxHalfCpltCallback : Rx Half Complete Callback. |
140 | (+) RxHalfCpltCallback : Rx Half Complete Callback. |
Line 144... | Line 145... | ||
144 | (+) AbortReceiveCpltCallback : Abort Receive Complete Callback. |
145 | (+) AbortReceiveCpltCallback : Abort Receive Complete Callback. |
145 | (+) MspInitCallback : IRDA MspInit. |
146 | (+) MspInitCallback : IRDA MspInit. |
146 | (+) MspDeInitCallback : IRDA MspDeInit. |
147 | (+) MspDeInitCallback : IRDA MspDeInit. |
147 | 148 | ||
148 | [..] |
149 | [..] |
149 | By default, after the @ref HAL_IRDA_Init() and when the state is HAL_IRDA_STATE_RESET |
150 | By default, after the HAL_IRDA_Init() and when the state is HAL_IRDA_STATE_RESET |
150 | all callbacks are set to the corresponding weak (surcharged) functions: |
151 | all callbacks are set to the corresponding weak (surcharged) functions: |
151 | examples @ref HAL_IRDA_TxCpltCallback(), @ref HAL_IRDA_RxHalfCpltCallback(). |
152 | examples HAL_IRDA_TxCpltCallback(), HAL_IRDA_RxHalfCpltCallback(). |
152 | Exception done for MspInit and MspDeInit functions that are respectively |
153 | Exception done for MspInit and MspDeInit functions that are respectively |
153 | reset to the legacy weak (surcharged) functions in the @ref HAL_IRDA_Init() |
154 | reset to the legacy weak (surcharged) functions in the HAL_IRDA_Init() |
154 | and @ref HAL_IRDA_DeInit() only when these callbacks are null (not registered beforehand). |
155 | and HAL_IRDA_DeInit() only when these callbacks are null (not registered beforehand). |
155 | If not, MspInit or MspDeInit are not null, the @ref HAL_IRDA_Init() and @ref HAL_IRDA_DeInit() |
156 | If not, MspInit or MspDeInit are not null, the HAL_IRDA_Init() and HAL_IRDA_DeInit() |
156 | keep and use the user MspInit/MspDeInit callbacks (registered beforehand). |
157 | keep and use the user MspInit/MspDeInit callbacks (registered beforehand). |
157 | 158 | ||
158 | [..] |
159 | [..] |
159 | Callbacks can be registered/unregistered in HAL_IRDA_STATE_READY state only. |
160 | Callbacks can be registered/unregistered in HAL_IRDA_STATE_READY state only. |
160 | Exception done MspInit/MspDeInit that can be registered/unregistered |
161 | Exception done MspInit/MspDeInit that can be registered/unregistered |
161 | in HAL_IRDA_STATE_READY or HAL_IRDA_STATE_RESET state, thus registered (user) |
162 | in HAL_IRDA_STATE_READY or HAL_IRDA_STATE_RESET state, thus registered (user) |
162 | MspInit/DeInit callbacks can be used during the Init/DeInit. |
163 | MspInit/DeInit callbacks can be used during the Init/DeInit. |
163 | In that case first register the MspInit/MspDeInit user callbacks |
164 | In that case first register the MspInit/MspDeInit user callbacks |
164 | using @ref HAL_IRDA_RegisterCallback() before calling @ref HAL_IRDA_DeInit() |
165 | using HAL_IRDA_RegisterCallback() before calling HAL_IRDA_DeInit() |
165 | or @ref HAL_IRDA_Init() function. |
166 | or HAL_IRDA_Init() function. |
166 | 167 | ||
167 | [..] |
168 | [..] |
168 | When The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS is set to 0 or |
169 | When The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS is set to 0 or |
169 | not defined, the callback registration feature is not available |
170 | not defined, the callback registration feature is not available |
170 | and weak (surcharged) callbacks are used. |
171 | and weak (surcharged) callbacks are used. |
Line 291... | Line 292... | ||
291 | (details for the procedures are available in reference manual). |
292 | (details for the procedures are available in reference manual). |
292 | 293 | ||
293 | @endverbatim |
294 | @endverbatim |
294 | 295 | ||
295 | Depending on the frame length defined either by the M bit (8-bits or 9-bits) |
296 | Depending on the frame length defined either by the M bit (8-bits or 9-bits) |
296 | or by the M1 and M0 bits (7-bit, 8-bit or 9-bit), the possible IRDA frame |
297 | or by the M1 and M0 bits (7-bit, 8-bit or 9-bit), the possible IRDA frame |
297 | formats are listed in the following table. |
298 | formats are listed in the following table. |
298 | 299 | ||
299 | Table 1. IRDA frame format. |
300 | Table 1. IRDA frame format. |
300 | +-----------------------------------------------------------------------+ |
301 | +-----------------------------------------------------------------------+ |
301 | | M bit | PCE bit | IRDA frame | |
302 | | M bit | PCE bit | IRDA frame | |
Line 619... | Line 620... | ||
619 | if (HAL_IRDA_STATE_READY == hirda->gState) |
620 | if (HAL_IRDA_STATE_READY == hirda->gState) |
620 | { |
621 | { |
621 | switch (CallbackID) |
622 | switch (CallbackID) |
622 | { |
623 | { |
623 | case HAL_IRDA_TX_HALFCOMPLETE_CB_ID : |
624 | case HAL_IRDA_TX_HALFCOMPLETE_CB_ID : |
624 | hirda->TxHalfCpltCallback = HAL_IRDA_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */ |
625 | hirda->TxHalfCpltCallback = HAL_IRDA_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */ |
625 | break; |
626 | break; |
626 | 627 | ||
627 | case HAL_IRDA_TX_COMPLETE_CB_ID : |
628 | case HAL_IRDA_TX_COMPLETE_CB_ID : |
628 | hirda->TxCpltCallback = HAL_IRDA_TxCpltCallback; /* Legacy weak TxCpltCallback */ |
629 | hirda->TxCpltCallback = HAL_IRDA_TxCpltCallback; /* Legacy weak TxCpltCallback */ |
629 | break; |
630 | break; |
630 | 631 | ||
631 | case HAL_IRDA_RX_HALFCOMPLETE_CB_ID : |
632 | case HAL_IRDA_RX_HALFCOMPLETE_CB_ID : |
632 | hirda->RxHalfCpltCallback = HAL_IRDA_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */ |
633 | hirda->RxHalfCpltCallback = HAL_IRDA_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */ |
633 | break; |
634 | break; |
634 | 635 | ||
635 | case HAL_IRDA_RX_COMPLETE_CB_ID : |
636 | case HAL_IRDA_RX_COMPLETE_CB_ID : |
636 | hirda->RxCpltCallback = HAL_IRDA_RxCpltCallback; /* Legacy weak RxCpltCallback */ |
637 | hirda->RxCpltCallback = HAL_IRDA_RxCpltCallback; /* Legacy weak RxCpltCallback */ |
637 | break; |
638 | break; |
638 | 639 | ||
639 | case HAL_IRDA_ERROR_CB_ID : |
640 | case HAL_IRDA_ERROR_CB_ID : |
640 | hirda->ErrorCallback = HAL_IRDA_ErrorCallback; /* Legacy weak ErrorCallback */ |
641 | hirda->ErrorCallback = HAL_IRDA_ErrorCallback; /* Legacy weak ErrorCallback */ |
641 | break; |
642 | break; |
642 | 643 | ||
643 | case HAL_IRDA_ABORT_COMPLETE_CB_ID : |
644 | case HAL_IRDA_ABORT_COMPLETE_CB_ID : |
644 | hirda->AbortCpltCallback = HAL_IRDA_AbortCpltCallback; /* Legacy weak AbortCpltCallback */ |
645 | hirda->AbortCpltCallback = HAL_IRDA_AbortCpltCallback; /* Legacy weak AbortCpltCallback */ |
645 | break; |
646 | break; |
646 | 647 | ||
647 | case HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID : |
648 | case HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID : |
648 | hirda->AbortTransmitCpltCallback = HAL_IRDA_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */ |
649 | hirda->AbortTransmitCpltCallback = HAL_IRDA_AbortTransmitCpltCallback; /* Legacy weak |
- | 650 | AbortTransmitCpltCallback */ |
|
649 | break; |
651 | break; |
650 | 652 | ||
651 | case HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID : |
653 | case HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID : |
652 | hirda->AbortReceiveCpltCallback = HAL_IRDA_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */ |
654 | hirda->AbortReceiveCpltCallback = HAL_IRDA_AbortReceiveCpltCallback; /* Legacy weak |
- | 655 | AbortReceiveCpltCallback */ |
|
653 | break; |
656 | break; |
654 | 657 | ||
655 | case HAL_IRDA_MSPINIT_CB_ID : |
658 | case HAL_IRDA_MSPINIT_CB_ID : |
656 | hirda->MspInitCallback = HAL_IRDA_MspInit; /* Legacy weak MspInitCallback */ |
659 | hirda->MspInitCallback = HAL_IRDA_MspInit; /* Legacy weak MspInitCallback */ |
657 | break; |
660 | break; |
658 | 661 | ||
659 | case HAL_IRDA_MSPDEINIT_CB_ID : |
662 | case HAL_IRDA_MSPDEINIT_CB_ID : |
660 | hirda->MspDeInitCallback = HAL_IRDA_MspDeInit; /* Legacy weak MspDeInitCallback */ |
663 | hirda->MspDeInitCallback = HAL_IRDA_MspDeInit; /* Legacy weak MspDeInitCallback */ |
661 | break; |
664 | break; |
662 | 665 | ||
663 | default : |
666 | default : |
664 | /* Update the error code */ |
667 | /* Update the error code */ |
665 | hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK; |
668 | hirda->ErrorCode |= HAL_IRDA_ERROR_INVALID_CALLBACK; |
Line 778... | Line 781... | ||
778 | (++) HAL_IRDA_AbortReceiveCpltCallback() |
781 | (++) HAL_IRDA_AbortReceiveCpltCallback() |
779 | 782 | ||
780 | (#) In Non-Blocking mode transfers, possible errors are split into 2 categories. |
783 | (#) In Non-Blocking mode transfers, possible errors are split into 2 categories. |
781 | Errors are handled as follows : |
784 | Errors are handled as follows : |
782 | (++) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is |
785 | (++) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is |
783 | to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error in Interrupt mode reception . |
786 | to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error |
- | 787 | in Interrupt mode reception . |
|
784 | Received character is then retrieved and stored in Rx buffer, Error code is set to allow user to identify error type, |
788 | Received character is then retrieved and stored in Rx buffer, Error code is set to allow user |
785 | and HAL_IRDA_ErrorCallback() user callback is executed. Transfer is kept ongoing on IRDA side. |
789 | to identify error type, and HAL_IRDA_ErrorCallback() user callback is executed. |
- | 790 | Transfer is kept ongoing on IRDA side. |
|
786 | If user wants to abort it, Abort services should be called by user. |
791 | If user wants to abort it, Abort services should be called by user. |
787 | (++) Error is considered as Blocking : Transfer could not be completed properly and is aborted. |
792 | (++) Error is considered as Blocking : Transfer could not be completed properly and is aborted. |
788 | This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode. |
793 | This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode. |
789 | Error code is set to allow user to identify error type, and HAL_IRDA_ErrorCallback() user callback is executed. |
794 | Error code is set to allow user to identify error type, and |
- | 795 | HAL_IRDA_ErrorCallback() user callback is executed. |
|
790 | 796 | ||
791 | @endverbatim |
797 | @endverbatim |
792 | * @{ |
798 | * @{ |
793 | */ |
799 | */ |
794 | 800 | ||
Line 822... | Line 828... | ||
822 | if ((pData == NULL) || (Size == 0U)) |
828 | if ((pData == NULL) || (Size == 0U)) |
823 | { |
829 | { |
824 | return HAL_ERROR; |
830 | return HAL_ERROR; |
825 | } |
831 | } |
826 | 832 | ||
827 | /* In case of 9bits/No Parity transfer, pData buffer provided as input paramter |
833 | /* In case of 9bits/No Parity transfer, pData buffer provided as input parameter |
828 | should be aligned on a u16 frontier, as data to be filled into TDR will be |
834 | should be aligned on a u16 frontier, as data to be filled into TDR will be |
829 | handled through a u16 cast. */ |
835 | handled through a u16 cast. */ |
830 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
836 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
831 | { |
837 | { |
832 | if ((((uint32_t)pData) & 1U) != 0U) |
838 | if ((((uint32_t)pData) & 1U) != 0U) |
Line 839... | Line 845... | ||
839 | __HAL_LOCK(hirda); |
845 | __HAL_LOCK(hirda); |
840 | 846 | ||
841 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
847 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
842 | hirda->gState = HAL_IRDA_STATE_BUSY_TX; |
848 | hirda->gState = HAL_IRDA_STATE_BUSY_TX; |
843 | 849 | ||
844 | /* Init tickstart for timeout managment*/ |
850 | /* Init tickstart for timeout management */ |
845 | tickstart = HAL_GetTick(); |
851 | tickstart = HAL_GetTick(); |
846 | 852 | ||
847 | hirda->TxXferSize = Size; |
853 | hirda->TxXferSize = Size; |
848 | hirda->TxXferCount = Size; |
854 | hirda->TxXferCount = Size; |
849 | 855 | ||
Line 929... | Line 935... | ||
929 | if ((pData == NULL) || (Size == 0U)) |
935 | if ((pData == NULL) || (Size == 0U)) |
930 | { |
936 | { |
931 | return HAL_ERROR; |
937 | return HAL_ERROR; |
932 | } |
938 | } |
933 | 939 | ||
934 | /* In case of 9bits/No Parity transfer, pData buffer provided as input paramter |
940 | /* In case of 9bits/No Parity transfer, pData buffer provided as input parameter |
935 | should be aligned on a u16 frontier, as data to be received from RDR will be |
941 | should be aligned on a u16 frontier, as data to be received from RDR will be |
936 | handled through a u16 cast. */ |
942 | handled through a u16 cast. */ |
937 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
943 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
938 | { |
944 | { |
939 | if ((((uint32_t)pData) & 1U) != 0U) |
945 | if ((((uint32_t)pData) & 1U) != 0U) |
Line 946... | Line 952... | ||
946 | __HAL_LOCK(hirda); |
952 | __HAL_LOCK(hirda); |
947 | 953 | ||
948 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
954 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
949 | hirda->RxState = HAL_IRDA_STATE_BUSY_RX; |
955 | hirda->RxState = HAL_IRDA_STATE_BUSY_RX; |
950 | 956 | ||
951 | /* Init tickstart for timeout managment*/ |
957 | /* Init tickstart for timeout management */ |
952 | tickstart = HAL_GetTick(); |
958 | tickstart = HAL_GetTick(); |
953 | 959 | ||
954 | hirda->RxXferSize = Size; |
960 | hirda->RxXferSize = Size; |
955 | hirda->RxXferCount = Size; |
961 | hirda->RxXferCount = Size; |
956 | 962 | ||
Line 1031... | Line 1037... | ||
1031 | if ((pData == NULL) || (Size == 0U)) |
1037 | if ((pData == NULL) || (Size == 0U)) |
1032 | { |
1038 | { |
1033 | return HAL_ERROR; |
1039 | return HAL_ERROR; |
1034 | } |
1040 | } |
1035 | 1041 | ||
1036 | /* In case of 9bits/No Parity transfer, pData buffer provided as input paramter |
1042 | /* In case of 9bits/No Parity transfer, pData buffer provided as input parameter |
1037 | should be aligned on a u16 frontier, as data to be filled into TDR will be |
1043 | should be aligned on a u16 frontier, as data to be filled into TDR will be |
1038 | handled through a u16 cast. */ |
1044 | handled through a u16 cast. */ |
1039 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1045 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1040 | { |
1046 | { |
1041 | if ((((uint32_t)pData) & 1U) != 0U) |
1047 | if ((((uint32_t)pData) & 1U) != 0U) |
Line 1093... | Line 1099... | ||
1093 | if ((pData == NULL) || (Size == 0U)) |
1099 | if ((pData == NULL) || (Size == 0U)) |
1094 | { |
1100 | { |
1095 | return HAL_ERROR; |
1101 | return HAL_ERROR; |
1096 | } |
1102 | } |
1097 | 1103 | ||
1098 | /* In case of 9bits/No Parity transfer, pData buffer provided as input paramter |
1104 | /* In case of 9bits/No Parity transfer, pData buffer provided as input parameter |
1099 | should be aligned on a u16 frontier, as data to be received from RDR will be |
1105 | should be aligned on a u16 frontier, as data to be received from RDR will be |
1100 | handled through a u16 cast. */ |
1106 | handled through a u16 cast. */ |
1101 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1107 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1102 | { |
1108 | { |
1103 | if ((((uint32_t)pData) & 1U) != 0U) |
1109 | if ((((uint32_t)pData) & 1U) != 0U) |
Line 1162... | Line 1168... | ||
1162 | if ((pData == NULL) || (Size == 0U)) |
1168 | if ((pData == NULL) || (Size == 0U)) |
1163 | { |
1169 | { |
1164 | return HAL_ERROR; |
1170 | return HAL_ERROR; |
1165 | } |
1171 | } |
1166 | 1172 | ||
1167 | /* In case of 9bits/No Parity transfer, pData buffer provided as input paramter |
1173 | /* In case of 9bits/No Parity transfer, pData buffer provided as input parameter |
1168 | should be aligned on a u16 frontier, as data copy into TDR will be |
1174 | should be aligned on a u16 frontier, as data copy into TDR will be |
1169 | handled by DMA from a u16 frontier. */ |
1175 | handled by DMA from a u16 frontier. */ |
1170 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1176 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1171 | { |
1177 | { |
1172 | if ((((uint32_t)pData) & 1U) != 0U) |
1178 | if ((((uint32_t)pData) & 1U) != 0U) |
Line 1259... | Line 1265... | ||
1259 | if ((pData == NULL) || (Size == 0U)) |
1265 | if ((pData == NULL) || (Size == 0U)) |
1260 | { |
1266 | { |
1261 | return HAL_ERROR; |
1267 | return HAL_ERROR; |
1262 | } |
1268 | } |
1263 | 1269 | ||
1264 | /* In case of 9bits/No Parity transfer, pData buffer provided as input paramter |
1270 | /* In case of 9bits/No Parity transfer, pData buffer provided as input parameter |
1265 | should be aligned on a u16 frontier, as data copy from RDR will be |
1271 | should be aligned on a u16 frontier, as data copy from RDR will be |
1266 | handled by DMA from a u16 frontier. */ |
1272 | handled by DMA from a u16 frontier. */ |
1267 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1273 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
1268 | { |
1274 | { |
1269 | if ((((uint32_t)pData) & 1U) != 0U) |
1275 | if ((((uint32_t)pData) & 1U) != 0U) |
Line 1389... | Line 1395... | ||
1389 | if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX) |
1395 | if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX) |
1390 | { |
1396 | { |
1391 | /* Clear the Overrun flag before resuming the Rx transfer*/ |
1397 | /* Clear the Overrun flag before resuming the Rx transfer*/ |
1392 | __HAL_IRDA_CLEAR_OREFLAG(hirda); |
1398 | __HAL_IRDA_CLEAR_OREFLAG(hirda); |
1393 | 1399 | ||
1394 | /* Reenable PE and ERR (Frame error, noise error, overrun error) interrupts */ |
1400 | /* Re-enable PE and ERR (Frame error, noise error, overrun error) interrupts */ |
1395 | SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE); |
1401 | SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE); |
1396 | SET_BIT(hirda->Instance->CR3, USART_CR3_EIE); |
1402 | SET_BIT(hirda->Instance->CR3, USART_CR3_EIE); |
1397 | 1403 | ||
1398 | /* Enable the IRDA DMA Rx request */ |
1404 | /* Enable the IRDA DMA Rx request */ |
1399 | SET_BIT(hirda->Instance->CR3, USART_CR3_DMAR); |
1405 | SET_BIT(hirda->Instance->CR3, USART_CR3_DMAR); |
Line 2421... | Line 2427... | ||
2421 | uint32_t tickstart; |
2427 | uint32_t tickstart; |
2422 | 2428 | ||
2423 | /* Initialize the IRDA ErrorCode */ |
2429 | /* Initialize the IRDA ErrorCode */ |
2424 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
2430 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
2425 | 2431 | ||
2426 | /* Init tickstart for timeout managment*/ |
2432 | /* Init tickstart for timeout management */ |
2427 | tickstart = HAL_GetTick(); |
2433 | tickstart = HAL_GetTick(); |
2428 | 2434 | ||
2429 | /* Check if the Transmitter is enabled */ |
2435 | /* Check if the Transmitter is enabled */ |
2430 | if ((hirda->Instance->CR1 & USART_CR1_TE) == USART_CR1_TE) |
2436 | if ((hirda->Instance->CR1 & USART_CR1_TE) == USART_CR1_TE) |
2431 | { |
2437 | { |
Line 2476... | Line 2482... | ||
2476 | /* Check for the Timeout */ |
2482 | /* Check for the Timeout */ |
2477 | if (Timeout != HAL_MAX_DELAY) |
2483 | if (Timeout != HAL_MAX_DELAY) |
2478 | { |
2484 | { |
2479 | if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) |
2485 | if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) |
2480 | { |
2486 | { |
2481 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
2487 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) |
- | 2488 | interrupts for the interrupt process */ |
|
2482 | CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE)); |
2489 | CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE)); |
2483 | CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE); |
2490 | CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE); |
2484 | 2491 | ||
2485 | hirda->gState = HAL_IRDA_STATE_READY; |
2492 | hirda->gState = HAL_IRDA_STATE_READY; |
2486 | hirda->RxState = HAL_IRDA_STATE_READY; |
2493 | hirda->RxState = HAL_IRDA_STATE_READY; |