20#ifndef STM32H7xx_HAL_SMARTCARD_H
21#define STM32H7xx_HAL_SMARTCARD_H
246#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
270#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
276 HAL_SMARTCARD_TX_COMPLETE_CB_ID = 0x00U,
277 HAL_SMARTCARD_RX_COMPLETE_CB_ID = 0x01U,
278 HAL_SMARTCARD_ERROR_CB_ID = 0x02U,
279 HAL_SMARTCARD_ABORT_COMPLETE_CB_ID = 0x03U,
280 HAL_SMARTCARD_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x04U,
281 HAL_SMARTCARD_ABORT_RECEIVE_COMPLETE_CB_ID = 0x05U,
282 HAL_SMARTCARD_RX_FIFO_FULL_CB_ID = 0x06U,
283 HAL_SMARTCARD_TX_FIFO_EMPTY_CB_ID = 0x07U,
285 HAL_SMARTCARD_MSPINIT_CB_ID = 0x08U,
286 HAL_SMARTCARD_MSPDEINIT_CB_ID = 0x09U
288} HAL_SMARTCARD_CallbackIDTypeDef;
326#define HAL_SMARTCARD_STATE_RESET 0x00000000U
328#define HAL_SMARTCARD_STATE_READY 0x00000020U
331#define HAL_SMARTCARD_STATE_BUSY 0x00000024U
333#define HAL_SMARTCARD_STATE_BUSY_TX 0x00000021U
335#define HAL_SMARTCARD_STATE_BUSY_RX 0x00000022U
337#define HAL_SMARTCARD_STATE_BUSY_TX_RX 0x00000023U
342#define HAL_SMARTCARD_STATE_TIMEOUT 0x000000A0U
344#define HAL_SMARTCARD_STATE_ERROR 0x000000E0U
354#define HAL_SMARTCARD_ERROR_NONE (0x00000000U)
355#define HAL_SMARTCARD_ERROR_PE (0x00000001U)
356#define HAL_SMARTCARD_ERROR_NE (0x00000002U)
357#define HAL_SMARTCARD_ERROR_FE (0x00000004U)
358#define HAL_SMARTCARD_ERROR_ORE (0x00000008U)
359#define HAL_SMARTCARD_ERROR_DMA (0x00000010U)
360#define HAL_SMARTCARD_ERROR_RTO (0x00000020U)
361#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
362#define HAL_SMARTCARD_ERROR_INVALID_CALLBACK (0x00000040U)
372#define SMARTCARD_WORDLENGTH_9B USART_CR1_M0
381#define SMARTCARD_STOPBITS_0_5 USART_CR2_STOP_0
382#define SMARTCARD_STOPBITS_1_5 USART_CR2_STOP
391#define SMARTCARD_PARITY_EVEN USART_CR1_PCE
392#define SMARTCARD_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS)
401#define SMARTCARD_MODE_RX USART_CR1_RE
402#define SMARTCARD_MODE_TX USART_CR1_TE
403#define SMARTCARD_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE)
412#define SMARTCARD_POLARITY_LOW 0x00000000U
413#define SMARTCARD_POLARITY_HIGH USART_CR2_CPOL
422#define SMARTCARD_PHASE_1EDGE 0x00000000U
423#define SMARTCARD_PHASE_2EDGE USART_CR2_CPHA
432#define SMARTCARD_LASTBIT_DISABLE 0x00000000U
433#define SMARTCARD_LASTBIT_ENABLE USART_CR2_LBCL
442#define SMARTCARD_ONE_BIT_SAMPLE_DISABLE 0x00000000U
443#define SMARTCARD_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT
452#define SMARTCARD_NACK_DISABLE 0x00000000U
453#define SMARTCARD_NACK_ENABLE USART_CR3_NACK
462#define SMARTCARD_TIMEOUT_DISABLE 0x00000000U
463#define SMARTCARD_TIMEOUT_ENABLE USART_CR2_RTOEN
472#define SMARTCARD_PRESCALER_DIV1 0x00000000U
473#define SMARTCARD_PRESCALER_DIV2 0x00000001U
474#define SMARTCARD_PRESCALER_DIV4 0x00000002U
475#define SMARTCARD_PRESCALER_DIV6 0x00000003U
476#define SMARTCARD_PRESCALER_DIV8 0x00000004U
477#define SMARTCARD_PRESCALER_DIV10 0x00000005U
478#define SMARTCARD_PRESCALER_DIV12 0x00000006U
479#define SMARTCARD_PRESCALER_DIV16 0x00000007U
480#define SMARTCARD_PRESCALER_DIV32 0x00000008U
481#define SMARTCARD_PRESCALER_DIV64 0x00000009U
482#define SMARTCARD_PRESCALER_DIV128 0x0000000AU
483#define SMARTCARD_PRESCALER_DIV256 0x0000000BU
492#define SMARTCARD_ADVFEATURE_TXINV_DISABLE 0x00000000U
493#define SMARTCARD_ADVFEATURE_TXINV_ENABLE USART_CR2_TXINV
502#define SMARTCARD_ADVFEATURE_RXINV_DISABLE 0x00000000U
503#define SMARTCARD_ADVFEATURE_RXINV_ENABLE USART_CR2_RXINV
512#define SMARTCARD_ADVFEATURE_DATAINV_DISABLE 0x00000000U
513#define SMARTCARD_ADVFEATURE_DATAINV_ENABLE USART_CR2_DATAINV
522#define SMARTCARD_ADVFEATURE_SWAP_DISABLE 0x00000000U
523#define SMARTCARD_ADVFEATURE_SWAP_ENABLE USART_CR2_SWAP
532#define SMARTCARD_ADVFEATURE_OVERRUN_ENABLE 0x00000000U
533#define SMARTCARD_ADVFEATURE_OVERRUN_DISABLE USART_CR3_OVRDIS
542#define SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR 0x00000000U
543#define SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR USART_CR3_DDRE
552#define SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE 0x00000000U
553#define SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE USART_CR2_MSBFIRST
562#define SMARTCARD_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ
563#define SMARTCARD_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ
572#define SMARTCARD_IT_MASK 0x001FU
573#define SMARTCARD_CR_MASK 0x00E0U
574#define SMARTCARD_CR_POS 5U
575#define SMARTCARD_ISR_MASK 0x1F00U
576#define SMARTCARD_ISR_POS 8U
595#if USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1
596#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) do{ \
597 (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET; \
598 (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET; \
599 (__HANDLE__)->MspInitCallback = NULL; \
600 (__HANDLE__)->MspDeInitCallback = NULL; \
603#define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) do{ \
604 (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET; \
605 (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET; \
613#define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) \
615 SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_RXDATA_FLUSH_REQUEST); \
616 SET_BIT((__HANDLE__)->Instance->RQR, SMARTCARD_TXDATA_FLUSH_REQUEST); \
635#define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
641#define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_PEF)
647#define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_FEF)
653#define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_NEF)
659#define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_OREF)
665#define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_FLAG((__HANDLE__), SMARTCARD_CLEAR_IDLEF)
693#define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
717#define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\
718 SMARTCARD_CR_POS) == 1U)?\
719 ((__HANDLE__)->Instance->CR1 |= (1UL <<\
720 ((__INTERRUPT__) & SMARTCARD_IT_MASK))):\
721 ((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\
722 SMARTCARD_CR_POS) == 2U)?\
723 ((__HANDLE__)->Instance->CR2 |= (1UL <<\
724 ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
725 ((__HANDLE__)->Instance->CR3 |= (1UL <<\
726 ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
750#define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\
751 SMARTCARD_CR_POS) == 1U)?\
752 ((__HANDLE__)->Instance->CR1 &= ~ (1U <<\
753 ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
754 ((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\
755 SMARTCARD_CR_POS) == 2U)?\
756 ((__HANDLE__)->Instance->CR2 &= ~ (1U <<\
757 ((__INTERRUPT__) & SMARTCARD_IT_MASK))): \
758 ((__HANDLE__)->Instance->CR3 &= ~ (1U <<\
759 ((__INTERRUPT__) & SMARTCARD_IT_MASK))))
783#define __HAL_SMARTCARD_GET_IT(__HANDLE__, __INTERRUPT__) (\
784 (((__HANDLE__)->Instance->ISR & (0x01UL << (((__INTERRUPT__)\
785 & SMARTCARD_ISR_MASK)>> SMARTCARD_ISR_POS)))!= 0U)\
810#define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\
811 SMARTCARD_CR_POS) == 0x01U)?\
812 (__HANDLE__)->Instance->CR1 : \
813 (((((__INTERRUPT__) & SMARTCARD_CR_MASK) >>\
814 SMARTCARD_CR_POS) == 0x02U)?\
815 (__HANDLE__)->Instance->CR2 : \
816 (__HANDLE__)->Instance->CR3)) &\
817 (0x01UL << (((uint16_t)(__INTERRUPT__))\
818 & SMARTCARD_IT_MASK))) != 0U)\
838#define __HAL_SMARTCARD_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR |= (uint32_t)(__IT_CLEAR__))
848#define __HAL_SMARTCARD_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
854#define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
860#define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3\
861 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
867#define __HAL_SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
873#define __HAL_SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
890#if defined(UART9) && defined(USART10)
891#define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
893 if ((__HANDLE__)->Instance == USART1) \
895 switch (__HAL_RCC_GET_USART1_SOURCE()) \
897 case RCC_USART1CLKSOURCE_D2PCLK2: \
898 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK2; \
900 case RCC_USART1CLKSOURCE_PLL2: \
901 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
903 case RCC_USART1CLKSOURCE_PLL3: \
904 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
906 case RCC_USART1CLKSOURCE_HSI: \
907 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
909 case RCC_USART1CLKSOURCE_CSI: \
910 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
912 case RCC_USART1CLKSOURCE_LSE: \
913 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
916 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
920 else if ((__HANDLE__)->Instance == USART2) \
922 switch (__HAL_RCC_GET_USART2_SOURCE()) \
924 case RCC_USART2CLKSOURCE_D2PCLK1: \
925 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK1; \
927 case RCC_USART2CLKSOURCE_PLL2: \
928 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
930 case RCC_USART2CLKSOURCE_PLL3: \
931 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
933 case RCC_USART2CLKSOURCE_HSI: \
934 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
936 case RCC_USART2CLKSOURCE_CSI: \
937 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
939 case RCC_USART2CLKSOURCE_LSE: \
940 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
943 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
947 else if ((__HANDLE__)->Instance == USART3) \
949 switch (__HAL_RCC_GET_USART3_SOURCE()) \
951 case RCC_USART3CLKSOURCE_D2PCLK1: \
952 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK1; \
954 case RCC_USART3CLKSOURCE_PLL2: \
955 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
957 case RCC_USART3CLKSOURCE_PLL3: \
958 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
960 case RCC_USART3CLKSOURCE_HSI: \
961 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
963 case RCC_USART3CLKSOURCE_CSI: \
964 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
966 case RCC_USART3CLKSOURCE_LSE: \
967 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
970 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
974 else if ((__HANDLE__)->Instance == USART6) \
976 switch (__HAL_RCC_GET_USART6_SOURCE()) \
978 case RCC_USART6CLKSOURCE_D2PCLK2: \
979 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK2; \
981 case RCC_USART6CLKSOURCE_PLL2: \
982 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
984 case RCC_USART6CLKSOURCE_PLL3: \
985 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
987 case RCC_USART6CLKSOURCE_HSI: \
988 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
990 case RCC_USART6CLKSOURCE_CSI: \
991 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
993 case RCC_USART6CLKSOURCE_LSE: \
994 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
997 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1001 else if ((__HANDLE__)->Instance == USART10) \
1003 switch (__HAL_RCC_GET_USART10_SOURCE()) \
1005 case RCC_USART10CLKSOURCE_D2PCLK2: \
1006 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK2; \
1008 case RCC_USART10CLKSOURCE_PLL2: \
1009 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
1011 case RCC_USART10CLKSOURCE_PLL3: \
1012 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
1014 case RCC_USART10CLKSOURCE_HSI: \
1015 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
1017 case RCC_USART10CLKSOURCE_CSI: \
1018 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
1020 case RCC_USART10CLKSOURCE_LSE: \
1021 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
1024 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1030 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1034#define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
1036 if ((__HANDLE__)->Instance == USART1) \
1038 switch (__HAL_RCC_GET_USART1_SOURCE()) \
1040 case RCC_USART1CLKSOURCE_D2PCLK2: \
1041 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK2; \
1043 case RCC_USART1CLKSOURCE_PLL2: \
1044 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
1046 case RCC_USART1CLKSOURCE_PLL3: \
1047 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
1049 case RCC_USART1CLKSOURCE_HSI: \
1050 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
1052 case RCC_USART1CLKSOURCE_CSI: \
1053 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
1055 case RCC_USART1CLKSOURCE_LSE: \
1056 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
1059 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1063 else if ((__HANDLE__)->Instance == USART2) \
1065 switch (__HAL_RCC_GET_USART2_SOURCE()) \
1067 case RCC_USART2CLKSOURCE_D2PCLK1: \
1068 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK1; \
1070 case RCC_USART2CLKSOURCE_PLL2: \
1071 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
1073 case RCC_USART2CLKSOURCE_PLL3: \
1074 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
1076 case RCC_USART2CLKSOURCE_HSI: \
1077 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
1079 case RCC_USART2CLKSOURCE_CSI: \
1080 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
1082 case RCC_USART2CLKSOURCE_LSE: \
1083 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
1086 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1090 else if ((__HANDLE__)->Instance == USART3) \
1092 switch (__HAL_RCC_GET_USART3_SOURCE()) \
1094 case RCC_USART3CLKSOURCE_D2PCLK1: \
1095 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK1; \
1097 case RCC_USART3CLKSOURCE_PLL2: \
1098 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
1100 case RCC_USART3CLKSOURCE_PLL3: \
1101 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
1103 case RCC_USART3CLKSOURCE_HSI: \
1104 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
1106 case RCC_USART3CLKSOURCE_CSI: \
1107 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
1109 case RCC_USART3CLKSOURCE_LSE: \
1110 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
1113 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1117 else if ((__HANDLE__)->Instance == USART6) \
1119 switch (__HAL_RCC_GET_USART6_SOURCE()) \
1121 case RCC_USART6CLKSOURCE_D2PCLK2: \
1122 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_D2PCLK2; \
1124 case RCC_USART6CLKSOURCE_PLL2: \
1125 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL2Q; \
1127 case RCC_USART6CLKSOURCE_PLL3: \
1128 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PLL3Q; \
1130 case RCC_USART6CLKSOURCE_HSI: \
1131 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
1133 case RCC_USART6CLKSOURCE_CSI: \
1134 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_CSI; \
1136 case RCC_USART6CLKSOURCE_LSE: \
1137 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
1140 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1146 (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
1157#define IS_SMARTCARD_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 6250001U)
1164#define IS_SMARTCARD_BLOCKLENGTH(__LENGTH__) ((__LENGTH__) <= 0xFFU)
1171#define IS_SMARTCARD_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFFU)
1178#define IS_SMARTCARD_AUTORETRY_COUNT(__COUNT__) ((__COUNT__) <= 0x7U)
1184#define IS_SMARTCARD_WORD_LENGTH(__LENGTH__) ((__LENGTH__) == SMARTCARD_WORDLENGTH_9B)
1190#define IS_SMARTCARD_STOPBITS(__STOPBITS__) (((__STOPBITS__) == SMARTCARD_STOPBITS_0_5) ||\
1191 ((__STOPBITS__) == SMARTCARD_STOPBITS_1_5))
1197#define IS_SMARTCARD_PARITY(__PARITY__) (((__PARITY__) == SMARTCARD_PARITY_EVEN) || \
1198 ((__PARITY__) == SMARTCARD_PARITY_ODD))
1204#define IS_SMARTCARD_MODE(__MODE__) ((((__MODE__) & 0xFFF3U) == 0x00U) && ((__MODE__) != 0x00U))
1210#define IS_SMARTCARD_POLARITY(__CPOL__) (((__CPOL__) == SMARTCARD_POLARITY_LOW)\
1211 || ((__CPOL__) == SMARTCARD_POLARITY_HIGH))
1217#define IS_SMARTCARD_PHASE(__CPHA__) (((__CPHA__) == SMARTCARD_PHASE_1EDGE) || ((__CPHA__) == SMARTCARD_PHASE_2EDGE))
1223#define IS_SMARTCARD_LASTBIT(__LASTBIT__) (((__LASTBIT__) == SMARTCARD_LASTBIT_DISABLE) || \
1224 ((__LASTBIT__) == SMARTCARD_LASTBIT_ENABLE))
1230#define IS_SMARTCARD_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_DISABLE) || \
1231 ((__ONEBIT__) == SMARTCARD_ONE_BIT_SAMPLE_ENABLE))
1237#define IS_SMARTCARD_NACK(__NACK__) (((__NACK__) == SMARTCARD_NACK_ENABLE) || \
1238 ((__NACK__) == SMARTCARD_NACK_DISABLE))
1244#define IS_SMARTCARD_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == SMARTCARD_TIMEOUT_DISABLE) || \
1245 ((__TIMEOUT__) == SMARTCARD_TIMEOUT_ENABLE))
1251#define IS_SMARTCARD_CLOCKPRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV1) || \
1252 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV2) || \
1253 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV4) || \
1254 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV6) || \
1255 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV8) || \
1256 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV10) || \
1257 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV12) || \
1258 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV16) || \
1259 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV32) || \
1260 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV64) || \
1261 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV128) || \
1262 ((__CLOCKPRESCALER__) == SMARTCARD_PRESCALER_DIV256))
1268#define IS_SMARTCARD_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (SMARTCARD_ADVFEATURE_NO_INIT | \
1269 SMARTCARD_ADVFEATURE_TXINVERT_INIT | \
1270 SMARTCARD_ADVFEATURE_RXINVERT_INIT | \
1271 SMARTCARD_ADVFEATURE_DATAINVERT_INIT | \
1272 SMARTCARD_ADVFEATURE_SWAP_INIT | \
1273 SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
1274 SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT | \
1275 SMARTCARD_ADVFEATURE_MSBFIRST_INIT))
1281#define IS_SMARTCARD_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == SMARTCARD_ADVFEATURE_TXINV_DISABLE) || \
1282 ((__TXINV__) == SMARTCARD_ADVFEATURE_TXINV_ENABLE))
1288#define IS_SMARTCARD_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == SMARTCARD_ADVFEATURE_RXINV_DISABLE) || \
1289 ((__RXINV__) == SMARTCARD_ADVFEATURE_RXINV_ENABLE))
1295#define IS_SMARTCARD_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == SMARTCARD_ADVFEATURE_DATAINV_DISABLE) || \
1296 ((__DATAINV__) == SMARTCARD_ADVFEATURE_DATAINV_ENABLE))
1302#define IS_SMARTCARD_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == SMARTCARD_ADVFEATURE_SWAP_DISABLE) || \
1303 ((__SWAP__) == SMARTCARD_ADVFEATURE_SWAP_ENABLE))
1309#define IS_SMARTCARD_OVERRUN(__OVERRUN__) (((__OVERRUN__) == SMARTCARD_ADVFEATURE_OVERRUN_ENABLE) || \
1310 ((__OVERRUN__) == SMARTCARD_ADVFEATURE_OVERRUN_DISABLE))
1316#define IS_SMARTCARD_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR) || \
1317 ((__DMA__) == SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR))
1323#define IS_SMARTCARD_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == SMARTCARD_ADVFEATURE_MSBFIRST_DISABLE) || \
1324 ((__MSBFIRST__) == SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE))
1330#define IS_SMARTCARD_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == SMARTCARD_RXDATA_FLUSH_REQUEST) || \
1331 ((__PARAM__) == SMARTCARD_TXDATA_FLUSH_REQUEST))
1355#if (USE_HAL_SMARTCARD_REGISTER_CALLBACKS == 1)
1358 HAL_SMARTCARD_CallbackIDTypeDef CallbackID,
1359 pSMARTCARD_CallbackTypeDef pCallback);
1361 HAL_SMARTCARD_CallbackIDTypeDef CallbackID);
#define __IO
Definition: core_cm4.h:239
SMARTCARD_ClockSourceTypeDef
SMARTCARD clock sources.
Definition: stm32h7xx_hal_smartcard.h:301
struct __SMARTCARD_HandleTypeDef SMARTCARD_HandleTypeDef
SMARTCARD handle Structure definition.
uint32_t HAL_SMARTCARD_StateTypeDef
HAL SMARTCARD State definition.
Definition: stm32h7xx_hal_smartcard.h:192
@ SMARTCARD_CLOCKSOURCE_PLL2Q
Definition: stm32h7xx_hal_smartcard.h:307
@ SMARTCARD_CLOCKSOURCE_UNDEFINED
Definition: stm32h7xx_hal_smartcard.h:309
@ SMARTCARD_CLOCKSOURCE_HSI
Definition: stm32h7xx_hal_smartcard.h:304
@ SMARTCARD_CLOCKSOURCE_CSI
Definition: stm32h7xx_hal_smartcard.h:305
@ SMARTCARD_CLOCKSOURCE_D2PCLK2
Definition: stm32h7xx_hal_smartcard.h:303
@ SMARTCARD_CLOCKSOURCE_LSE
Definition: stm32h7xx_hal_smartcard.h:306
@ SMARTCARD_CLOCKSOURCE_PLL3Q
Definition: stm32h7xx_hal_smartcard.h:308
@ SMARTCARD_CLOCKSOURCE_D2PCLK1
Definition: stm32h7xx_hal_smartcard.h:302
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of SMARTCARD HAL Extended module.
SMARTCARD advanced features initialization structure definition.
Definition: stm32h7xx_hal_smartcard.h:119
uint32_t DMADisableonRxError
Definition: stm32h7xx_hal_smartcard.h:140
uint16_t TxCompletionIndication
Definition: stm32h7xx_hal_smartcard.h:146
uint32_t AdvFeatureInit
Definition: stm32h7xx_hal_smartcard.h:120
uint32_t Swap
Definition: stm32h7xx_hal_smartcard.h:134
uint32_t DataInvert
Definition: stm32h7xx_hal_smartcard.h:130
uint32_t TxPinLevelInvert
Definition: stm32h7xx_hal_smartcard.h:124
uint32_t MSBFirst
Definition: stm32h7xx_hal_smartcard.h:143
uint32_t RxPinLevelInvert
Definition: stm32h7xx_hal_smartcard.h:127
uint32_t OverrunDisable
Definition: stm32h7xx_hal_smartcard.h:137
SMARTCARD Init Structure definition.
Definition: stm32h7xx_hal_smartcard.h:48
uint8_t BlockLength
Definition: stm32h7xx_hal_smartcard.h:102
uint32_t WordLength
Definition: stm32h7xx_hal_smartcard.h:54
uint16_t OneBitSampling
Definition: stm32h7xx_hal_smartcard.h:80
uint16_t CLKLastBit
Definition: stm32h7xx_hal_smartcard.h:76
uint16_t Parity
Definition: stm32h7xx_hal_smartcard.h:61
uint16_t NACKEnable
Definition: stm32h7xx_hal_smartcard.h:91
uint16_t CLKPhase
Definition: stm32h7xx_hal_smartcard.h:73
uint32_t TimeOutValue
Definition: stm32h7xx_hal_smartcard.h:98
uint8_t AutoRetryCount
Definition: stm32h7xx_hal_smartcard.h:105
uint8_t Prescaler
Definition: stm32h7xx_hal_smartcard.h:85
uint32_t BaudRate
Definition: stm32h7xx_hal_smartcard.h:49
uint32_t ClockPrescaler
Definition: stm32h7xx_hal_smartcard.h:110
uint32_t StopBits
Definition: stm32h7xx_hal_smartcard.h:58
uint16_t CLKPolarity
Definition: stm32h7xx_hal_smartcard.h:70
uint8_t GuardTime
Definition: stm32h7xx_hal_smartcard.h:89
uint16_t Mode
Definition: stm32h7xx_hal_smartcard.h:67
uint32_t TimeOutEnable
Definition: stm32h7xx_hal_smartcard.h:95
Universal Synchronous Asynchronous Receiver Transmitter.
Definition: stm32h723xx.h:1596
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138
SMARTCARD handle Structure definition.
Definition: stm32h7xx_hal_smartcard.h:198
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_smartcard.h:233
uint32_t FifoMode
Definition: stm32h7xx_hal_smartcard.h:221
SMARTCARD_InitTypeDef Init
Definition: stm32h7xx_hal_smartcard.h:201
DMA_HandleTypeDef * hdmarx
Definition: stm32h7xx_hal_smartcard.h:231
uint16_t NbTxDataToProcess
Definition: stm32h7xx_hal_smartcard.h:219
__IO uint16_t TxXferCount
Definition: stm32h7xx_hal_smartcard.h:209
SMARTCARD_AdvFeatureInitTypeDef AdvancedInit
Definition: stm32h7xx_hal_smartcard.h:203
uint16_t RxXferSize
Definition: stm32h7xx_hal_smartcard.h:213
uint16_t TxXferSize
Definition: stm32h7xx_hal_smartcard.h:207
uint8_t * pRxBuffPtr
Definition: stm32h7xx_hal_smartcard.h:211
USART_TypeDef * Instance
Definition: stm32h7xx_hal_smartcard.h:199
void(* TxISR)(struct __SMARTCARD_HandleTypeDef *huart)
Definition: stm32h7xx_hal_smartcard.h:227
__IO uint32_t ErrorCode
Definition: stm32h7xx_hal_smartcard.h:244
__IO uint16_t RxXferCount
Definition: stm32h7xx_hal_smartcard.h:215
__IO HAL_SMARTCARD_StateTypeDef gState
Definition: stm32h7xx_hal_smartcard.h:235
const uint8_t * pTxBuffPtr
Definition: stm32h7xx_hal_smartcard.h:205
__IO HAL_SMARTCARD_StateTypeDef RxState
Definition: stm32h7xx_hal_smartcard.h:240
DMA_HandleTypeDef * hdmatx
Definition: stm32h7xx_hal_smartcard.h:229
void(* RxISR)(struct __SMARTCARD_HandleTypeDef *huart)
Definition: stm32h7xx_hal_smartcard.h:225
uint16_t NbRxDataToProcess
Definition: stm32h7xx_hal_smartcard.h:217