summaryrefslogtreecommitdiff
path: root/bsps/arm/stm32h7/include/stm32h7xx_ll_swpmi.h
blob: 0a73bc530119f28ccd60007d849c8abc8b7e36c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
/**
  ******************************************************************************
  * @file    stm32h7xx_ll_swpmi.h
  * @author  MCD Application Team
  * @brief   Header file of SWPMI LL module.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32H7xx_LL_SWPMI_H
#define STM32H7xx_LL_SWPMI_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx.h"

/** @addtogroup STM32H7xx_LL_Driver
  * @{
  */


/** @defgroup SWPMI_LL SWPMI
  * @{
  */

/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
#if defined(USE_FULL_LL_DRIVER)
/** @defgroup SWPMI_LL_Private_Macros SWPMI Private Macros
  * @{
  */
/**
  * @}
  */
#endif /*USE_FULL_LL_DRIVER*/

/* Exported types ------------------------------------------------------------*/
#if defined(USE_FULL_LL_DRIVER)
/** @defgroup SWPMI_LL_ES_INIT SWPMI Exported Init structure
  * @{
  */

/**
  * @brief  SWPMI Init structures definition
  */
typedef struct
{
  uint32_t VoltageClass;           /*!< Specifies the SWP Voltage Class.
                                        This parameter can be a value of @ref SWPMI_LL_EC_VOLTAGE_CLASS

                                        This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetVoltageClass. */

  uint32_t BitRatePrescaler;       /*!< Specifies the SWPMI bitrate prescaler.
                                        This parameter must be a number between Min_Data=0 and Max_Data=255U.

                                        The value can be calculated thanks to helper macro @ref __LL_SWPMI_CALC_BITRATE_PRESCALER

                                        This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetBitRatePrescaler. */

  uint32_t TxBufferingMode;        /*!< Specifies the transmission buffering mode.
                                        This parameter can be a value of @ref SWPMI_LL_EC_SW_BUFFER_TX

                                        This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetTransmissionMode. */

  uint32_t RxBufferingMode;        /*!< Specifies the reception buffering mode.
                                        This parameter can be a value of @ref SWPMI_LL_EC_SW_BUFFER_RX

                                        This feature can be modified afterwards using unitary function @ref LL_SWPMI_SetReceptionMode. */
} LL_SWPMI_InitTypeDef;

/**
  * @}
  */
#endif /* USE_FULL_LL_DRIVER */

/* Exported constants --------------------------------------------------------*/
/** @defgroup SWPMI_LL_Exported_Constants SWPMI Exported Constants
  * @{
  */

/** @defgroup SWPMI_LL_EC_CLEAR_FLAG Clear Flags Defines
  * @brief    Flags defines which can be used with LL_SWPMI_WriteReg function
  * @{
  */
#define LL_SWPMI_ICR_CRXBFF                SWPMI_ICR_CRXBFF  /*!< Clear receive buffer full flag     */
#define LL_SWPMI_ICR_CTXBEF                SWPMI_ICR_CTXBEF  /*!< Clear transmit buffer empty flag   */
#define LL_SWPMI_ICR_CRXBERF               SWPMI_ICR_CRXBERF /*!< Clear receive CRC error flag       */
#define LL_SWPMI_ICR_CRXOVRF               SWPMI_ICR_CRXOVRF /*!< Clear receive overrun error flag   */
#define LL_SWPMI_ICR_CTXUNRF               SWPMI_ICR_CTXUNRF /*!< Clear transmit underrun error flag */
#define LL_SWPMI_ICR_CTCF                  SWPMI_ICR_CTCF    /*!< Clear transfer complete flag       */
#define LL_SWPMI_ICR_CSRF                  SWPMI_ICR_CSRF    /*!< Clear slave resume flag            */
/**
  * @}
  */

/** @defgroup SWPMI_LL_EC_GET_FLAG Get Flags Defines
  * @brief    Flags defines which can be used with LL_SWPMI_ReadReg function
  * @{
  */
