Subversion Repositories FuelGauge

Rev

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

Rev 2 Rev 6
Line 45... Line 45...
45
  *** Callback registration ***
45
  *** Callback registration ***
46
  =============================================
46
  =============================================
47
 
47
 
48
  The compilation define  USE_HAL_CEC_REGISTER_CALLBACKS when set to 1
48
  The compilation define  USE_HAL_CEC_REGISTER_CALLBACKS when set to 1
49
  allows the user to configure dynamically the driver callbacks.
49
  allows the user to configure dynamically the driver callbacks.
50
  Use Functions @ref HAL_CEC_RegisterCallback() or HAL_CEC_RegisterXXXCallback()
50
  Use Functions HAL_CEC_RegisterCallback() or HAL_CEC_RegisterXXXCallback()
51
  to register an interrupt callback.
51
  to register an interrupt callback.
52
 
52
 
53
  Function @ref HAL_CEC_RegisterCallback() allows to register following callbacks:
53
  Function HAL_CEC_RegisterCallback() allows to register following callbacks:
54
    (+) TxCpltCallback     : Tx Transfer completed callback.
54
    (+) TxCpltCallback     : Tx Transfer completed callback.
55
    (+) ErrorCallback      : callback for error detection.
55
    (+) ErrorCallback      : callback for error detection.
56
    (+) MspInitCallback    : CEC MspInit.
56
    (+) MspInitCallback    : CEC MspInit.
57
    (+) MspDeInitCallback  : CEC MspDeInit.
57
    (+) MspDeInitCallback  : CEC MspDeInit.
58
  This function takes as parameters the HAL peripheral handle, the Callback ID
58
  This function takes as parameters the HAL peripheral handle, the Callback ID
59
  and a pointer to the user callback function.
59
  and a pointer to the user callback function.
60
 
60
 
61
  For specific callback HAL_CEC_RxCpltCallback use dedicated register callbacks
61
  For specific callback HAL_CEC_RxCpltCallback use dedicated register callbacks
62
  @ref HAL_CEC_RegisterRxCpltCallback().
62
  HAL_CEC_RegisterRxCpltCallback().
63
 
63
 
64
  Use function @ref HAL_CEC_UnRegisterCallback() to reset a callback to the default
64
  Use function HAL_CEC_UnRegisterCallback() to reset a callback to the default
65
  weak function.
65
  weak function.
66
  @ref HAL_CEC_UnRegisterCallback() takes as parameters the HAL peripheral handle,
66
  HAL_CEC_UnRegisterCallback() takes as parameters the HAL peripheral handle,
67
  and the Callback ID.
67
  and the Callback ID.
68
  This function allows to reset following callbacks:
68
  This function allows to reset following callbacks:
69
    (+) TxCpltCallback     : Tx Transfer completed callback.
69
    (+) TxCpltCallback     : Tx Transfer completed callback.
70
    (+) ErrorCallback      : callback for error detection.
70
    (+) ErrorCallback      : callback for error detection.
71
    (+) MspInitCallback    : CEC MspInit.
71
    (+) MspInitCallback    : CEC MspInit.
72
    (+) MspDeInitCallback  : CEC MspDeInit.
72
    (+) MspDeInitCallback  : CEC MspDeInit.
73
 
73
 
74
  For callback HAL_CEC_RxCpltCallback use dedicated unregister callback :
74
  For callback HAL_CEC_RxCpltCallback use dedicated unregister callback :
75
  @ref HAL_CEC_UnRegisterRxCpltCallback().
75
  HAL_CEC_UnRegisterRxCpltCallback().
76
 
76
 
77
  By default, after the @ref HAL_CEC_Init() and when the state is HAL_CEC_STATE_RESET
77
  By default, after the HAL_CEC_Init() and when the state is HAL_CEC_STATE_RESET
78
  all callbacks are set to the corresponding weak functions :
78
  all callbacks are set to the corresponding weak functions :
79
  examples @ref HAL_CEC_TxCpltCallback() , @ref HAL_CEC_RxCpltCallback().
79
  examples HAL_CEC_TxCpltCallback() , HAL_CEC_RxCpltCallback().
80
  Exception done for MspInit and MspDeInit functions that are
80
  Exception done for MspInit and MspDeInit functions that are
81
  reset to the legacy weak function in the @ref HAL_CEC_Init()/ @ref HAL_CEC_DeInit() only when
81
  reset to the legacy weak function in the HAL_CEC_Init()/ HAL_CEC_DeInit() only when
82
  these callbacks are null (not registered beforehand).
82
  these callbacks are null (not registered beforehand).
