f6086ace78f7b0fc9a60f82d15f1a8c041056792
[mTask.git] / int / com / lib / STM32F7xx_HAL_Driver / Src / stm32f7xx_hal_cec.c
1 /**
2 ******************************************************************************
3 * @file stm32f7xx_hal_cec.c
4 * @author MCD Application Team
5 * @version V1.1.0
6 * @date 22-April-2016
7 * @brief CEC HAL module driver.
8 * This file provides firmware functions to manage the following
9 * functionalities of the High Definition Multimedia Interface
10 * Consumer Electronics Control Peripheral (CEC).
11 * + Initialization and de-initialization function
12 * + IO operation function
13 * + Peripheral Control function
14 *
15 *
16 @verbatim
17 ===============================================================================
18 ##### How to use this driver #####
19 ===============================================================================
20 [..]
21 The CEC HAL driver can be used as follow:
22
23 (#) Declare a CEC_HandleTypeDef handle structure.
24 (#) Initialize the CEC low level resources by implementing the HAL_CEC_MspInit ()API:
25 (##) Enable the CEC interface clock.
26 (##) CEC pins configuration:
27 (+++) Enable the clock for the CEC GPIOs.
28 (+++) Configure these CEC pins as alternate function pull-up.
29 (##) NVIC configuration if you need to use interrupt process (HAL_CEC_Transmit_IT()
30 and HAL_CEC_Receive_IT() APIs):
31 (+++) Configure the CEC interrupt priority.
32 (+++) Enable the NVIC CEC IRQ handle.
33 (+++) The specific CEC interrupts (Transmission complete interrupt,
34 RXNE interrupt and Error Interrupts) will be managed using the macros
35 __HAL_CEC_ENABLE_IT() and __HAL_CEC_DISABLE_IT() inside the transmit
36 and receive process.
37
38 (#) Program the Signal Free Time (SFT) and SFT option, Tolerance, reception stop in
39 in case of Bit Rising Error, Error-Bit generation conditions, device logical
40 address and Listen mode in the hcec Init structure.
41
42 (#) Initialize the CEC registers by calling the HAL_CEC_Init() API.
43
44 [..]
45 (@) This API (HAL_CEC_Init()) configures also the low level Hardware (GPIO, CLOCK, CORTEX...etc)
46 by calling the customed HAL_CEC_MspInit() API.
47
48 @endverbatim
49 ******************************************************************************
50 * @attention
51 *
52 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
53 *
54 * Redistribution and use in source and binary forms, with or without modification,
55 * are permitted provided that the following conditions are met:
56 * 1. Redistributions of source code must retain the above copyright notice,
57 * this list of conditions and the following disclaimer.
58 * 2. Redistributions in binary form must reproduce the above copyright notice,
59 * this list of conditions and the following disclaimer in the documentation
60 * and/or other materials provided with the distribution.
61 * 3. Neither the name of STMicroelectronics nor the names of its contributors
62 * may be used to endorse or promote products derived from this software
63 * without specific prior written permission.
64 *
65 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
66 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
71 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
72 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
73 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
74 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75 *
76 ******************************************************************************
77 */
78
79 /* Includes ------------------------------------------------------------------*/
80 #include "stm32f7xx_hal.h"
81
82 /** @addtogroup STM32F7xx_HAL_Driver
83 * @{
84 */
85
86 /** @defgroup CEC CEC
87 * @brief HAL CEC module driver
88 * @{
89 */
90 #ifdef HAL_CEC_MODULE_ENABLED
91
92 /* Private typedef -----------------------------------------------------------*/
93 /* Private define ------------------------------------------------------------*/
94 /** @defgroup CEC_Private_Constants CEC Private Constants
95 * @{
96 */
97 /**
98 * @}
99 */
100
101 /* Private macro -------------------------------------------------------------*/
102 /* Private variables ---------------------------------------------------------*/
103 /* Private function prototypes -----------------------------------------------*/
104 /** @defgroup CEC_Private_Functions CEC Private Functions
105 * @{
106 */
107 /**
108 * @}
109 */
110
111 /* Exported functions ---------------------------------------------------------*/
112
113 /** @defgroup CEC_Exported_Functions CEC Exported Functions
114 * @{
115 */
116
117 /** @defgroup CEC_Exported_Functions_Group1 Initialization and de-initialization functions
118 * @brief Initialization and Configuration functions
119 *
120 @verbatim
121 ===============================================================================
122 ##### Initialization and Configuration functions #####
123 ===============================================================================
124 [..]
125 This subsection provides a set of functions allowing to initialize the CEC
126 (+) The following parameters need to be configured:
127 (++) SignalFreeTime
128 (++) Tolerance
129 (++) BRERxStop (RX stopped or not upon Bit Rising Error)
130 (++) BREErrorBitGen (Error-Bit generation in case of Bit Rising Error)
131 (++) LBPEErrorBitGen (Error-Bit generation in case of Long Bit Period Error)
132 (++) BroadcastMsgNoErrorBitGen (Error-bit generation in case of broadcast message error)
133 (++) SignalFreeTimeOption (SFT Timer start definition)
134 (++) OwnAddress (CEC device address)
135 (++) ListenMode
136
137 @endverbatim
138 * @{
139 */
140
141 /**
142 * @brief Initializes the CEC mode according to the specified
143 * parameters in the CEC_InitTypeDef and creates the associated handle .
144 * @param hcec: CEC handle
145 * @retval HAL status
146 */
147 HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec)
148 {
149 /* Check the CEC handle allocation */
150 if((hcec == NULL) ||(hcec->Init.RxBuffer == NULL))
151 {
152 return HAL_ERROR;
153 }
154
155 /* Check the parameters */
156 assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance));
157 assert_param(IS_CEC_SIGNALFREETIME(hcec->Init.SignalFreeTime));
158 assert_param(IS_CEC_TOLERANCE(hcec->Init.Tolerance));
159 assert_param(IS_CEC_BRERXSTOP(hcec->Init.BRERxStop));
160 assert_param(IS_CEC_BREERRORBITGEN(hcec->Init.BREErrorBitGen));
161 assert_param(IS_CEC_LBPEERRORBITGEN(hcec->Init.LBPEErrorBitGen));
162 assert_param(IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(hcec->Init.BroadcastMsgNoErrorBitGen));
163 assert_param(IS_CEC_SFTOP(hcec->Init.SignalFreeTimeOption));
164 assert_param(IS_CEC_LISTENING_MODE(hcec->Init.ListenMode));
165 assert_param(IS_CEC_OWN_ADDRESS(hcec->Init.OwnAddress));
166
167 if(hcec->gState == HAL_CEC_STATE_RESET)
168 {
169 /* Allocate lock resource and initialize it */
170 hcec->Lock = HAL_UNLOCKED;
171 /* Init the low level hardware : GPIO, CLOCK */
172 HAL_CEC_MspInit(hcec);
173 }
174 hcec->gState = HAL_CEC_STATE_BUSY;
175
176 /* Disable the Peripheral */
177 __HAL_CEC_DISABLE(hcec);
178
179 /* Write to CEC Control Register */
180 hcec->Instance->CFGR = hcec->Init.SignalFreeTime | hcec->Init.Tolerance | hcec->Init.BRERxStop|\
181 hcec->Init.BREErrorBitGen | hcec->Init.LBPEErrorBitGen | hcec->Init.BroadcastMsgNoErrorBitGen |\
182 hcec->Init.SignalFreeTimeOption |((uint32_t)(hcec->Init.OwnAddress)<<16U) |\
183 hcec->Init.ListenMode;
184
185 /* Enable the following CEC Transmission/Reception interrupts as
186 * well as the following CEC Transmission/Reception Errors interrupts
187 * Rx Byte Received IT
188 * End of Reception IT
189 * Rx overrun
190 * Rx bit rising error
191 * Rx short bit period error
192 * Rx long bit period error
193 * Rx missing acknowledge
194 * Tx Byte Request IT
195 * End of Transmission IT
196 * Tx Missing Acknowledge IT
197 * Tx-Error IT
198 * Tx-Buffer Underrun IT
199 * Tx arbitration lost */
200 __HAL_CEC_ENABLE_IT(hcec, CEC_IT_RXBR|CEC_IT_RXEND|CEC_IER_RX_ALL_ERR|CEC_IT_TXBR|CEC_IT_TXEND|CEC_IER_TX_ALL_ERR);
201
202 /* Enable the CEC Peripheral */
203 __HAL_CEC_ENABLE(hcec);
204
205 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
206 hcec->gState = HAL_CEC_STATE_READY;
207 hcec->RxState = HAL_CEC_STATE_READY;
208
209 return HAL_OK;
210 }
211
212 /**
213 * @brief DeInitializes the CEC peripheral
214 * @param hcec: CEC handle
215 * @retval HAL status
216 */
217 HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec)
218 {
219 /* Check the CEC handle allocation */
220 if(hcec == NULL)
221 {
222 return HAL_ERROR;
223 }
224
225 /* Check the parameters */
226 assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance));
227
228 hcec->gState = HAL_CEC_STATE_BUSY;
229
230 /* DeInit the low level hardware */
231 HAL_CEC_MspDeInit(hcec);
232
233 /* Disable the Peripheral */
234 __HAL_CEC_DISABLE(hcec);
235
236 /* Clear Flags */
237 __HAL_CEC_CLEAR_FLAG(hcec,CEC_FLAG_TXEND|CEC_FLAG_TXBR|CEC_FLAG_RXBR|CEC_FLAG_RXEND|CEC_ISR_ALL_ERROR);
238
239 /* Disable the following CEC Transmission/Reception interrupts as
240 * well as the following CEC Transmission/Reception Errors interrupts
241 * Rx Byte Received IT
242 * End of Reception IT
243 * Rx overrun
244 * Rx bit rising error
245 * Rx short bit period error
246 * Rx long bit period error
247 * Rx missing acknowledge
248 * Tx Byte Request IT
249 * End of Transmission IT
250 * Tx Missing Acknowledge IT
251 * Tx-Error IT
252 * Tx-Buffer Underrun IT
253 * Tx arbitration lost */
254 __HAL_CEC_DISABLE_IT(hcec, CEC_IT_RXBR|CEC_IT_RXEND|CEC_IER_RX_ALL_ERR|CEC_IT_TXBR|CEC_IT_TXEND|CEC_IER_TX_ALL_ERR);
255
256 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
257 hcec->gState = HAL_CEC_STATE_RESET;
258 hcec->RxState = HAL_CEC_STATE_RESET;
259
260 /* Process Unlock */
261 __HAL_UNLOCK(hcec);
262
263 return HAL_OK;
264 }
265
266 /**
267 * @brief Initializes the Own Address of the CEC device
268 * @param hcec: CEC handle
269 * @param CEC_OwnAddress: The CEC own address.
270 * @retval HAL status
271 */
272 HAL_StatusTypeDef HAL_CEC_SetDeviceAddress(CEC_HandleTypeDef *hcec, uint16_t CEC_OwnAddress)
273 {
274 /* Check the parameters */
275 assert_param(IS_CEC_OWN_ADDRESS(CEC_OwnAddress));
276
277 if ((hcec->gState == HAL_CEC_STATE_READY) && (hcec->RxState == HAL_CEC_STATE_READY))
278 {
279 /* Process Locked */
280 __HAL_LOCK(hcec);
281
282 hcec->gState = HAL_CEC_STATE_BUSY;
283
284 /* Disable the Peripheral */
285 __HAL_CEC_DISABLE(hcec);
286
287 if(CEC_OwnAddress != CEC_OWN_ADDRESS_NONE)
288 {
289 hcec->Instance->CFGR |= ((uint32_t)CEC_OwnAddress<<16);
290 }
291 else
292 {
293 hcec->Instance->CFGR &= ~(CEC_CFGR_OAR);
294 }
295
296 hcec->gState = HAL_CEC_STATE_READY;
297 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
298
299 /* Process Unlocked */
300 __HAL_UNLOCK(hcec);
301
302 /* Enable the Peripheral */
303 __HAL_CEC_ENABLE(hcec);
304
305 return HAL_OK;
306 }
307 else
308 {
309 return HAL_BUSY;
310 }
311 }
312
313 /**
314 * @brief CEC MSP Init
315 * @param hcec: CEC handle
316 * @retval None
317 */
318 __weak void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec)
319 {
320 /* Prevent unused argument(s) compilation warning */
321 UNUSED(hcec);
322 /* NOTE : This function should not be modified, when the callback is needed,
323 the HAL_CEC_MspInit can be implemented in the user file
324 */
325 }
326
327 /**
328 * @brief CEC MSP DeInit
329 * @param hcec: CEC handle
330 * @retval None
331 */
332 __weak void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec)
333 {
334 /* Prevent unused argument(s) compilation warning */
335 UNUSED(hcec);
336 /* NOTE : This function should not be modified, when the callback is needed,
337 the HAL_CEC_MspDeInit can be implemented in the user file
338 */
339 }
340
341 /**
342 * @}
343 */
344
345 /** @defgroup CEC_Exported_Functions_Group2 Input and Output operation functions
346 * @brief CEC Transmit/Receive functions
347 *
348 @verbatim
349 ===============================================================================
350 ##### IO operation functions #####
351 ===============================================================================
352 This subsection provides a set of functions allowing to manage the CEC data transfers.
353
354 (#) The CEC handle must contain the initiator (TX side) and the destination (RX side)
355 logical addresses (4-bit long addresses, 0xF for broadcast messages destination)
356
357 (#) The communication is performed using Interrupts.
358 These API's return the HAL status.
359 The end of the data processing will be indicated through the
360 dedicated CEC IRQ when using Interrupt mode.
361 The HAL_CEC_TxCpltCallback(), HAL_CEC_RxCpltCallback() user callbacks
362 will be executed respectively at the end of the transmit or Receive process
363 The HAL_CEC_ErrorCallback() user callback will be executed when a communication
364 error is detected
365
366 (#) API's with Interrupt are :
367 (+) HAL_CEC_Transmit_IT()
368 (+) HAL_CEC_IRQHandler()
369
370 (#) A set of User Callbacks are provided:
371 (+) HAL_CEC_TxCpltCallback()
372 (+) HAL_CEC_RxCpltCallback()
373 (+) HAL_CEC_ErrorCallback()
374
375 @endverbatim
376 * @{
377 */
378
379 /**
380 * @brief Send data in interrupt mode
381 * @param hcec: CEC handle
382 * @param InitiatorAddress: Initiator address
383 * @param DestinationAddress: destination logical address
384 * @param pData: pointer to input byte data buffer
385 * @param Size: amount of data to be sent in bytes (without counting the header).
386 * 0 means only the header is sent (ping operation).
387 * Maximum TX size is 15 bytes (1 opcode and up to 14 operands).
388 * @retval HAL status
389 */
390 HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t InitiatorAddress,uint8_t DestinationAddress, uint8_t *pData, uint32_t Size)
391 {
392 /* if the IP isn't already busy and if there is no previous transmission
393 already pending due to arbitration lost */
394 if (hcec->gState == HAL_CEC_STATE_READY)
395 {
396 if((pData == NULL ) && (Size > 0))
397 {
398 return HAL_ERROR;
399 }
400
401 assert_param(IS_CEC_ADDRESS(DestinationAddress));
402 assert_param(IS_CEC_ADDRESS(InitiatorAddress));
403 assert_param(IS_CEC_MSGSIZE(Size));
404
405 /* Process Locked */
406 __HAL_LOCK(hcec);
407 hcec->pTxBuffPtr = pData;
408 hcec->gState = HAL_CEC_STATE_BUSY_TX;
409 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
410
411 /* initialize the number of bytes to send,
412 * 0 means only one header is sent (ping operation) */
413 hcec->TxXferCount = Size;
414
415 /* in case of no payload (Size = 0), sender is only pinging the system;
416 Set TX End of Message (TXEOM) bit, must be set before writing data to TXDR */
417 if (Size == 0)
418 {
419 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
420 }
421 /* send header block */
422 hcec->Instance->TXDR = ((uint8_t)(InitiatorAddress << CEC_INITIATOR_LSB_POS) |(uint8_t) DestinationAddress);
423 /* Set TX Start of Message (TXSOM) bit */
424 __HAL_CEC_FIRST_BYTE_TX_SET(hcec);
425
426 /* Process Unlocked */
427 __HAL_UNLOCK(hcec);
428
429 return HAL_OK;
430
431 }
432 else
433 {
434 return HAL_BUSY;
435 }
436 }
437
438 /**
439 * @brief Get size of the received frame.
440 * @param hcec: CEC handle
441 * @retval Frame size
442 */
443 uint32_t HAL_CEC_GetLastReceivedFrameSize(CEC_HandleTypeDef *hcec)
444 {
445 return hcec->RxXferSize;
446 }
447
448 /**
449 * @brief Change Rx Buffer.
450 * @param hcec: CEC handle
451 * @param Rxbuffer: Rx Buffer
452 * @note This function can be called only inside the HAL_CEC_RxCpltCallback()
453 * @retval Frame size
454 */
455 void HAL_CEC_ChangeRxBuffer(CEC_HandleTypeDef *hcec, uint8_t* Rxbuffer)
456 {
457 hcec->Init.RxBuffer = Rxbuffer;
458 }
459
460 /**
461 * @brief This function handles CEC interrupt requests.
462 * @param hcec: CEC handle
463 * @retval None
464 */
465 void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec)
466 {
467
468 /* save interrupts register for further error or interrupts handling purposes */
469 uint32_t reg = 0;
470 reg = hcec->Instance->ISR;
471
472
473 /* ----------------------------Arbitration Lost Management----------------------------------*/
474 /* CEC TX arbitration error interrupt occurred --------------------------------------*/
475 if((reg & CEC_FLAG_ARBLST) != RESET)
476 {
477 hcec->ErrorCode = HAL_CEC_ERROR_ARBLST;
478 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_ARBLST);
479 }
480
481 /* ----------------------------Rx Management----------------------------------*/
482 /* CEC RX byte received interrupt ---------------------------------------------------*/
483 if((reg & CEC_FLAG_RXBR) != RESET)
484 {
485 /* reception is starting */
486 hcec->RxState = HAL_CEC_STATE_BUSY_RX;
487 hcec->RxXferSize++;
488 /* read received byte */
489 *hcec->Init.RxBuffer++ = hcec->Instance->RXDR;
490 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RXBR);
491 }
492
493 /* CEC RX end received interrupt ---------------------------------------------------*/
494 if((reg & CEC_FLAG_RXEND) != RESET)
495 {
496 /* clear IT */
497 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RXEND);
498
499 /* Rx process is completed, restore hcec->RxState to Ready */
500 hcec->RxState = HAL_CEC_STATE_READY;
501 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
502 hcec->Init.RxBuffer-=hcec->RxXferSize;
503 HAL_CEC_RxCpltCallback(hcec, hcec->RxXferSize);
504 hcec->RxXferSize = 0;
505 }
506
507 /* ----------------------------Tx Management----------------------------------*/
508 /* CEC TX byte request interrupt ------------------------------------------------*/
509 if((reg & CEC_FLAG_TXBR) != RESET)
510 {
511 if (hcec->TxXferCount == 0)
512 {
513 /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */
514 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
515 hcec->Instance->TXDR = *hcec->pTxBuffPtr++;
516 }
517 else
518 {
519 hcec->Instance->TXDR = *hcec->pTxBuffPtr++;
520 hcec->TxXferCount--;
521 }
522 /* clear Tx-Byte request flag */
523 __HAL_CEC_CLEAR_FLAG(hcec,CEC_FLAG_TXBR);
524 }
525
526 /* CEC TX end interrupt ------------------------------------------------*/
527 if((reg & CEC_FLAG_TXEND) != RESET)
528 {
529 __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXEND);
530
531 /* Tx process is ended, restore hcec->gState to Ready */
532 hcec->gState = HAL_CEC_STATE_READY;
533 /* Call the Process Unlocked before calling the Tx call back API to give the possibility to
534 start again the Transmission under the Tx call back API */
535 __HAL_UNLOCK(hcec);
536 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
537 HAL_CEC_TxCpltCallback(hcec);
538 }
539
540 /* ----------------------------Rx/Tx Error Management----------------------------------*/
541 if ((reg & (CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE|CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)) != 0)
542 {
543 hcec->ErrorCode = reg;
544 __HAL_CEC_CLEAR_FLAG(hcec, HAL_CEC_ERROR_RXOVR|HAL_CEC_ERROR_BRE|CEC_FLAG_LBPE|CEC_FLAG_SBPE|HAL_CEC_ERROR_RXACKE|HAL_CEC_ERROR_TXUDR|HAL_CEC_ERROR_TXERR|HAL_CEC_ERROR_TXACKE);
545
546
547 if((reg & (CEC_ISR_RXOVR|CEC_ISR_BRE|CEC_ISR_SBPE|CEC_ISR_LBPE|CEC_ISR_RXACKE)) != RESET)
548 {
549 hcec->Init.RxBuffer-=hcec->RxXferSize;
550 hcec->RxXferSize = 0;
551 hcec->RxState = HAL_CEC_STATE_READY;
552 }
553 else if (((reg & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)) != RESET) && ((reg & CEC_ISR_ARBLST) == RESET))
554 {
555 /* Set the CEC state ready to be able to start again the process */
556 hcec->gState = HAL_CEC_STATE_READY;
557 }
558
559 /* Error Call Back */
560 HAL_CEC_ErrorCallback(hcec);
561 }
562
563 }
564
565 /**
566 * @brief Tx Transfer completed callback
567 * @param hcec: CEC handle
568 * @retval None
569 */
570 __weak void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec)
571 {
572 /* Prevent unused argument(s) compilation warning */
573 UNUSED(hcec);
574 /* NOTE : This function should not be modified, when the callback is needed,
575 the HAL_CEC_TxCpltCallback can be implemented in the user file
576 */
577 }
578
579 /**
580 * @brief Rx Transfer completed callback
581 * @param hcec: CEC handle
582 * @param RxFrameSize: Size of frame
583 * @retval None
584 */
585 __weak void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec, uint32_t RxFrameSize)
586 {
587 /* Prevent unused argument(s) compilation warning */
588 UNUSED(hcec);
589 UNUSED(RxFrameSize);
590 /* NOTE : This function should not be modified, when the callback is needed,
591 the HAL_CEC_RxCpltCallback can be implemented in the user file
592 */
593 }
594
595 /**
596 * @brief CEC error callbacks
597 * @param hcec: CEC handle
598 * @retval None
599 */
600 __weak void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec)
601 {
602 /* Prevent unused argument(s) compilation warning */
603 UNUSED(hcec);
604 /* NOTE : This function should not be modified, when the callback is needed,
605 the HAL_CEC_ErrorCallback can be implemented in the user file
606 */
607 }
608 /**
609 * @}
610 */
611
612 /** @defgroup CEC_Exported_Functions_Group3 Peripheral Control function
613 * @brief CEC control functions
614 *
615 @verbatim
616 ===============================================================================
617 ##### Peripheral Control function #####
618 ===============================================================================
619 [..]
620 This subsection provides a set of functions allowing to control the CEC.
621 (+) HAL_CEC_GetState() API can be helpful to check in run-time the state of the CEC peripheral.
622 (+) HAL_CEC_GetError() API can be helpful to check in run-time the error of the CEC peripheral.
623 @endverbatim
624 * @{
625 */
626 /**
627 * @brief return the CEC state
628 * @param hcec: pointer to a CEC_HandleTypeDef structure that contains
629 * the configuration information for the specified CEC module.
630 * @retval HAL state
631 */
632 HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec)
633 {
634 uint32_t temp1= 0x00U, temp2 = 0x00U;
635 temp1 = hcec->gState;
636 temp2 = hcec->RxState;
637
638 return (HAL_CEC_StateTypeDef)(temp1 | temp2);
639 }
640
641 /**
642 * @brief Return the CEC error code
643 * @param hcec : pointer to a CEC_HandleTypeDef structure that contains
644 * the configuration information for the specified CEC.
645 * @retval CEC Error Code
646 */
647 uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec)
648 {
649 return hcec->ErrorCode;
650 }
651
652 /**
653 * @}
654 */
655
656 /**
657 * @}
658 */
659 #endif /* HAL_CEC_MODULE_ENABLED */
660 /**
661 * @}
662 */
663
664 /**
665 * @}
666 */
667
668 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/