#define LL_SWPMI_ISR_RXBFF                 SWPMI_ISR_RXBFF   /*!< Receive buffer full flag           */
#define LL_SWPMI_ISR_TXBEF                 SWPMI_ISR_TXBEF   /*!< Transmit buffer empty flag         */
#define LL_SWPMI_ISR_RXBERF                SWPMI_ISR_RXBERF  /*!< Receive CRC error flag             */
#define LL_SWPMI_ISR_RXOVRF                SWPMI_ISR_RXOVRF  /*!< Receive overrun error flag         */
#define LL_SWPMI_ISR_TXUNRF                SWPMI_ISR_TXUNRF  /*!< Transmit underrun error flag       */
#define LL_SWPMI_ISR_RXNE                  SWPMI_ISR_RXNE    /*!< Receive data register not empty    */
#define LL_SWPMI_ISR_TXE                   SWPMI_ISR_TXE     /*!< Transmit data register empty       */
#define LL_SWPMI_ISR_TCF                   SWPMI_ISR_TCF     /*!< Transfer complete flag             */
#define LL_SWPMI_ISR_SRF                   SWPMI_ISR_SRF     /*!< Slave resume flag                  */
#define LL_SWPMI_ISR_SUSP                  SWPMI_ISR_SUSP    /*!< SUSPEND flag                       */
#define LL_SWPMI_ISR_DEACTF                SWPMI_ISR_DEACTF  /*!< DEACTIVATED flag                   */
/**
  * @}
  */

/** @defgroup SWPMI_LL_EC_IT IT Defines
  * @brief    IT defines which can be used with LL_SWPMI_ReadReg and  LL_SWPMI_WriteReg functions
  * @{
  */
#define LL_SWPMI_IER_SRIE                  SWPMI_IER_SRIE    /*!< Slave resume interrupt enable            */
#define LL_SWPMI_IER_TCIE                  SWPMI_IER_TCIE    /*!< Transmit complete interrupt enable       */
#define LL_SWPMI_IER_TIE                   SWPMI_IER_TIE     /*!< Transmit interrupt enable                */
#define LL_SWPMI_IER_RIE                   SWPMI_IER_RIE     /*!< Receive interrupt enable                 */
#define LL_SWPMI_IER_TXUNRIE               SWPMI_IER_TXUNRIE /*!< Transmit underrun error interrupt enable */
#define LL_SWPMI_IER_RXOVRIE               SWPMI_IER_RXOVRIE /*!< Receive overrun error interrupt enable   */
#define LL_SWPMI_IER_RXBERIE               SWPMI_IER_RXBERIE /*!< Receive CRC error interrupt enable       */
#define LL_SWPMI_IER_TXBEIE                SWPMI_IER_TXBEIE  /*!< Transmit buffer empty interrupt enable   */
#define LL_SWPMI_IER_RXBFIE                SWPMI_IER_RXBFIE  /*!< Receive buffer full interrupt enable     */
/**
  * @}
  */

/** @defgroup SWPMI_LL_EC_SW_BUFFER_RX SW BUFFER RX
  * @{
  */
#define LL_SWPMI_SW_BUFFER_RX_SINGLE ((uint32_t)0x00000000)  /*!< Single software buffer mode for reception */
#define LL_SWPMI_SW_BUFFER_RX_MULTI  SWPMI_CR_RXMODE         /*!< Multi software buffermode for reception   */
/**
  * @}
  */

/** @defgroup SWPMI_LL_EC_SW_BUFFER_TX SW BUFFER TX
  * @{
  */
#define LL_SWPMI_SW_BUFFER_TX_SINGLE ((uint32_t)0x00000000)  /*!< Single software buffer mode for transmission */
#define LL_SWPMI_SW_BUFFER_TX_MULTI  SWPMI_CR_TXMODE         /*!< Multi software buffermode for transmission   */
/**
  * @}
  */

/** @defgroup SWPMI_LL_EC_VOLTAGE_CLASS VOLTAGE CLASS
  * @{
  */
#define LL_SWPMI_VOLTAGE_CLASS_C     ((uint32_t)0x00000000)  /*!< SWPMI_IO uses directly VDD voltage to operate in class C          */
#define LL_SWPMI_VOLTAGE_CLASS_B     SWPMI_OR_CLASS          /*!< SWPMI_IO uses an internal voltage regulator to operate in class B */
/**
  * @}
  */

/** @defgroup SWPMI_LL_EC_DMA_REG_DATA DMA register data
  * @{
  */
#define LL_SWPMI_DMA_REG_DATA_TRANSMIT     (uint32_t)0       /*!< Get address of data register used for transmission */
#define LL_SWPMI_DMA_REG_DATA_RECEIVE      (uint32_t)1       /*!< Get address of data register used for reception    */
/**
  * @}
  */

/**
  * @}
  */

/* Exported macro ------------------------------------------------------------*/
/** @defgroup SWPMI_LL_Exported_Macros SWPMI Exported Macros
  * @{
  */

/** @defgroup SWPMI_LL_EM_WRITE_READ Common Write and read registers Macros
  * @{
  */

