Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 6 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | ============================================= |
80 | ============================================= |
81 | [..] |
81 | [..] |
82 | 82 | ||
83 | The compilation flag USE_HAL_COMP_REGISTER_CALLBACKS, when set to 1, |
83 | The compilation flag USE_HAL_COMP_REGISTER_CALLBACKS, when set to 1, |
84 | allows the user to configure dynamically the driver callbacks. |
84 | allows the user to configure dynamically the driver callbacks. |
85 | Use Functions @ref HAL_COMP_RegisterCallback() |
85 | Use Functions HAL_COMP_RegisterCallback() |
86 | to register an interrupt callback. |
86 | to register an interrupt callback. |
87 | [..] |
87 | [..] |
88 | 88 | ||
89 | Function @ref HAL_COMP_RegisterCallback() allows to register following callbacks: |
89 | Function HAL_COMP_RegisterCallback() allows to register following callbacks: |
90 | (+) OperationCpltCallback : callback for End of operation. |
90 | (+) OperationCpltCallback : callback for End of operation. |
91 | (+) ErrorCallback : callback for error detection. |
91 | (+) ErrorCallback : callback for error detection. |
92 | (+) MspInitCallback : callback for Msp Init. |
92 | (+) MspInitCallback : callback for Msp Init. |
93 | (+) MspDeInitCallback : callback for Msp DeInit. |
93 | (+) MspDeInitCallback : callback for Msp DeInit. |
94 | This function takes as parameters the HAL peripheral handle, the Callback ID |
94 | This function takes as parameters the HAL peripheral handle, the Callback ID |
95 | and a pointer to the user callback function. |
95 | and a pointer to the user callback function. |
96 | [..] |
96 | [..] |
97 | 97 | ||
98 | Use function @ref HAL_COMP_UnRegisterCallback to reset a callback to the default |
98 | Use function HAL_COMP_UnRegisterCallback to reset a callback to the default |
99 | weak function. |
99 | weak function. |
100 | [..] |
100 | [..] |
101 | 101 | ||
102 | @ref HAL_COMP_UnRegisterCallback takes as parameters the HAL peripheral handle, |
102 | HAL_COMP_UnRegisterCallback takes as parameters the HAL peripheral handle, |
103 | and the Callback ID. |
103 | and the Callback ID. |
104 | This function allows to reset following callbacks: |
104 | This function allows to reset following callbacks: |
105 | (+) OperationCpltCallback : callback for End of operation. |
105 | (+) OperationCpltCallback : callback for End of operation. |
106 | (+) ErrorCallback : callback for error detection. |
106 | (+) ErrorCallback : callback for error detection. |
107 | (+) MspInitCallback : callback for Msp Init. |
107 | (+) MspInitCallback : callback for Msp Init. |
108 | (+) MspDeInitCallback : callback for Msp DeInit. |
108 | (+) MspDeInitCallback : callback for Msp DeInit. |
109 | [..] |
109 | [..] |
110 | 110 | ||
111 | By default, after the @ref HAL_COMP_Init() and when the state is @ref HAL_COMP_STATE_RESET |
111 | By default, after the HAL_COMP_Init() and when the state is HAL_COMP_STATE_RESET |
112 | all callbacks are set to the corresponding weak functions: |
112 | all callbacks are set to the corresponding weak functions: |
113 | examples @ref HAL_COMP_OperationCpltCallback(), @ref HAL_COMP_ErrorCallback(). |
113 | examples HAL_COMP_OperationCpltCallback(), HAL_COMP_ErrorCallback(). |
114 | Exception done for MspInit and MspDeInit functions that are |
114 | Exception done for MspInit and MspDeInit functions that are |
115 | reset to the legacy weak functions in the @ref HAL_COMP_Init()/ @ref HAL_COMP_DeInit() only when |
115 | reset to the legacy weak functions in the HAL_COMP_Init()/ HAL_COMP_DeInit() only when |
116 | these callbacks are null (not registered beforehand). |
116 | these callbacks are null (not registered beforehand). |
117 | [..] |
117 | [..] |
118 | 118 | ||
119 | If MspInit or MspDeInit are not null, the @ref HAL_COMP_Init()/ @ref HAL_COMP_DeInit() |
119 | If MspInit or MspDeInit are not null, the HAL_COMP_Init()/ HAL_COMP_DeInit() |
120 | keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. |
120 | keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. |
121 | [..] |
121 | [..] |
122 | 122 | ||
123 | Callbacks can be registered/unregistered in @ref HAL_COMP_STATE_READY state only. |
123 | Callbacks can be registered/unregistered in HAL_COMP_STATE_READY state only. |
124 | Exception done MspInit/MspDeInit functions that can be registered/unregistered |
124 | Exception done MspInit/MspDeInit functions that can be registered/unregistered |
125 | in @ref HAL_COMP_STATE_READY or @ref HAL_COMP_STATE_RESET state, |
125 | in HAL_COMP_STATE_READY or HAL_COMP_STATE_RESET state, |
126 | thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. |
126 | thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. |
127 | [..] |
127 | [..] |
128 | 128 | ||
129 | Then, the user first registers the MspInit/MspDeInit user callbacks |
129 | Then, the user first registers the MspInit/MspDeInit user callbacks |
130 | using @ref HAL_COMP_RegisterCallback() before calling @ref HAL_COMP_DeInit() |
130 | using HAL_COMP_RegisterCallback() before calling HAL_COMP_DeInit() |
131 | or @ref HAL_COMP_Init() function. |
131 | or HAL_COMP_Init() function. |
132 | [..] |
132 | [..] |
133 | 133 | ||
134 | When the compilation flag USE_HAL_COMP_REGISTER_CALLBACKS is set to 0 or |
134 | When the compilation flag USE_HAL_COMP_REGISTER_CALLBACKS is set to 0 or |
135 | not defined, the callback registration feature is not available and all callbacks |
135 | not defined, the callback registration feature is not available and all callbacks |
136 | are set to the corresponding weak functions. |
136 | are set to the corresponding weak functions. |