83
  if not, MspInit or MspDeInit are not null, the @ref HAL_CEC_Init() / @ref HAL_CEC_DeInit()
83
  if not, MspInit or MspDeInit are not null, the HAL_CEC_Init() / HAL_CEC_DeInit()
84
  keep and use the user MspInit/MspDeInit functions (registered beforehand)
84
  keep and use the user MspInit/MspDeInit functions (registered beforehand)
85
 
85
 
86
  Callbacks can be registered/unregistered in HAL_CEC_STATE_READY state only.
86
  Callbacks can be registered/unregistered in HAL_CEC_STATE_READY state only.
87
  Exception done MspInit/MspDeInit callbacks that can be registered/unregistered
87
  Exception done MspInit/MspDeInit callbacks that can be registered/unregistered
88
  in HAL_CEC_STATE_READY or HAL_CEC_STATE_RESET state,
88
  in HAL_CEC_STATE_READY or HAL_CEC_STATE_RESET state,
89
  thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
89
  thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
90
  In that case first register the MspInit/MspDeInit user callbacks
90
  In that case first register the MspInit/MspDeInit user callbacks
91
  using @ref HAL_CEC_RegisterCallback() before calling @ref HAL_CEC_DeInit()
91
  using HAL_CEC_RegisterCallback() before calling HAL_CEC_DeInit()
92
  or @ref HAL_CEC_Init() function.
92
  or HAL_CEC_Init() function.
93
 
93
 
94
  When the compilation define USE_HAL_CEC_REGISTER_CALLBACKS is set to 0 or
94
  When the compilation define USE_HAL_CEC_REGISTER_CALLBACKS is set to 0 or
95
  not defined, the callback registration feature is not available and all callbacks
95
  not defined, the callback registration feature is not available and all callbacks
96
  are set to the corresponding weak functions.
96
  are set to the corresponding weak functions.
97
  @endverbatim
97
  @endverbatim
Line 694... Line 694...
694
  * @retval HAL status
694
  * @retval HAL status
695
  */
695
  */
696
HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress, uint8_t DestinationAddress,
696
HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress, uint8_t DestinationAddress,
697
                                      uint8_t *pData, uint32_t Size)
697
                                      uint8_t *pData, uint32_t Size)
698
{
698
{
699
  /* if the IP isn't already busy and if there is no previous transmission
699
  /* if the peripheral isn't already busy and if there is no previous transmission
700
     already pending due to arbitration lost */
700
     already pending due to arbitration lost */
701
  if (hcec->gState == HAL_CEC_STATE_READY)
701
  if (hcec->gState == HAL_CEC_STATE_READY)
702
  {
702
  {
703
    if ((pData == NULL) && (Size > 0U))
703
    if ((pData == NULL) && (Size > 0U))
704
    {
704
    {
Line 820... Line 820...
820
 
820
 
821
  /* ----------------------------Tx Management----------------------------------*/
821
  /* ----------------------------Tx Management----------------------------------*/
822
  /* CEC TX byte request interrupt ------------------------------------------------*/
822
  /* CEC TX byte request interrupt ------------------------------------------------*/
823
  if ((reg & CEC_FLAG_TXBR) != 0U)
823
  if ((reg & CEC_FLAG_TXBR) != 0U)
824
  {
824
  {
-
 
825
    --hcec->TxXferCount;
825
    if (hcec->TxXferCount == 0U)
826
    if (hcec->TxXferCount == 0U)
826
    {
827
    {
827
      /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */
828
      /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */
828
      __HAL_CEC_LAST_BYTE_TX_SET(hcec);
829
      __HAL_CEC_LAST_BYTE_TX_SET(hcec);
829
      hcec->Instance->TXDR = *hcec->pTxBuffPtr;
-
 
830
      hcec->pTxBuffPtr++;
-
 
831
    }
-
 
832
    else
-
 
833
    {
-
 
834
      hcec->Instance->TXDR = *hcec->pTxBuffPtr;
-
 
835
      hcec->pTxBuffPtr++;
-
 
836
      hcec->TxXferCount--;
-
 
837
    }
830
    }
-
 
831
    /* In all cases transmit the byte */
-
 
832
    hcec->Instance->TXDR = *hcec->pTxBuffPtr;
-
 
833
    hcec->pTxBuffPtr++;
838
    /* clear Tx-Byte request flag */
834
    /* clear Tx-Byte request flag */
839
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXBR);
835
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXBR);
840
  }
836
  }
841
 
837
 
842
  /* CEC TX end interrupt ------------------------------------------------*/
838
  /* CEC TX end interrupt ------------------------------------------------*/