/**
  * @brief  Write a value in SWPMI register
  * @param  __INSTANCE__ SWPMI Instance
  * @param  __REG__ Register to be written
  * @param  __VALUE__ Value to be written in the register
  * @retval None
  */
#define LL_SWPMI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))

/**
  * @brief  Read a value in SWPMI register
  * @param  __INSTANCE__ SWPMI Instance
  * @param  __REG__ Register to be read
  * @retval Register value
  */
#define LL_SWPMI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
/**
  * @}
  */

/** @defgroup SWPMI_LL_EM_BitRate Bit rate calculation helper Macros
  * @{
  */

/**
  * @brief  Helper macro to calculate bit rate value to set in BRR register (@ref LL_SWPMI_SetBitRatePrescaler function)
  * @note ex: @ref __LL_SWPMI_CALC_BITRATE_PRESCALER(2000000, 80000000);
  * @param  __FSWP__ Within the following range: from 100 Kbit/s up to 2Mbit/s (in bit/s)
  * @param  __FSWPCLK__ PCLK or HSI frequency (in Hz)
  * @retval Bitrate prescaler (BRR register)
  */
#define __LL_SWPMI_CALC_BITRATE_PRESCALER(__FSWP__, __FSWPCLK__)   ((uint32_t)(((__FSWPCLK__) / ((__FSWP__) * 4)) - 1))

/**
  * @}
  */

/**
  * @}
  */

/* Exported functions --------------------------------------------------------*/
/** @defgroup SWPMI_LL_Exported_Functions SWPMI Exported Functions
  * @{
  */

/** @defgroup SWPMI_LL_EF_Configuration Configuration
  * @{
  */

/**
  * @brief  Set Reception buffering mode
  * @note   If Multi software buffer mode is chosen, RXDMA bits must also be set.
  * @rmtoll CR           RXMODE        LL_SWPMI_SetReceptionMode
  * @param  SWPMIx SWPMI Instance
  * @param  RxBufferingMode This parameter can be one of the following values:
  *         @arg @ref LL_SWPMI_SW_BUFFER_RX_SINGLE
  *         @arg @ref LL_SWPMI_SW_BUFFER_RX_MULTI
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_SetReceptionMode(SWPMI_TypeDef *SWPMIx, uint32_t RxBufferingMode)
{
  MODIFY_REG(SWPMIx->CR, SWPMI_CR_RXMODE, RxBufferingMode);
}

/**
  * @brief  Get Reception buffering mode
  * @rmtoll CR           RXMODE        LL_SWPMI_GetReceptionMode
  * @param  SWPMIx SWPMI Instance
  * @retval Returned value can be one of the following values:
  *         @arg @ref LL_SWPMI_SW_BUFFER_RX_SINGLE
  *         @arg @ref LL_SWPMI_SW_BUFFER_RX_MULTI
  */
__STATIC_INLINE uint32_t LL_SWPMI_GetReceptionMode(SWPMI_TypeDef *SWPMIx)
{
  return (uint32_t)(READ_BIT(SWPMIx->CR, SWPMI_CR_RXMODE));
}

/**
  * @brief  Set Transmission buffering mode
  * @note   If Multi software buffer mode is chosen, TXDMA bits must also be set.
  * @rmtoll CR           TXMODE        LL_SWPMI_SetTransmissionMode
  * @param  SWPMIx SWPMI Instance
  * @param  TxBufferingMode This parameter can be one of the following values:
  *         @arg @ref LL_SWPMI_SW_BUFFER_TX_SINGLE
  *         @arg @ref LL_SWPMI_SW_BUFFER_TX_MULTI
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_SetTransmissionMode(SWPMI_TypeDef *SWPMIx, uint32_t TxBufferingMode)
{
  MODIFY_REG(SWPMIx->CR, SWPMI_CR_TXMODE, TxBufferingMode);
}

/**
  * @brief  Get Transmission buffering mode
  * @rmtoll CR           TXMODE        LL_SWPMI_GetTransmissionMode
  * @param  SWPMIx SWPMI Instance
  * @retval Returned value can be one of the following values:
  *         @arg @ref LL_SWPMI_SW_BUFFER_TX_SINGLE
  *         @arg @ref LL_SWPMI_SW_BUFFER_TX_MULTI
  */
__STATIC_INLINE uint32_t LL_SWPMI_GetTransmissionMode(SWPMI_TypeDef *SWPMIx)
{
  return (uint32_t)(READ_BIT(SWPMIx->CR, SWPMI_CR_TXMODE));
}

