Subversion Repositories DashDisplay

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_smartcard.c
3
  * @file    stm32f1xx_hal_smartcard.c
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @version V1.0.1
5
  * @version V1.0.4
6
  * @date    31-July-2015
6
  * @date    29-April-2016
7
  * @brief   SMARTCARD HAL module driver.
7
  * @brief   SMARTCARD HAL module driver.
8
  *          This file provides firmware functions to manage the following
8
  *          This file provides firmware functions to manage the following
9
  *          functionalities of the SMARTCARD peripheral:
9
  *          functionalities of the SMARTCARD peripheral:
10
  *           + Initialization and de-initialization functions
10
  *           + Initialization and de-initialization functions
11
  *           + IO operation functions
11
  *           + IO operation functions
Line 101... Line 101...
101
 
101
 
102
  @endverbatim
102
  @endverbatim
103
  ******************************************************************************
103
  ******************************************************************************
104
  * @attention
104
  * @attention
105
  *
105
  *
106
  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
106
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
107
  *
107
  *
108
  * Redistribution and use in source and binary forms, with or without modification,
108
  * Redistribution and use in source and binary forms, with or without modification,
109
  * are permitted provided that the following conditions are met:
109
  * are permitted provided that the following conditions are met:
110
  *   1. Redistributions of source code must retain the above copyright notice,
110
  *   1. Redistributions of source code must retain the above copyright notice,
111
  *      this list of conditions and the following disclaimer.
111
  *      this list of conditions and the following disclaimer.
Line 192... Line 192...
192
  (+) For the Smartcard mode only these parameters can be configured:
192
  (+) For the Smartcard mode only these parameters can be configured:
193
      (++) Baud Rate
193
      (++) Baud Rate
194
      (++) Word Length => Should be 9 bits (8 bits + parity)
194
      (++) Word Length => Should be 9 bits (8 bits + parity)
195
      (++) Stop Bit
195
      (++) Stop Bit
196
      (++) Parity: => Should be enabled
196
      (++) Parity: => Should be enabled
197
   +-------------------------------------------------------------+
-
 
198
   |   M bit |  PCE bit  |        SMARTCARD frame                |
-
 
199
   |---------------------|---------------------------------------|
-
 
200
   |    1    |    1      |    | SB | 8 bit data | PB | STB |     |
-
 
201
   +-------------------------------------------------------------+
-
 
202
      (++) USART polarity
197
      (++) USART polarity
203
      (++) USART phase
198
      (++) USART phase
204
      (++) USART LastBit
199
      (++) USART LastBit
205
      (++) Receiver/transmitter modes
200
      (++) Receiver/transmitter modes
206
      (++) Prescaler
201
      (++) Prescaler
Line 226... Line 221...
226
 
221
 
227
@endverbatim
222
@endverbatim
228
  * @{
223
  * @{
229
  */
224
  */
230
 
225
 
-
 
226
/*
-
 
227
  Additionnal remark on the smartcard frame:
-
 
228
   +-------------------------------------------------------------+
-
 
229
   |   M bit |  PCE bit  |        SMARTCARD frame                |
-
 
230
   |---------------------|---------------------------------------|
-
 
231
   |    1    |    1      |    | SB | 8 bit data | PB | STB |     |
-
 
232
   +-------------------------------------------------------------+
-
 
233
*/
-
 
234
 
231
/**
235
/**
232
  * @brief  Initializes the SmartCard mode according to the specified
236
  * @brief  Initializes the SmartCard mode according to the specified
233
  *         parameters in the SMARTCARD_HandleTypeDef and create the associated handle.
237
  *         parameters in the SMARTCARD_HandleTypeDef and create the associated handle.
234
  * @param  hsc: Pointer to a SMARTCARD_HandleTypeDef structure that contains
238
  * @param  hsc: Pointer to a SMARTCARD_HandleTypeDef structure that contains
235
  *              the configuration information for the specified SMARTCARD module.
239
  *              the configuration information for the specified SMARTCARD module.
Line 347... Line 351...
347
  *                the configuration information for the specified SMARTCARD module.
351
  *                the configuration information for the specified SMARTCARD module.
348
  * @retval None
352
  * @retval None
349
  */
353
  */
350
 __weak void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc)
354
 __weak void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc)
351
{
355
{
-
 
356
  /* Prevent unused argument(s) compilation warning */
-
 
357
  UNUSED(hsc);
352
  /* NOTE: This function should not be modified, when the callback is needed,
358
  /* NOTE: This function should not be modified, when the callback is needed,
353
           the HAL_SMARTCARD_MspInit can be implemented in the user file
359
           the HAL_SMARTCARD_MspInit can be implemented in the user file
354
   */
360
   */
355
}
361
}
356
 
362
 
Line 360... Line 366...
360
  *                the configuration information for the specified SMARTCARD module.
366
  *                the configuration information for the specified SMARTCARD module.
361
  * @retval None
367
  * @retval None
362
  */
368
  */
363
 __weak void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc)
369
 __weak void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc)
364
{
370
{
-
 
371
  /* Prevent unused argument(s) compilation warning */
-
 
372
  UNUSED(hsc);
365
  /* NOTE: This function should not be modified, when the callback is needed,
373
  /* NOTE: This function should not be modified, when the callback is needed,
366
           the HAL_SMARTCARD_MspDeInit can be implemented in the user file
374
           the HAL_SMARTCARD_MspDeInit can be implemented in the user file
367
   */
375
   */
368
}
376
}
369
 
377
 
Line 824... Line 832...
824
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_PE);
832
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_PE);
825
  tmp_it_source = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_PE);