/**
  * @brief  Enable loopback mode
  * @rmtoll CR           LPBK          LL_SWPMI_EnableLoopback
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableLoopback(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->CR, SWPMI_CR_LPBK);
}

/**
  * @brief  Disable loopback mode
  * @rmtoll CR           LPBK          LL_SWPMI_DisableLoopback
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableLoopback(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->CR, SWPMI_CR_LPBK);
}

/**
  * @brief  Enable SWPMI transceiver
  * @note   SWPMI_IO pin is controlled by SWPMI
  * @rmtoll CR           SWPEN          LL_SWPMI_EnableTransceiver
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableTransceiver(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->CR, SWPMI_CR_SWPEN);
}

/**
  * @brief  Disable SWPMI transceiver
  * @note   SWPMI_IO pin is controlled by GPIO controller
  * @rmtoll CR           SWPEN          LL_SWPMI_DisableTransceiver
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableTransceiver(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->CR, SWPMI_CR_SWPEN);
}

/**
  * @brief  Check if SWPMI transceiver is enabled
  * @rmtoll CR           SWPEN         LL_SWPMI_IsEnabledTransceiver
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledTransceiver(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->CR, SWPMI_CR_SWPEN) == (SWPMI_CR_SWPEN)) ? 1UL : 0UL);
}

/**
  * @brief  Activate Single wire protocol bus (SUSPENDED or ACTIVATED state)
  * @note   SWP bus stays in the ACTIVATED state as long as there is a communication
  *         with the slave, either in transmission or in reception. The SWP bus switches back
  *         to the SUSPENDED state as soon as there is no more transmission or reception
  *         activity, after 7 idle bits.
  * @rmtoll CR           SWPACT        LL_SWPMI_Activate
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_Activate(SWPMI_TypeDef *SWPMIx)
{
  /* In order to activate SWP again, the software must clear DEACT bit*/
  CLEAR_BIT(SWPMIx->CR, SWPMI_CR_DEACT);

  /* Set SWACT bit */
  SET_BIT(SWPMIx->CR, SWPMI_CR_SWPACT);
}

/**
  * @brief  Check if Single wire protocol bus is in ACTIVATED state.
  * @rmtoll CR           SWPACT        LL_SWPMI_Activate
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActivated(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->CR, SWPMI_CR_SWPACT) == (SWPMI_CR_SWPACT)) ? 1UL : 0UL);
}

/**
  * @brief  Deactivate immediately Single wire protocol bus (immediate transition to
  *         DEACTIVATED state)
  * @rmtoll CR           SWPACT        LL_SWPMI_Deactivate
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_Deactivate(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->CR, SWPMI_CR_SWPACT);
}

/**
  * @brief  Request a deactivation of Single wire protocol bus (request to go in DEACTIVATED
  *         state if no resume from slave)
  * @rmtoll CR           DEACT         LL_SWPMI_RequestDeactivation
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_RequestDeactivation(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->CR, SWPMI_CR_DEACT);
}

/**
  * @brief  Set Bitrate prescaler SWPMI_freq = SWPMI_clk / (((BitRate) + 1)  * 4)
  * @rmtoll BRR          BR            LL_SWPMI_SetBitRatePrescaler
  * @param  SWPMIx SWPMI Instance
  * @param  BitRatePrescaler A number between Min_Data=0 and Max_Data=255U
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_SetBitRatePrescaler(SWPMI_TypeDef *SWPMIx, uint32_t BitRatePrescaler)
{
  WRITE_REG(SWPMIx->BRR, BitRatePrescaler);
}

/**
  * @brief  Get Bitrate prescaler
  * @rmtoll BRR          BR            LL_SWPMI_GetBitRatePrescaler
  * @param  SWPMIx SWPMI Instance
  * @retval A number between Min_Data=0 and Max_Data=255U
  */
__STATIC_INLINE uint32_t LL_SWPMI_GetBitRatePrescaler(SWPMI_TypeDef *SWPMIx)
{
  return (uint32_t)(READ_BIT(SWPMIx->BRR, SWPMI_BRR_BR));
}

/**
  * @brief  Set SWP Voltage Class
  * @rmtoll OR           CLASS         LL_SWPMI_SetVoltageClass
  * @param  SWPMIx SWPMI Instance
  * @param  VoltageClass This parameter can be one of the following values:
  *         @arg @ref LL_SWPMI_VOLTAGE_CLASS_C
  *         @arg @ref LL_SWPMI_VOLTAGE_CLASS_B
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_SetVoltageClass(SWPMI_TypeDef *SWPMIx, uint32_t VoltageClass)
{
  MODIFY_REG(SWPMIx->OR, SWPMI_OR_CLASS, VoltageClass);
}

/**
  * @brief  Get SWP Voltage Class
  * @rmtoll OR           CLASS         LL_SWPMI_GetVoltageClass
  * @param  SWPMIx SWPMI Instance
  * @retval Returned value can be one of the following values:
  *         @arg @ref LL_SWPMI_VOLTAGE_CLASS_C
  *         @arg @ref LL_SWPMI_VOLTAGE_CLASS_B
  */
__STATIC_INLINE uint32_t LL_SWPMI_GetVoltageClass(SWPMI_TypeDef *SWPMIx)
{
  return (uint32_t)(READ_BIT(SWPMIx->OR, SWPMI_OR_CLASS));
}

/**
  * @}
  */

/** @defgroup SWPMI_LL_EF_FLAG_Management FLAG_Management
  * @{
  */

/**
  * @brief  Check if the last word of the frame under reception has arrived in SWPMI_RDR.
  * @rmtoll ISR          RXBFF         LL_SWPMI_IsActiveFlag_RXBF
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXBF(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXBFF) == (SWPMI_ISR_RXBFF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Frame transmission buffer has been emptied
  * @rmtoll ISR          TXBEF         LL_SWPMI_IsActiveFlag_TXBE
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TXBE(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXBEF) == (SWPMI_ISR_TXBEF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if CRC error in reception has been detected
  * @rmtoll ISR          RXBERF        LL_SWPMI_IsActiveFlag_RXBER
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXBER(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXBERF) == (SWPMI_ISR_RXBERF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Overrun in reception has been detected
  * @rmtoll ISR          RXOVRF        LL_SWPMI_IsActiveFlag_RXOVR
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXOVR(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXOVRF) == (SWPMI_ISR_RXOVRF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if underrun error in transmission has been detected
  * @rmtoll ISR          TXUNRF        LL_SWPMI_IsActiveFlag_TXUNR
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TXUNR(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXUNRF) == (SWPMI_ISR_TXUNRF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Receive data register not empty (it means that Received data is ready
  *         to be read in the SWPMI_RDR register)
  * @rmtoll ISR          RXNE          LL_SWPMI_IsActiveFlag_RXNE
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RXNE(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_RXNE) == (SWPMI_ISR_RXNE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Transmit data register is empty (it means that Data written in transmit
  *         data register SWPMI_TDR has been transmitted and SWPMI_TDR can be written to again)
  * @rmtoll ISR          TXE           LL_SWPMI_IsActiveFlag_TXE
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TXE(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXE) == (SWPMI_ISR_TXE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Both transmission and reception are completed and SWP is switched to
  *         the SUSPENDED state
  * @rmtoll ISR          TCF           LL_SWPMI_IsActiveFlag_TC
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_TC(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_TCF) == (SWPMI_ISR_TCF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if a Resume by slave state has been detected during the SWP bus SUSPENDED
  *         state
  * @rmtoll ISR          SRF           LL_SWPMI_IsActiveFlag_SR
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_SR(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_SRF) == (SWPMI_ISR_SRF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if SWP bus is in SUSPENDED or DEACTIVATED state
  * @rmtoll ISR          SUSP          LL_SWPMI_IsActiveFlag_SUSP
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_SUSP(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_SUSP) == (SWPMI_ISR_SUSP)) ? 1UL : 0UL);
}

/**
  * @brief  Check if SWP bus is in DEACTIVATED state
  * @rmtoll ISR          DEACTF        LL_SWPMI_IsActiveFlag_DEACT
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_DEACT(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_DEACTF) == (SWPMI_ISR_DEACTF)) ? 1UL : 0UL);
}

/**
  * @brief  Check if SWPMI transceiver is ready
  * @rmtoll ISR          RDYF        LL_SWPMI_IsActiveFlag_RDYF
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsActiveFlag_RDYF(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_RDYF) == (SWPMI_ISR_RDYF)) ? 1UL : 0UL);
}

/**
  * @brief  Clear receive buffer full flag
  * @rmtoll ICR          CRXBFF        LL_SWPMI_ClearFlag_RXBF
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_RXBF(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXBFF);
}

/**
  * @brief  Clear transmit buffer empty flag
  * @rmtoll ICR          CTXBEF        LL_SWPMI_ClearFlag_TXBE
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_TXBE(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CTXBEF);
}

/**
  * @brief  Clear receive CRC error flag
  * @rmtoll ICR          CRXBERF       LL_SWPMI_ClearFlag_RXBER
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_RXBER(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXBERF);
}

/**
  * @brief  Clear receive overrun error flag
  * @rmtoll ICR          CRXOVRF       LL_SWPMI_ClearFlag_RXOVR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_RXOVR(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXOVRF);
}

/**
  * @brief  Clear transmit underrun error flag
  * @rmtoll ICR          CTXUNRF       LL_SWPMI_ClearFlag_TXUNR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_TXUNR(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CTXUNRF);
}

/**
  * @brief  Clear transfer complete flag
  * @rmtoll ICR          CTCF          LL_SWPMI_ClearFlag_TC
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_TC(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CTCF);
}

/**
  * @brief  Clear slave resume flag
  * @rmtoll ICR          CSRF          LL_SWPMI_ClearFlag_SR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_SR(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CSRF);
}

/**
  * @brief  Clear SWPMI transceiver ready flag
  * @rmtoll ISR          CRDYF        LL_SWPMI_ClearFlag_RDY
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_ClearFlag_RDY(SWPMI_TypeDef *SWPMIx)
{
  WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRDYF);
}

/**
  * @}
  */