833
  tmp_it_source = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_PE);
826
  /* SMARTCARD parity error interrupt occurred -----------------------------------*/
834
  /* SMARTCARD parity error interrupt occurred -----------------------------------*/
827
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
835
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
828
  {
836
  {
829
    __HAL_SMARTCARD_CLEAR_PEFLAG(hsc);
-
 
830
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_PE;
837
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_PE;
831
  }
838
  }
832
 
839
 
833
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_FE);
840
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_FE);
834
  tmp_it_source = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_ERR);
841
  tmp_it_source = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_ERR);
835
  /* SMARTCARD frame error interrupt occurred ------------------------------------*/
842
  /* SMARTCARD frame error interrupt occurred ------------------------------------*/
836
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
843
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
837
  {
844
  {
838
    __HAL_SMARTCARD_CLEAR_FEFLAG(hsc);
-
 
839
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_FE;
845
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_FE;
840
  }
846
  }
841
 
847
 
842
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_NE);
848
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_NE);
843
  /* SMARTCARD noise error interrupt occurred ------------------------------------*/
849
  /* SMARTCARD noise error interrupt occurred ------------------------------------*/
844
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
850
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
845
  {
851
  {
846
    __HAL_SMARTCARD_CLEAR_NEFLAG(hsc);
-
 
847
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_NE;
852
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_NE;
848
  }
853
  }
849
 
854
 
850
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_ORE);
855
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_ORE);
851
  /* SMARTCARD Over-Run interrupt occurred ---------------------------------------*/
856
  /* SMARTCARD Over-Run interrupt occurred ---------------------------------------*/
852
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
857
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
853
  {
858
  {
854
    __HAL_SMARTCARD_CLEAR_OREFLAG(hsc);
-
 
855
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_ORE;
859
    hsc->ErrorCode |= HAL_SMARTCARD_ERROR_ORE;
856
  }
860
  }
857
 
861
 
858
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_RXNE);
862
  tmp_flag = __HAL_SMARTCARD_GET_FLAG(hsc, SMARTCARD_FLAG_RXNE);
859
  tmp_it_source = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_RXNE);
863
  tmp_it_source = __HAL_SMARTCARD_GET_IT_SOURCE(hsc, SMARTCARD_IT_RXNE);
Line 880... Line 884...
880
  }
884
  }
881
 
885
 
882
  /* Call the Error call Back in case of Errors */
886
  /* Call the Error call Back in case of Errors */
883
  if(hsc->ErrorCode != HAL_SMARTCARD_ERROR_NONE)
887
  if(hsc->ErrorCode != HAL_SMARTCARD_ERROR_NONE)
884
  {
888
  {
-
 
889
    /* Clear all the error flag at once */
-
 
890
    __HAL_SMARTCARD_CLEAR_PEFLAG(hsc);
-
 
891
 
885
    /* Set the SMARTCARD state ready to be able to start again the process */
892
    /* Set the SMARTCARD state ready to be able to start again the process */
886
    hsc->State= HAL_SMARTCARD_STATE_READY;
893
    hsc->State= HAL_SMARTCARD_STATE_READY;
887
    HAL_SMARTCARD_ErrorCallback(hsc);
894
    HAL_SMARTCARD_ErrorCallback(hsc);
888
  }
895
  }
889
}
896
}
Line 894... Line 901...
894
  *                the configuration information for the specified SMARTCARD module.
901
  *                the configuration information for the specified SMARTCARD module.
895
  * @retval None
902
  * @retval None
896
  */
903
  */
897
 __weak void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc)
904
 __weak void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc)
898
{
905
{
-
 
906
  /* Prevent unused argument(s) compilation warning */
-
 
907
  UNUSED(hsc);
899
  /* NOTE: This function should not be modified, when the callback is needed,
908
  /* NOTE: This function should not be modified, when the callback is needed,
900
           the HAL_SMARTCARD_TxCpltCallback can be implemented in the user file
909
           the HAL_SMARTCARD_TxCpltCallback can be implemented in the user file
901
   */
910
   */
902
}
911
}
903
 
912
 
Line 907... Line 916...
907
  *                the configuration information for the specified SMARTCARD module.
916
  *                the configuration information for the specified SMARTCARD module.
908
  * @retval None
917
  * @retval None
909
  */
918
  */
910
__weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc)
919
__weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc)
911
{
920
{
-
 
921
  /* Prevent unused argument(s) compilation warning */
-
 
922
  UNUSED(hsc);
912
  /* NOTE: This function should not be modified, when the callback is needed,
923
  /* NOTE: This function should not be modified, when the callback is needed,
913
           the HAL_SMARTCARD_RxCpltCallback can be implemented in the user file
924
           the HAL_SMARTCARD_RxCpltCallback can be implemented in the user file
914
   */
925
   */
915
}
926
}
916
 
927
 
Line 920... Line 931...
920
  *                the configuration information for the specified SMARTCARD module.
931
  *                the configuration information for the specified SMARTCARD module.
921
  * @retval None
932
  * @retval None
922
  */
933
  */
923
 __weak void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc)
934
 __weak void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc)
924
{
935
{
-
 
936
  /* Prevent unused argument(s) compilation warning */
-
 
937
  UNUSED(hsc);
925
  /* NOTE: This function should not be modified, when the callback is needed,
938
  /* NOTE: This function should not be modified, when the callback is needed,
926
           the HAL_SMARTCARD_ErrorCallback can be implemented in the user file
939
           the HAL_SMARTCARD_ErrorCallback can be implemented in the user file
927
   */
940
   */
928
}
941
}
929
 
942