/** @defgroup SWPMI_LL_EF_IT_Management IT_Management
  * @{
  */

/**
  * @brief  Enable SWPMI transceiver ready interrupt
  * @rmtoll IER          RDYIE         LL_SWPMI_EnableIT_RDY
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_RDY(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_RDYIE);
}

/**
  * @brief  Enable Slave resume interrupt
  * @rmtoll IER          SRIE          LL_SWPMI_EnableIT_SR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_SR(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_SRIE);
}

/**
  * @brief  Enable Transmit complete interrupt
  * @rmtoll IER          TCIE          LL_SWPMI_EnableIT_TC
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_TC(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_TCIE);
}

/**
  * @brief  Enable Transmit interrupt
  * @rmtoll IER          TIE           LL_SWPMI_EnableIT_TX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_TX(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_TIE);
}

/**
  * @brief  Enable Receive interrupt
  * @rmtoll IER          RIE           LL_SWPMI_EnableIT_RX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_RX(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_RIE);
}

/**
  * @brief  Enable Transmit underrun error interrupt
  * @rmtoll IER          TXUNRIE       LL_SWPMI_EnableIT_TXUNR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_TXUNR(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_TXUNRIE);
}

/**
  * @brief  Enable Receive overrun error interrupt
  * @rmtoll IER          RXOVRIE       LL_SWPMI_EnableIT_RXOVR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_RXOVR(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE);
}

/**
  * @brief  Enable Receive CRC error interrupt
  * @rmtoll IER          RXBERIE       LL_SWPMI_EnableIT_RXBER
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_RXBER(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE);
}

/**
  * @brief  Enable Transmit buffer empty interrupt
  * @rmtoll IER          TXBEIE        LL_SWPMI_EnableIT_TXBE
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_TXBE(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE);
}

/**
  * @brief  Enable Receive buffer full interrupt
  * @rmtoll IER          RXBFIE        LL_SWPMI_EnableIT_RXBF
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableIT_RXBF(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->IER, SWPMI_IER_RXBFIE);
}

/**
  * @brief  Disable SWPMI transceiver ready interrupt
  * @rmtoll IER          RDYIE         LL_SWPMI_DisableIT_RDY
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_RDY(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RDYIE);
}

/**
  * @brief  Disable Slave resume interrupt
  * @rmtoll IER          SRIE          LL_SWPMI_DisableIT_SR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_SR(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_SRIE);
}

/**
  * @brief  Disable Transmit complete interrupt
  * @rmtoll IER          TCIE          LL_SWPMI_DisableIT_TC
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_TC(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TCIE);
}

/**
  * @brief  Disable Transmit interrupt
  * @rmtoll IER          TIE           LL_SWPMI_DisableIT_TX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_TX(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TIE);
}

/**
  * @brief  Disable Receive interrupt
  * @rmtoll IER          RIE           LL_SWPMI_DisableIT_RX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_RX(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RIE);
}

/**
  * @brief  Disable Transmit underrun error interrupt
  * @rmtoll IER          TXUNRIE       LL_SWPMI_DisableIT_TXUNR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_TXUNR(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TXUNRIE);
}

/**
  * @brief  Disable Receive overrun error interrupt
  * @rmtoll IER          RXOVRIE       LL_SWPMI_DisableIT_RXOVR
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_RXOVR(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE);
}

/**
  * @brief  Disable Receive CRC error interrupt
  * @rmtoll IER          RXBERIE       LL_SWPMI_DisableIT_RXBER
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_RXBER(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE);
}

/**
  * @brief  Disable Transmit buffer empty interrupt
  * @rmtoll IER          TXBEIE        LL_SWPMI_DisableIT_TXBE
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_TXBE(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE);
}

/**
  * @brief  Disable Receive buffer full interrupt
  * @rmtoll IER          RXBFIE        LL_SWPMI_DisableIT_RXBF
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableIT_RXBF(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->IER, SWPMI_IER_RXBFIE);
}

/**
  * @brief  Check if SWPMI transceiver ready interrupt is enabled
  * @rmtoll IER          RDYIE         LL_SWPMI_IsEnabledIT_RDY
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RDY(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_RDYIE) == (SWPMI_IER_RDYIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Slave resume interrupt is enabled
  * @rmtoll IER          SRIE          LL_SWPMI_IsEnabledIT_SR
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_SR(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_SRIE) == (SWPMI_IER_SRIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Transmit complete interrupt is enabled
  * @rmtoll IER          TCIE          LL_SWPMI_IsEnabledIT_TC
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TC(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_TCIE) == (SWPMI_IER_TCIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Transmit interrupt is enabled
  * @rmtoll IER          TIE           LL_SWPMI_IsEnabledIT_TX
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TX(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_TIE) == (SWPMI_IER_TIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Receive interrupt is enabled
  * @rmtoll IER          RIE           LL_SWPMI_IsEnabledIT_RX
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RX(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_RIE) == (SWPMI_IER_RIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Transmit underrun error interrupt is enabled
  * @rmtoll IER          TXUNRIE       LL_SWPMI_IsEnabledIT_TXUNR
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TXUNR(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_TXUNRIE) == (SWPMI_IER_TXUNRIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Receive overrun error interrupt is enabled
  * @rmtoll IER          RXOVRIE       LL_SWPMI_IsEnabledIT_RXOVR
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RXOVR(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_RXOVRIE) == (SWPMI_IER_RXOVRIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Receive CRC error interrupt is enabled
  * @rmtoll IER          RXBERIE       LL_SWPMI_IsEnabledIT_RXBER
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RXBER(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_RXBERIE) == (SWPMI_IER_RXBERIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Transmit buffer empty interrupt is enabled
  * @rmtoll IER          TXBEIE        LL_SWPMI_IsEnabledIT_TXBE
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_TXBE(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE) == (SWPMI_IER_TXBEIE)) ? 1UL : 0UL);
}

/**
  * @brief  Check if Receive buffer full interrupt is enabled
  * @rmtoll IER          RXBFIE        LL_SWPMI_IsEnabledIT_RXBF
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledIT_RXBF(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->IER, SWPMI_IER_RXBFIE) == (SWPMI_IER_RXBFIE)) ? 1UL : 0UL);
}

/**
  * @}
  */

/** @defgroup SWPMI_LL_EF_DMA_Management DMA_Management
  * @{
  */

/**
  * @brief  Enable DMA mode for reception
  * @rmtoll CR           RXDMA         LL_SWPMI_EnableDMAReq_RX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableDMAReq_RX(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->CR, SWPMI_CR_RXDMA);
}

/**
  * @brief  Disable DMA mode for reception
  * @rmtoll CR           RXDMA         LL_SWPMI_DisableDMAReq_RX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableDMAReq_RX(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->CR, SWPMI_CR_RXDMA);
}

/**
  * @brief  Check if DMA mode for reception is enabled
  * @rmtoll CR           RXDMA         LL_SWPMI_IsEnabledDMAReq_RX
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledDMAReq_RX(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->CR, SWPMI_CR_RXDMA) == (SWPMI_CR_RXDMA)) ? 1UL : 0UL);
}

/**
  * @brief  Enable DMA mode for transmission
  * @rmtoll CR           TXDMA         LL_SWPMI_EnableDMAReq_TX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableDMAReq_TX(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->CR, SWPMI_CR_TXDMA);
}

/**
  * @brief  Disable DMA mode for transmission
  * @rmtoll CR           TXDMA         LL_SWPMI_DisableDMAReq_TX
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableDMAReq_TX(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->CR, SWPMI_CR_TXDMA);
}

/**
  * @brief  Check if DMA mode for transmission is enabled
  * @rmtoll CR           TXDMA         LL_SWPMI_IsEnabledDMAReq_TX
  * @param  SWPMIx SWPMI Instance
  * @retval State of bit (1 or 0).
  */
__STATIC_INLINE uint32_t LL_SWPMI_IsEnabledDMAReq_TX(SWPMI_TypeDef *SWPMIx)
{
  return ((READ_BIT(SWPMIx->CR, SWPMI_CR_TXDMA) == (SWPMI_CR_TXDMA)) ? 1UL : 0UL);
}

/**
  * @brief  Get the data register address used for DMA transfer
  * @rmtoll TDR          TD            LL_SWPMI_DMA_GetRegAddr\n
  *         RDR          RD            LL_SWPMI_DMA_GetRegAddr
  * @param  SWPMIx SWPMI Instance
  * @param  Direction This parameter can be one of the following values:
  *         @arg @ref LL_SWPMI_DMA_REG_DATA_TRANSMIT
  *         @arg @ref LL_SWPMI_DMA_REG_DATA_RECEIVE
  * @retval Address of data register
  */
__STATIC_INLINE uint32_t LL_SWPMI_DMA_GetRegAddr(SWPMI_TypeDef *SWPMIx, uint32_t Direction)
{
  uint32_t data_reg_addr;

  if (Direction == LL_SWPMI_DMA_REG_DATA_TRANSMIT)
  {
    /* return address of TDR register */
    data_reg_addr = (uint32_t)&(SWPMIx->TDR);
  }
  else
  {
    /* return address of RDR register */
    data_reg_addr = (uint32_t)&(SWPMIx->RDR);
  }

  return data_reg_addr;
}

/**
  * @}
  */

/** @defgroup SWPMI_LL_EF_Data_Management Data_Management
  * @{
  */

/**
  * @brief  Retrieve number of data bytes present in payload of received frame
  * @rmtoll RFL          RFL           LL_SWPMI_GetReceiveFrameLength
  * @param  SWPMIx SWPMI Instance
  * @retval Value between Min_Data=0x00 and Max_Data=0x1F
  */
__STATIC_INLINE uint32_t LL_SWPMI_GetReceiveFrameLength(SWPMI_TypeDef *SWPMIx)
{
  return (uint32_t)(READ_BIT(SWPMIx->RFL, SWPMI_RFL_RFL));
}

/**
  * @brief  Transmit Data Register
  * @rmtoll TDR          TD            LL_SWPMI_TransmitData32
  * @param  SWPMIx SWPMI Instance
  * @param  TxData Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_TransmitData32(SWPMI_TypeDef *SWPMIx, uint32_t TxData)
{
  WRITE_REG(SWPMIx->TDR, TxData);
}

/**
  * @brief  Receive Data Register
  * @rmtoll RDR          RD            LL_SWPMI_ReceiveData32
  * @param  SWPMIx SWPMI Instance
  * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  */
__STATIC_INLINE uint32_t LL_SWPMI_ReceiveData32(SWPMI_TypeDef *SWPMIx)
{
  return (uint32_t)(READ_BIT(SWPMIx->RDR, SWPMI_RDR_RD));
}

/**
  * @brief  Enable SWP Transceiver Bypass
  * @note   The external interface for SWPMI is SWPMI_IO
  *         (SWPMI_RX, SWPMI_TX and SWPMI_SUSPEND signals are not available on GPIOs)
  * @rmtoll OR           TBYP          LL_SWPMI_EnableTXBypass
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_EnableTXBypass(SWPMI_TypeDef *SWPMIx)
{
  CLEAR_BIT(SWPMIx->OR, SWPMI_OR_TBYP);
}

/**
  * @brief  Disable SWP Transceiver Bypass
  * @note   SWPMI_RX, SWPMI_TX and SWPMI_SUSPEND signals are available as alternate
  *         function on GPIOs. This configuration is selected to connect an external transceiver
  * @note   In SWPMI_IO bypass mode, SWPEN bit in SWPMI_CR register must be kept cleared
  * @rmtoll OR           TBYP          LL_SWPMI_DisableTXBypass
  * @param  SWPMIx SWPMI Instance
  * @retval None
  */
__STATIC_INLINE void LL_SWPMI_DisableTXBypass(SWPMI_TypeDef *SWPMIx)
{
  SET_BIT(SWPMIx->OR, SWPMI_OR_TBYP);
}

/**
  * @}
  */

#if defined(USE_FULL_LL_DRIVER)
/** @defgroup SWPMI_LL_EF_Init Initialization and de-initialization functions
  * @{
  */

ErrorStatus LL_SWPMI_DeInit(SWPMI_TypeDef *SWPMIx);
ErrorStatus LL_SWPMI_Init(SWPMI_TypeDef *SWPMIx, LL_SWPMI_InitTypeDef *SWPMI_InitStruct);
void        LL_SWPMI_StructInit(LL_SWPMI_InitTypeDef *SWPMI_InitStruct);

/**
  * @}
  */
#endif /*USE_FULL_LL_DRIVER*/

/**
  * @}
  */

/**
  * @}
  */


/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* STM32H7xx_LL_SWPMI_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/