PageRenderTime 58ms CodeModel.GetById 11ms app.highlight 39ms RepoModel.GetById 1ms app.codeStats 0ms

/src/common/STM32F10x/Utilities/STM32_EVAL/STM32100B_EVAL/stm32100b_eval_cec.c

https://github.com/denisacostaq/firmware-stm3210fx2
C | 1721 lines | 1057 code | 327 blank | 337 comment | 315 complexity | 6035e5bf28f080a4206cccb3040ad6e6 MD5 | raw file
   1/**
   2  ******************************************************************************
   3  * @file    stm32100b_eval_cec.c
   4  * @author  MCD Application Team
   5  * @version V4.1.0
   6  * @date    03/01/2010
   7  * @brief   This file provides all the STM32100B-EVAL HDMI-CEC firmware functions.
   8  ******************************************************************************
   9  * @copy
  10  *
  11  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17  *
  18  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  19  */
  20
  21/* Includes ------------------------------------------------------------------*/
  22#include "stm32100b_eval_cec.h"

  23
  24/** @addtogroup Utilities
  25  * @{
  26  */
  27
  28/** @addtogroup STM32_EVAL
  29  * @{
  30  */ 
  31
  32/** @addtogroup STM32100B_EVAL
  33  * @{
  34  */
  35  
  36/** @defgroup STM32100B_EVAL_CEC
  37  * @brief This file includes the CEC Stack driver for HDMI-CEC Module
  38  *        of STM32100B-EVAL board.
  39  * @{
  40  */
  41
  42/** @defgroup STM32100B_EVAL_CEC_Private_Types
  43  * @{
  44  */
  45
  46/**
  47  * @}
  48  */
  49
  50/** @defgroup STM32100B_EVAL_CEC_Private_Defines
  51  * @{
  52  */
  53
  54
  55/**
  56  * @}
  57  */
  58
  59/** @defgroup STM32100B_EVAL_CEC_Private_Macros
  60  * @{
  61  */
  62/**
  63  * @}
  64  */
  65
  66/** @defgroup STM32100B_EVAL_CEC_Private_Variables
  67  * @{
  68  */
  69
  70__IO uint32_t ReceivedFrame = 0;
  71__IO uint32_t SendFrame = 0;
  72__IO uint32_t BufferCount = 0, TxCounter = 0, RxCounter = 0;
  73__IO uint8_t BufferPointer[15];
  74__IO uint32_t ReceiveStatus = 0;
  75__IO uint32_t SendStatus = 0;
  76__IO uint8_t TransErrorCode = 0;
  77__IO uint8_t RecepErrorCode = 0;
  78__IO uint8_t MyLogicalAddress = 0;
  79__IO uint16_t MyPhysicalAddress = 0;
  80__IO uint8_t DeviceType = 0;
  81#ifdef HDMI_CEC_USE_DDC

  82__IO uint8_t pBuffer[256];
  83__IO uint16_t NumByteToRead = 255;
  84#endif

  85__IO uint8_t CECDevicesNumber = 0;
  86
  87HDMI_CEC_Message HDMI_CEC_TX_MessageStructPrivate;
  88HDMI_CEC_Message HDMI_CEC_RX_MessageStructPrivate;
  89HDMI_CEC_Message HDMI_CEC_TX_MessageStructure;
  90
  91__IO uint8_t FeatureOpcode = 0;
  92__IO uint8_t AbortReason = 0;
  93__IO uint8_t DeviceCount = 0;
  94
  95HDMI_CEC_Map HDMI_CEC_MapStruct;
  96HDMI_CEC_Map HDMI_CEC_DeviceMap[14];
  97
  98/* CEC follower addresses */
  99uint8_t* HDMI_CEC_Follower_String[13][2] =
 100  {
 101    {"         TV         ", "0"},
 102    {"Recording Device 1  ", "0"},
 103    {"Recording Device 2  ", "0"},
 104    {"    Tuner 1         ", "0"},
 105    {" Playback Device 1  ", "0"},
 106    {"   Audio System     ", "0"},
 107    {"    Tuner 2         ", "0"},
 108    {"    Tuner 3         ", "0"},
 109    {" Playback Device 2  ", "0"},
 110    {"Recording Device 3  ", "0"},
 111    {"      Tuner 4       ", "0"},
 112    {" Playback Device 3  ", "0"},
 113    {"     Broadcast      ", "1"}
 114  };
 115
 116/**
 117  * @}
 118  */
 119
 120
 121/** @defgroup STM32100B_EVAL_CEC_Private_Function_Prototypes
 122  * @{
 123  */
 124static HDMI_CEC_Error PhysicalAddressDiscovery(void);
 125static HDMI_CEC_Error LogicalAddressAllocation(void);
 126
 127
 128/**
 129  * @}
 130  */
 131
 132
 133/** @defgroup STM32100B_EVAL_CEC_Private_Functions
 134  * @{
 135  */
 136
 137/**
 138  * @brief  Initializes the HDMI CEC.
 139  * @param  None
 140  * @retval HDMI_CEC_Error: CEC Error code
 141  */
 142HDMI_CEC_Error HDMI_CEC_Init(void)
 143{
 144  GPIO_InitTypeDef GPIO_InitStructure;
 145  CEC_InitTypeDef CEC_InitStructure;
 146  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
 147  uint8_t sendcount = 0;
 148
 149#ifdef HDMI_CEC_USE_DDC

 150  I2C_InitTypeDef  I2C_InitStructure;
 151  /* Enable CEC_I2C clocks */
 152  RCC_APB1PeriphClockCmd(HDMI_CEC_I2C_CLK, ENABLE);
 153
 154  /* Enable CEC_I2C_GPIO and CEC_HPD_GPIO clocks */
 155  RCC_APB2PeriphClockCmd(HDMI_CEC_I2C_GPIO_CLK | HDMI_CEC_HPD_GPIO_CLK, ENABLE);
 156#endif

 157
 158  /* Enable CEC clocks */
 159  RCC_APB1PeriphClockCmd(RCC_APB1Periph_CEC, ENABLE);
 160
 161  /* Enable CEC_LINE_GPIO clocks */
 162  RCC_APB2PeriphClockCmd(HDMI_CEC_LINE_GPIO_CLK, ENABLE);
 163
 164  /* Configure CEC_LINE_GPIO as Output open drain */
 165  GPIO_InitStructure.GPIO_Pin = HDMI_CEC_LINE_PIN;
 166  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 167  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
 168  GPIO_Init(HDMI_CEC_LINE_GPIO_PORT, &GPIO_InitStructure);
 169
 170#ifdef HDMI_CEC_USE_DDC

 171  /* Configure CEC_I2C_SCL_PIN and CEC_I2C_SDA_PIN  as Output open drain */
 172  GPIO_InitStructure.GPIO_Pin = HDMI_CEC_I2C_SCL_PIN | HDMI_CEC_I2C_SDA_PIN;
 173  GPIO_Init(HDMI_CEC_I2C_GPIO_PORT, &GPIO_InitStructure);
 174
 175/* This configuration is only when the HDMI CEC is configured as source.
 176   The HDMI source has to provide the +5V Power signal to the sink. 
 177   On STM32100B-EVAL borad, you have to solder the SB4 Solder bridge.
 178   Then, the source will wait for HPD signal to be asserted from the sink.
 179   Once the HPD signal is detected the source shall read the EDID structure 
 180   throuhgh the DDC channel. */
 181  /* Configure CEC_HPD_GPIO as Input pull down */
 182  GPIO_InitStructure.GPIO_Pin = HDMI_CEC_HPD_PIN;
 183  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
 184  GPIO_Init(HDMI_CEC_HPD_GPIO_PORT, &GPIO_InitStructure);
 185
 186
 187/* This configuration is only when the HDMI CEC is configured as sink.
 188   The HDMI sink has to wait for the +5V Power signal from the source. 
 189   On STM32100B-EVAL borad, SB4 Solder bridge should be open (default configuration).
 190   Then, the sink will assert the HPD signal to inform the source that the EDID
 191   is ready for read through DDC channel. In this implementation, the EDID structure
 192   is not implemented. */
 193/*  GPIO_InitStructure.GPIO_Pin = HDMI_CEC_HPD_PIN;
 194  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
 195  GPIO_Init(HDMI_CEC_HPD_GPIO_PORT, &GPIO_InitStructure);
 196
 197  HDMI_CEC_HPD_HIGH(); // Set the Hot plug detect signal */
 198  
 199  /* Enable CEC_I2C */
 200  I2C_Cmd(HDMI_CEC_I2C, ENABLE);
 201
 202  /* I2C configuration */
 203  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
 204  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
 205  I2C_InitStructure.I2C_OwnAddress1 = HDMI_CEC_I2C_SLAVE_ADDRESS7;
 206  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
 207  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
 208  I2C_InitStructure.I2C_ClockSpeed = HDMI_CEC_I2C_CLOCK_SPEED;
 209  I2C_Init(HDMI_CEC_I2C, &I2C_InitStructure);
 210#endif

 211
 212  /* Physical Address discovery */
 213  errorstatus = PhysicalAddressDiscovery();
 214
 215  if (errorstatus != HDMI_CEC_OK)
 216  {
 217    /* Device not connected (Physical Address lost) */
 218    return(errorstatus);
 219  }
 220
 221
 222  /* CEC DeInit */
 223  CEC_DeInit();
 224
 225  /* Configure CEC */
 226  CEC_InitStructure.CEC_BitTimingMode = CEC_BitTimingStdMode;
 227  CEC_InitStructure.CEC_BitPeriodMode = CEC_BitPeriodStdMode;
 228  CEC_Init(&CEC_InitStructure);
 229
 230  /* Set Prescaler value for APB1 clock = 24MHz */
 231  CEC_SetPrescaler(0x4AF);
 232
 233  /* Enable CEC */
 234  CEC_Cmd(ENABLE);
 235
 236  /* Logical Address Allocation */
 237  sendcount = 0;
 238  errorstatus = LogicalAddressAllocation();
 239
 240  while ((errorstatus != HDMI_CEC_OK) && sendcount < 0x5)
 241  {
 242    sendcount++;
 243    errorstatus = LogicalAddressAllocation();
 244  }
 245
 246  if (errorstatus != HDMI_CEC_OK)
 247  {
 248    /* Device Unregistred */
 249    return(errorstatus);
 250  }
 251
 252  HDMI_CEC_CheckConnectedDevices();
 253  
 254  /* Set the CEC initiator address */
 255  CEC_OwnAddressConfig(MyLogicalAddress);
 256
 257  /* Activate CEC interrupts associated to the set of RBTF,RERR, TBTF, TERR flags */
 258  CEC_ITConfig(ENABLE);
 259
 260  /* Report physical address*/
 261  errorstatus = HDMI_CEC_ReportPhysicalAddress();
 262  sendcount = 0;
 263
 264  while ((errorstatus != HDMI_CEC_OK) && sendcount < 0x5)
 265  {
 266    sendcount++;
 267    errorstatus = HDMI_CEC_ReportPhysicalAddress();
 268  }
 269
 270  if (errorstatus != HDMI_CEC_OK)
 271  {
 272    /* Device Unregistred */
 273    return(errorstatus);
 274  }
 275
 276  return errorstatus;
 277}
 278
 279/**
 280  * @brief  Transmit message by taking  data from typedef struct CEC_Meassage
 281  * @param  CEC_TX_MessageStructure: pointer to an CEC_Message structure that contains
 282  *         the message to be sent.
 283  * @retval HDMI_CEC_Error: CEC Error code
 284  */
 285HDMI_CEC_Error HDMI_CEC_TransmitMessage(HDMI_CEC_Message *HDMI_CEC_TX_MessageStructure)
 286{
 287  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
 288  __IO uint32_t count = 0, j = 0;
 289
 290  SendFrame = 0;
 291  SendStatus = 0;
 292  TxCounter = 0;
 293  BufferCount = 0;
 294
 295  HDMI_CEC_TX_MessageStructPrivate =  *HDMI_CEC_TX_MessageStructure;
 296
 297  /* Initialize BufferPointer */
 298  for (j = 0; j < 15; j++)
 299  {
 300    BufferPointer[j] = 0;
 301  }
 302
 303  BufferPointer[0] =  HDMI_CEC_TX_MessageStructPrivate.Opcode;
 304
 305  for (BufferCount = 1; BufferCount < HDMI_CEC_TX_MessageStructPrivate.TxMessageLength + 1; BufferCount++)
 306  {
 307    BufferPointer[BufferCount] =  HDMI_CEC_TX_MessageStructPrivate.Operande[BufferCount-1];
 308  }
 309
 310  CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
 311
 312  /* Write single Data in the TX Buffer to Transmit through the CEC peripheral */
 313  CEC_SendDataByte(HDMI_CEC_TX_MessageStructPrivate.Header);
 314
 315  /* Initiate Message Transmission */
 316  CEC_StartOfMessage();
 317
 318  while ((SendFrame == 0) && (count < HDMI_CEC_TIMEOUT_VALUE))
 319  {
 320    count++;
 321  }
 322  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 323  {
 324    errorstatus = HDMI_CEC_TIMEOUT;
 325    return(errorstatus);
 326  }
 327
 328  if (SendStatus == 0)
 329  {
 330    errorstatus = (HDMI_CEC_Error) TransErrorCode;
 331  }
 332
 333  return errorstatus;
 334}
 335
 336
 337/**
 338  * @brief  Get the ESR register status.
 339  * @param  None
 340  * @retval HDMI_CEC_Error: CEC Error code
 341  */
 342HDMI_CEC_Error HDMI_CEC_GetErrorStatus (void)
 343{
 344  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
 345
 346  /* Bit timing error case*/
 347  if (CEC_GetFlagStatus(CEC_FLAG_BTE) != RESET)
 348  {
 349    errorstatus = HDMI_CEC_BIT_TIMING;
 350  }
 351  /* Bit period error case */
 352  if (CEC_GetFlagStatus(CEC_FLAG_BPE) != RESET)
 353  {
 354    errorstatus = HDMI_CEC_BIT_PERIOD;
 355  }
 356  /* Recieve error case */
 357  if (CEC_GetFlagStatus(CEC_FLAG_RBTFE) != RESET)
 358  {
 359    errorstatus = HDMI_CEC_RX_BLOCK_FINISHED;
 360  }
 361  /* Start bit error case*/
 362  if (CEC_GetFlagStatus(CEC_FLAG_SBE) != RESET)
 363  {
 364    errorstatus = HDMI_CEC_START_BIT;
 365  }
 366  /* Acknowledge error case*/
 367  if (CEC_GetFlagStatus(CEC_FLAG_ACKE) != RESET)
 368  {
 369    errorstatus = HDMI_CEC_BLOCK_ACKNOWLEDGE;
 370  }
 371  /* Line error case */
 372  if (CEC_GetFlagStatus(CEC_FLAG_LINE) != RESET)
 373  {
 374    errorstatus = HDMI_CEC_LINE;
 375  }
 376  /* Transfert error case*/
 377  if (CEC_GetFlagStatus(CEC_FLAG_TBTFE) != RESET)
 378  {
 379    errorstatus = HDMI_CEC_TX_BLOCK_FINISHED;
 380  }
 381  /* Clear All errors */
 382  CEC_ClearFlag(CEC_FLAG_RERR);
 383  CEC_ClearFlag(CEC_FLAG_TERR);
 384  return errorstatus;
 385}
 386
 387/**
 388  * @brief  Allows to process all the interrupts that are high.
 389  * @param  None
 390  * @retval None
 391  */
 392void HDMI_CEC_ProcessIRQSrc(void)
 393{
 394  /********************** Reception *********************************************/
 395  /* Check if a reception error occured */
 396  if (CEC_GetFlagStatus(CEC_FLAG_RERR))
 397  {
 398    /* Set receive status bit (Error) */
 399    ReceiveStatus  = 0;
 400    ReceivedFrame  = 1;
 401    RecepErrorCode = HDMI_CEC_GetErrorStatus();
 402    CEC_ClearFlag(CEC_FLAG_RERR | CEC_FLAG_RSOM | CEC_FLAG_REOM  | CEC_FLAG_RBTF);
 403  }
 404  else if (CEC_GetFlagStatus(CEC_FLAG_RBTF))
 405  {
 406    /* Check if the byte received is the last one of the message */
 407    if (CEC_GetFlagStatus(CEC_FLAG_REOM))
 408    {
 409      HDMI_CEC_RX_MessageStructPrivate.Operande[RxCounter-1] = CEC_ReceiveDataByte();
 410      HDMI_CEC_RX_MessageStructPrivate.RxMessageLength = RxCounter;
 411      ReceiveStatus = SUCCESS;
 412      ReceivedFrame = 1;
 413    }
 414    /* Check if the byte received is a Header */
 415    else if (CEC_GetFlagStatus(CEC_FLAG_RSOM))
 416    {
 417      ReceiveStatus = 0;
 418      HDMI_CEC_RX_MessageStructPrivate.Header = CEC_ReceiveDataByte();
 419      RxCounter = 0;
 420    }
 421    /* Receive each byte except header in the reception buffer */
 422    else
 423    {
 424      if (RxCounter != 0)
 425      {
 426        HDMI_CEC_RX_MessageStructPrivate.Operande[RxCounter-1] = CEC_ReceiveDataByte();
 427        RxCounter++;
 428      }
 429      else
 430      {
 431        HDMI_CEC_RX_MessageStructPrivate.Opcode = CEC_ReceiveDataByte();
 432        RxCounter++;
 433      }
 434      
 435    }
 436    /* Clear all reception flags */
 437    CEC_ClearFlag(CEC_FLAG_RSOM | CEC_FLAG_REOM  | CEC_FLAG_RBTF);
 438  }
 439
 440  /********************** Transmission ******************************************/
 441  /* Check if a transmission error occured */
 442  if (CEC_GetFlagStatus(CEC_FLAG_TERR))
 443  {
 444    TransErrorCode = HDMI_CEC_GetErrorStatus();
 445    CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
 446    SendFrame = 1;
 447    SendStatus = 0;
 448  }
 449  /* Check if end of message bit is set in the data to be transmitted */
 450  else if (CEC_GetFlagStatus(CEC_FLAG_TEOM))
 451  {
 452    CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_RBTF);
 453    CEC_EndOfMessageCmd(DISABLE);
 454    SendFrame = 1;
 455    SendStatus = SUCCESS;
 456  }
 457  /* Check if data byte has been sent */
 458  else if (CEC_GetFlagStatus(CEC_FLAG_TBTRF))
 459  {
 460    /* Set EOM bit if the byte to be transmitted is the last one of the TransmitBuffer */
 461    if (TxCounter == (HDMI_CEC_TX_MessageStructPrivate.TxMessageLength))
 462    {
 463      CEC_SendDataByte(BufferPointer[TxCounter]);
 464      TxCounter++;
 465      CEC_ClearFlag(CEC_FLAG_TBTRF);
 466      CEC_EndOfMessageCmd(ENABLE);
 467    }
 468    else
 469    {
 470      /* Put the byte in the TX Buffer */
 471      CEC_SendDataByte(BufferPointer[TxCounter]);
 472      TxCounter++;
 473      CEC_ClearFlag(CEC_FLAG_TBTRF);
 474    }
 475  }
 476}
 477
 478/**
 479  * @brief  Report physical address to all other devices thus allowing any
 480            device to create a map of the network.
 481  * @param  None
 482  * @retval HDMI_CEC_Error: CEC Error code.
 483  */
 484HDMI_CEC_Error HDMI_CEC_ReportPhysicalAddress(void)
 485{
 486  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
 487  HDMI_CEC_Message HDMI_CEC_TX_Message;
 488
 489  HDMI_CEC_TX_Message.Header = ((MyLogicalAddress << 4) | 0xF);
 490  HDMI_CEC_TX_Message.Opcode = HDMI_CEC_OPCODE_REPORT_PHYSICAL_ADDRESS;
 491  HDMI_CEC_TX_Message.Operande[0] = MyPhysicalAddress >> 8;
 492  HDMI_CEC_TX_Message.Operande[1] = MyPhysicalAddress & 0xFF;
 493  HDMI_CEC_TX_Message.Operande[2] = DeviceType;
 494  HDMI_CEC_TX_Message.TxMessageLength = 0x03;
 495
 496  errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_Message);
 497
 498  return  errorstatus;
 499}
 500
 501/**
 502  * @brief  Handle CEC command receive callback.
 503  *         When receiving the STANDBY Opcode commande, the system is entred in
 504  *         Stop mode and when wakeup, the PLL is configured as system clock and
 505  *         the HSI is selected as PLL source.      
 506  * @param  None
 507  * @retval None
 508  */
 509void HDMI_CEC_CommandCallBack(void)
 510{
 511  uint8_t i = 0, sendcount = 0;
 512  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
 513  EXTI_InitTypeDef EXTI_InitStructure;
 514
 515  switch (HDMI_CEC_RX_MessageStructPrivate.Opcode)
 516  {
 517    case HDMI_CEC_OPCODE_REPORT_PHYSICAL_ADDRESS:
 518      HDMI_CEC_MapStruct.PhysicalAddress_A = HDMI_CEC_RX_MessageStructPrivate.Operande[1] >> 4;
 519      HDMI_CEC_MapStruct.PhysicalAddress_B = HDMI_CEC_RX_MessageStructPrivate.Operande[1] & 0x0F;
 520      HDMI_CEC_MapStruct.PhysicalAddress_C = HDMI_CEC_RX_MessageStructPrivate.Operande[0] >> 4;
 521      HDMI_CEC_MapStruct.PhysicalAddress_D = HDMI_CEC_RX_MessageStructPrivate.Operande[0] & 0x0F;
 522      HDMI_CEC_MapStruct.LogicalAddress = (HDMI_CEC_RX_MessageStructPrivate.Header >> 0x4) & 0x0F;
 523      HDMI_CEC_MapStruct.DeviceType = HDMI_CEC_RX_MessageStructPrivate.Operande[2];
 524      HDMI_CEC_DeviceMap[DeviceCount] = HDMI_CEC_MapStruct;
 525      HDMI_CEC_Follower_String[(HDMI_CEC_DeviceMap[DeviceCount].LogicalAddress)][1] = "1";
 526      DeviceCount++;
 527      break;
 528
 529    case HDMI_CEC_OPCODE_STANDBY:
 530      /* CEC Line */
 531      GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource8);
 532      /* Configure the CEC Line as EXTI Line on Falling Edge */
 533      EXTI_ClearITPendingBit(EXTI_Line8);
 534      EXTI_InitStructure.EXTI_Line = EXTI_Line8;
 535      EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
 536      EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;  
 537      EXTI_InitStructure.EXTI_LineCmd = ENABLE;
 538      EXTI_Init(&EXTI_InitStructure);
 539      /* Request to enter Stop mode */
 540      PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFI);
 541
 542      /* Disable the CEC EXTI Line */
 543      EXTI_InitStructure.EXTI_LineCmd = DISABLE;
 544      EXTI_Init(&EXTI_InitStructure);
 545      /* Configure the PLL Source */
 546      RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_6);
 547
 548      /* Enable PLL */ 
 549      RCC_PLLCmd(ENABLE);
 550
 551      /* Wait till PLL is ready */
 552      while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
 553      {
 554      }
 555
 556      /* Select PLL as system clock source */
 557      RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
 558
 559      /* Wait till PLL is used as system clock source */
 560      while(RCC_GetSYSCLKSource() != 0x08)
 561      {
 562      }
 563      break;
 564
 565    case HDMI_CEC_OPCODE_GET_CEC_VERSION:
 566      /* Send the Used CEC version */
 567      HDMI_CEC_TX_MessageStructPrivate.Header = ((MyLogicalAddress << 4) | HDMI_CEC_RX_MessageStructPrivate.Header >> 4);
 568      HDMI_CEC_TX_MessageStructPrivate.Opcode = HDMI_CEC_OPCODE_CEC_VERSION;
 569      HDMI_CEC_TX_MessageStructPrivate.Operande[0] = HDMI_CEC_VERSION; /* CEC Version */
 570      HDMI_CEC_TX_MessageStructPrivate.TxMessageLength = 0x01;
 571      errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_MessageStructPrivate);
 572
 573      /* Retransmit message until 5 time */
 574      while ((errorstatus != HDMI_CEC_OK) && sendcount < 0x5)
 575      {
 576        sendcount++;
 577        errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_MessageStructPrivate);
 578      }
 579      break;
 580
 581    case HDMI_CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
 582      /* Send the Physical address */
 583      errorstatus = HDMI_CEC_ReportPhysicalAddress();
 584      sendcount = 0;
 585      /* Retransmit message until 5 time */
 586      while ((errorstatus != HDMI_CEC_OK) && sendcount < 0x5)
 587      {
 588        sendcount++;
 589        errorstatus = HDMI_CEC_ReportPhysicalAddress();
 590      }
 591      break;
 592
 593    case HDMI_CEC_OPCODE_FEATURE_ABORT:
 594      /* The device doesn't support the requested message type, or that it cannot
 595      execute it at the present time. */
 596      FeatureOpcode = HDMI_CEC_RX_MessageStructPrivate.Operande[0];
 597      AbortReason = HDMI_CEC_RX_MessageStructPrivate.Operande[1];
 598      break;
 599
 600    case HDMI_CEC_OPCODE_GIVE_OSD_NAME:
 601      /* Send the OSD name = STM32100B CEC*/
 602      HDMI_CEC_TX_MessageStructPrivate.Header = ((MyLogicalAddress << 4) | HDMI_CEC_RX_MessageStructPrivate.Header >> 4);
 603      HDMI_CEC_TX_MessageStructPrivate.Opcode = HDMI_CEC_OPCODE_SET_OSD_NAME;
 604      /* STM32100B*/
 605      HDMI_CEC_TX_MessageStructPrivate.Operande[0] = 0x53;
 606      HDMI_CEC_TX_MessageStructPrivate.Operande[1] = 0x54;
 607      HDMI_CEC_TX_MessageStructPrivate.Operande[2] = 0x4D;
 608      HDMI_CEC_TX_MessageStructPrivate.Operande[3] = 0x33;
 609      HDMI_CEC_TX_MessageStructPrivate.Operande[4] = 0x32;
 610      HDMI_CEC_TX_MessageStructPrivate.Operande[5] = 0x31;
 611      HDMI_CEC_TX_MessageStructPrivate.Operande[6] = 0x30;
 612      HDMI_CEC_TX_MessageStructPrivate.Operande[7] = 0x30;
 613      HDMI_CEC_TX_MessageStructPrivate.Operande[8] = 0x42;
 614      HDMI_CEC_TX_MessageStructPrivate.Operande[9] = 0x20;
 615      /* CEC */
 616      HDMI_CEC_TX_MessageStructPrivate.Operande[10] = 0x43;
 617      HDMI_CEC_TX_MessageStructPrivate.Operande[11] = 0x45;
 618      HDMI_CEC_TX_MessageStructPrivate.Operande[12] = 0x43;
 619      HDMI_CEC_TX_MessageStructPrivate.TxMessageLength = 13;
 620      errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_MessageStructPrivate);
 621      sendcount = 0;
 622      /* Retransmit message until 5 time */
 623      while ((errorstatus != HDMI_CEC_OK) && sendcount < 0x5)
 624      {
 625        sendcount++;
 626        errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_MessageStructPrivate);
 627      }
 628      break;
 629
 630    case HDMI_CEC_OPCODE_ROUTING_CHANGE:
 631      for (i = 0;i < 0x14;i++)
 632      {
 633        if ((HDMI_CEC_DeviceMap[i].PhysicalAddress_A == HDMI_CEC_RX_MessageStructPrivate.Operande[1] >> 4) &&
 634            (HDMI_CEC_DeviceMap[i].PhysicalAddress_B == HDMI_CEC_RX_MessageStructPrivate.Operande[1]&0x0F) &&
 635            (HDMI_CEC_DeviceMap[i].PhysicalAddress_C == HDMI_CEC_RX_MessageStructPrivate.Operande[0] >> 4) &&
 636            (HDMI_CEC_DeviceMap[i].PhysicalAddress_D == HDMI_CEC_RX_MessageStructPrivate.Operande[0]&0x0F))
 637        {
 638          HDMI_CEC_MapStruct.LogicalAddress = (HDMI_CEC_RX_MessageStructPrivate.Header >> 0x4) & 0x0F;
 639          HDMI_CEC_MapStruct.DeviceType = HDMI_CEC_RX_MessageStructPrivate.Operande[2];
 640          HDMI_CEC_DeviceMap[i] = HDMI_CEC_MapStruct;
 641        }
 642      }
 643      break;
 644
 645    default:
 646      /* Send Abort feature*/
 647      HDMI_CEC_TX_MessageStructPrivate.Header = ((MyLogicalAddress << 4) | HDMI_CEC_RX_MessageStructPrivate.Header >> 4);
 648      HDMI_CEC_TX_MessageStructPrivate.Opcode = HDMI_CEC_OPCODE_FEATURE_ABORT;
 649      HDMI_CEC_TX_MessageStructPrivate.Operande[0] = 0x02; /* defines command to be performed */
 650      HDMI_CEC_TX_MessageStructPrivate.Operande[1] = HDMI_CEC_REFUSED; /* Reason for abort feature */
 651      HDMI_CEC_TX_MessageStructPrivate.TxMessageLength = 0x02;
 652      errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_MessageStructPrivate);
 653      sendcount = 0;
 654      /* Retransmit message until 5 time */
 655      while ((errorstatus != HDMI_CEC_OK) && sendcount < 0x5)
 656      {
 657        sendcount++;
 658        errorstatus = HDMI_CEC_TransmitMessage(&HDMI_CEC_TX_MessageStructPrivate);
 659      }
 660      break;
 661
 662  }
 663}
 664
 665/**
 666  * @brief  Check the connected CEC devices.
 667  * @param  None
 668  * @retval HDMI_CEC_Error
 669  */
 670HDMI_CEC_Error HDMI_CEC_CheckConnectedDevices(void)
 671{
 672  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
 673  uint32_t count = 0, i = 1;
 674 
 675  /*----------------------------- TV device  ---------------------------*/
 676  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 677
 678  CEC_EndOfMessageCmd(ENABLE);
 679
 680  CEC_SendDataByte((MyLogicalAddress << 4) | 0x0);
 681
 682  /* Start of message */
 683  CEC_StartOfMessage();
 684
 685  /* Wait till the header message is sent */
 686  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 687  {
 688    count++;
 689  }
 690
 691  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 692  {
 693    errorstatus = HDMI_CEC_TIMEOUT;
 694    return(errorstatus);
 695  }
 696
 697  errorstatus = HDMI_CEC_GetErrorStatus();
 698
 699  if (errorstatus == HDMI_CEC_OK)
 700  {
 701    HDMI_CEC_Follower_String[0][1] = "1";
 702    i++;
 703    errorstatus = HDMI_CEC_OK;
 704  }
 705
 706  /* Clear CEC CSR register */
 707  CEC_ClearFlag(CEC_FLAG_TBTRF);
 708  CEC_EndOfMessageCmd(DISABLE);
 709
 710  /*----------------------------- Recording device 1 ---------------------------*/
 711  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 712
 713  CEC_EndOfMessageCmd(ENABLE);
 714
 715  CEC_SendDataByte((MyLogicalAddress << 4) | 0x1);
 716
 717  /* Start of message */
 718  CEC_StartOfMessage();
 719
 720  /* Wait till the header message is sent */
 721  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 722  {
 723    count++;
 724  }
 725
 726  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 727  {
 728    errorstatus = HDMI_CEC_TIMEOUT;
 729    return(errorstatus);
 730  }
 731
 732  errorstatus = HDMI_CEC_GetErrorStatus();
 733
 734  if (errorstatus == HDMI_CEC_OK)
 735  {
 736    HDMI_CEC_Follower_String[1][1] = "1";
 737    i++;
 738    errorstatus = HDMI_CEC_OK;
 739  }
 740
 741  /* Clear CEC CSR register */
 742  CEC_ClearFlag(CEC_FLAG_TBTRF);
 743  CEC_EndOfMessageCmd(DISABLE);
 744  /*----------------------------- Recording device 2 ---------------------------*/
 745  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 746
 747  CEC_EndOfMessageCmd(ENABLE);
 748
 749  CEC_SendDataByte((MyLogicalAddress << 4) | 0x2);
 750
 751  /* Start of message */
 752  CEC_StartOfMessage();
 753
 754  /* Wait till the header message is sent */
 755  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 756  {
 757    count++;
 758  }
 759
 760  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 761  {
 762    errorstatus = HDMI_CEC_TIMEOUT;
 763    return(errorstatus);
 764  }
 765
 766  errorstatus = HDMI_CEC_GetErrorStatus();
 767
 768  if (errorstatus == HDMI_CEC_OK)
 769  {
 770    HDMI_CEC_Follower_String[2][1] = "1";
 771    i++;
 772    errorstatus = HDMI_CEC_OK;
 773  }
 774
 775  /* Clear CEC CSR register */
 776  CEC_ClearFlag(CEC_FLAG_TBTRF);
 777  CEC_EndOfMessageCmd(DISABLE);
 778
 779  /*----------------------------- Tuner 1 ---------------------------*/
 780  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 781
 782  CEC_EndOfMessageCmd(ENABLE);
 783
 784  CEC_SendDataByte((MyLogicalAddress << 4) | 0x3);
 785
 786  /* Start of message */
 787  CEC_StartOfMessage();
 788
 789  /* Wait till the header message is sent */
 790  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 791  {
 792    count++;
 793  }
 794
 795  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 796  {
 797    errorstatus = HDMI_CEC_TIMEOUT;
 798    return(errorstatus);
 799  }
 800
 801  errorstatus = HDMI_CEC_GetErrorStatus();
 802
 803  if (errorstatus == HDMI_CEC_OK)
 804  {
 805    HDMI_CEC_Follower_String[3][1] = "1";
 806    i++;
 807    errorstatus = HDMI_CEC_OK;
 808  }
 809  /* Clear CEC CSR register */
 810  CEC_ClearFlag(CEC_FLAG_TBTRF);
 811  CEC_EndOfMessageCmd(DISABLE);
 812  /*----------------------------- Playback device 1 ---------------------------*/
 813  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 814
 815  CEC_EndOfMessageCmd(ENABLE);
 816
 817  CEC_SendDataByte((MyLogicalAddress << 4) | 0x4);
 818
 819  /* Start of message */
 820  CEC_StartOfMessage();
 821
 822  /* Wait till the header message is sent */
 823  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 824  {
 825    count++;
 826  }
 827
 828  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 829  {
 830    errorstatus = HDMI_CEC_TIMEOUT;
 831    return(errorstatus);
 832  }
 833
 834  errorstatus = HDMI_CEC_GetErrorStatus();
 835
 836  if (errorstatus == HDMI_CEC_OK)
 837  {
 838    HDMI_CEC_Follower_String[4][1] = "1";
 839    i++;
 840    errorstatus = HDMI_CEC_OK;
 841  }
 842  /* Clear CEC CSR register */
 843  CEC_ClearFlag(CEC_FLAG_TBTRF);
 844  CEC_EndOfMessageCmd(DISABLE);
 845
 846  /*----------------------------- Audio system ---------------------------*/
 847  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 848
 849  CEC_EndOfMessageCmd(ENABLE);
 850
 851  CEC_SendDataByte((MyLogicalAddress << 4) | 0x5);
 852
 853  /* Start of message */
 854  CEC_StartOfMessage();
 855
 856  /* Wait till the header message is sent */
 857  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 858  {
 859    count++;
 860  }
 861
 862  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 863  {
 864    errorstatus = HDMI_CEC_TIMEOUT;
 865    return(errorstatus);
 866  }
 867
 868  errorstatus = HDMI_CEC_GetErrorStatus();
 869
 870  if (errorstatus == HDMI_CEC_OK)
 871  {
 872    HDMI_CEC_Follower_String[5][1] = "1";
 873    i++;
 874    errorstatus = HDMI_CEC_OK;
 875  }
 876  /* Clear CEC CSR register */
 877  CEC_ClearFlag(CEC_FLAG_TBTRF);
 878  CEC_EndOfMessageCmd(DISABLE);
 879
 880  /*----------------------------- Tuner 2 ---------------------------*/
 881  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 882
 883  CEC_EndOfMessageCmd(ENABLE);
 884
 885  CEC_SendDataByte((MyLogicalAddress << 4) | 0x6);
 886
 887  /* Start of message */
 888  CEC_StartOfMessage();
 889
 890  /* Wait till the header message is sent */
 891  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 892  {
 893    count++;
 894  }
 895
 896  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 897  {
 898    errorstatus = HDMI_CEC_TIMEOUT;
 899    return(errorstatus);
 900  }
 901
 902  errorstatus = HDMI_CEC_GetErrorStatus();
 903
 904  if (errorstatus == HDMI_CEC_OK)
 905  {
 906    HDMI_CEC_Follower_String[6][1] = "1";
 907    i++;
 908    errorstatus = HDMI_CEC_OK;
 909  }
 910  /* Clear CEC CSR register */
 911  CEC_ClearFlag(CEC_FLAG_TBTRF);
 912  CEC_EndOfMessageCmd(DISABLE);
 913
 914  /*----------------------------- Tuner 3 ---------------------------*/
 915  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 916
 917  CEC_EndOfMessageCmd(ENABLE);
 918
 919  CEC_SendDataByte((MyLogicalAddress << 4) | 0x7);
 920
 921  /* Start of message */
 922  CEC_StartOfMessage();
 923
 924  /* Wait till the header message is sent */
 925  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 926  {
 927    count++;
 928  }
 929
 930  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 931  {
 932    errorstatus = HDMI_CEC_TIMEOUT;
 933    return(errorstatus);
 934  }
 935
 936  errorstatus = HDMI_CEC_GetErrorStatus();
 937
 938  if (errorstatus == HDMI_CEC_OK)
 939  {
 940    HDMI_CEC_Follower_String[7][1] = "1";
 941    i++;
 942    errorstatus = HDMI_CEC_OK;
 943  }
 944  /* Clear CEC CSR register */
 945  CEC_ClearFlag(CEC_FLAG_TBTRF);
 946  CEC_EndOfMessageCmd(DISABLE);
 947
 948  /*----------------------------- Playback device 2 ---------------------------*/
 949  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 950
 951  CEC_EndOfMessageCmd(ENABLE);
 952
 953  CEC_SendDataByte((MyLogicalAddress << 4) | 0x8);
 954
 955  /* Start of message */
 956  CEC_StartOfMessage();
 957
 958  /* Wait till the header message is sent */
 959  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 960  {
 961    count++;
 962  }
 963
 964  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 965  {
 966    errorstatus = HDMI_CEC_TIMEOUT;
 967    return(errorstatus);
 968  }
 969
 970  errorstatus = HDMI_CEC_GetErrorStatus();
 971
 972  if (errorstatus == HDMI_CEC_OK)
 973  {
 974    HDMI_CEC_Follower_String[8][1] = "1";
 975    i++;
 976    errorstatus = HDMI_CEC_OK;
 977  }
 978  /* Clear CEC CSR register */
 979  CEC_ClearFlag(CEC_FLAG_TBTRF);
 980  CEC_EndOfMessageCmd(DISABLE);
 981
 982  /*----------------------------- Recording device 3 ---------------------------*/
 983  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
 984
 985  CEC_EndOfMessageCmd(ENABLE);
 986
 987  CEC_SendDataByte((MyLogicalAddress << 4) | 0x9);
 988
 989  /* Start of message */
 990  CEC_StartOfMessage();
 991
 992  /* Wait till the header message is sent */
 993  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
 994  {
 995    count++;
 996  }
 997
 998  if (count >= HDMI_CEC_TIMEOUT_VALUE)
 999  {
1000    errorstatus = HDMI_CEC_TIMEOUT;
1001    return(errorstatus);
1002  }
1003
1004  errorstatus = HDMI_CEC_GetErrorStatus();
1005
1006  if (errorstatus == HDMI_CEC_OK)
1007  {
1008    HDMI_CEC_Follower_String[9][1] = "1";
1009    i++;
1010    errorstatus = HDMI_CEC_OK;
1011  }
1012  /* Clear CEC CSR register */
1013  CEC_ClearFlag(CEC_FLAG_TBTRF);
1014  CEC_EndOfMessageCmd(DISABLE);
1015  /*----------------------------- Tuner 4 ---------------------------*/
1016  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
1017
1018  CEC_EndOfMessageCmd(ENABLE);
1019
1020  CEC_SendDataByte((MyLogicalAddress << 4) | 0xA);
1021
1022  /* Start of message */
1023  CEC_StartOfMessage();
1024
1025  /* Wait till the header message is sent */
1026  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1027  {
1028    count++;
1029  }
1030
1031  if (count >= HDMI_CEC_TIMEOUT_VALUE)
1032  {
1033    errorstatus = HDMI_CEC_TIMEOUT;
1034    return(errorstatus);
1035  }
1036
1037  errorstatus = HDMI_CEC_GetErrorStatus();
1038
1039  if (errorstatus == HDMI_CEC_OK)
1040  {
1041    HDMI_CEC_Follower_String[10][1] = "1";
1042    i++;
1043    errorstatus = HDMI_CEC_OK;
1044  }
1045  /* Clear CEC CSR register */
1046  CEC_ClearFlag(CEC_FLAG_TBTRF);
1047  CEC_EndOfMessageCmd(DISABLE);
1048  /*----------------------------- Playback device 3 ---------------------------*/
1049  CEC_OwnAddressConfig(MyLogicalAddress); /* Own address = MyLogicalAddress */
1050
1051  CEC_EndOfMessageCmd(ENABLE);
1052
1053  CEC_SendDataByte((MyLogicalAddress << 4) | 0xB);
1054
1055  /* Start of message */
1056  CEC_StartOfMessage();
1057
1058  /* Wait till the header message is sent */
1059  while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1060  {
1061    count++;
1062  }
1063
1064  if (count >= HDMI_CEC_TIMEOUT_VALUE)
1065  {
1066    errorstatus = HDMI_CEC_TIMEOUT;
1067    return(errorstatus);
1068  }
1069
1070  errorstatus = HDMI_CEC_GetErrorStatus();
1071
1072  if (errorstatus == HDMI_CEC_OK)
1073  {
1074    HDMI_CEC_Follower_String[11][1] = "1";
1075    i++;
1076    errorstatus = HDMI_CEC_OK;
1077  }
1078  /* Clear CEC CSR register */
1079  CEC_ClearFlag(CEC_FLAG_TBTRF);
1080  CEC_EndOfMessageCmd(DISABLE);
1081
1082  CECDevicesNumber = i - 1;
1083
1084  return errorstatus;
1085}
1086
1087/**
1088  * @brief  Physical address discovery.
1089  * @param  None
1090  * @retval HDMI_CEC_Error: CEC Error code.
1091  */
1092static HDMI_CEC_Error PhysicalAddressDiscovery(void)
1093{
1094  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
1095#ifdef HDMI_CEC_USE_DDC

1096  uint32_t index = 0, i = 0;
1097#endif

1098
1099  /*------------------------------ Physical address discovery -----------------*/
1100  if (HDMI_CEC_ROOT == 0x1)
1101  {
1102    MyPhysicalAddress = 0x0000;
1103    /* The HDMI-CEC here is configured as sink or as a repeater. The configuration
1104       of the +5V power signal and the HPD should be well configured.
1105       Implement here the EDID Structure to be sent to the HDMI source.
1106       For more details please refer to the HDMI specification. 
1107       The EDID structure should be sent to the device source using the DDC Channel
1108       and using the HPD signal. */
1109  }
1110  else
1111  {
1112  
1113#ifdef HDMI_CEC_USE_DDC  

1114    /* The HDMI-CEC here is configured as source or as a repeater. The configuration
1115       of the +5V power signal and the HPD should be well configured.
1116       The source should wait for HPD and then read the EDID structure. */
1117    while(GPIO_ReadInputDataBit(HDMI_CEC_HPD_GPIO_PORT, HDMI_CEC_HPD_PIN) == RESET)
1118    {
1119    }
1120    /* Wait for 100 ms after HPD was received */
1121    for(i = 0; i < 0x5FFFF; i++)
1122    {
1123    }
1124
1125    /* Return the physical address using the I2C  by reading the 2 bytes 24 and
1126      25 form the EDID */
1127    /* Read the EDID Block 0 and EDID Block 1 at address 0xA0 */
1128    /*!< While the bus is busy */
1129    while(I2C_GetFlagStatus(HDMI_CEC_I2C, I2C_FLAG_BUSY))
1130    {
1131    }
1132  
1133    /*!< Send START condition */
1134    I2C_GenerateSTART(HDMI_CEC_I2C, ENABLE);
1135  
1136    /*!< Test on EV5 and clear it */
1137    while(!I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_MODE_SELECT))
1138    {
1139    }
1140   
1141    /*!< Send EEPROM address for write */
1142    I2C_Send7bitAddress(HDMI_CEC_I2C, 0xA0, I2C_Direction_Transmitter);
1143 
1144
1145    /*!< Test on EV6 and clear it */
1146    while(!I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
1147    {
1148    }
1149
1150    /*!< Send the EEPROM's internal address to read from: Only one byte address */
1151    I2C_SendData(HDMI_CEC_I2C, 0x00);  
1152
1153    /*!< Test on EV8 and clear it */
1154    while(!I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_BYTE_TRANSMITTED))
1155    {
1156    }
1157  
1158    /*!< Send STRAT condition a second time */  
1159    I2C_GenerateSTART(HDMI_CEC_I2C, ENABLE);
1160  
1161    /*!< Test on EV5 and clear it */
1162    while(!I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_MODE_SELECT))
1163    {
1164    }
1165  
1166    /*!< Send EEPROM address for read */
1167    I2C_Send7bitAddress(HDMI_CEC_I2C, 0xA1, I2C_Direction_Receiver);
1168  
1169    /*!< Test on EV6 and clear it */
1170    while(!I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED))
1171    {
1172    }
1173
1174    /* While there is data to be read */
1175    while (NumByteToRead-- > 1)
1176    {
1177      while(I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_BYTE_RECEIVED))
1178      {
1179      }
1180      for(i = 0; i < 0xFFF; i++)
1181      {
1182      }
1183      pBuffer[index++] = I2C_ReceiveData(HDMI_CEC_I2C);
1184    }
1185
1186    /* Disable Acknowledgement */
1187    I2C_AcknowledgeConfig(HDMI_CEC_I2C, DISABLE);
1188
1189    /* Send STOP Condition */
1190    I2C_GenerateSTOP(HDMI_CEC_I2C, ENABLE);
1191
1192    while(I2C_CheckEvent(HDMI_CEC_I2C, I2C_EVENT_MASTER_BYTE_RECEIVED));
1193    pBuffer[index] = I2C_ReceiveData(HDMI_CEC_I2C);
1194
1195    /* Enable Acknowledgement to be ready for another reception */
1196    I2C_AcknowledgeConfig(HDMI_CEC_I2C, ENABLE);
1197    MyPhysicalAddress = ((pBuffer[138] << 8) | pBuffer[137]);
1198#else

1199    MyPhysicalAddress = 0x1000;
1200#endif

1201  }
1202
1203  return errorstatus;
1204}
1205/**
1206  * @brief  Allocate the logical address.
1207  * @param  None
1208  * @retval HDMI_CEC_Error: CEC Error code.
1209  */
1210static HDMI_CEC_Error LogicalAddressAllocation(void)
1211{
1212  HDMI_CEC_Error errorstatus = HDMI_CEC_OK;
1213  uint32_t count = 0;
1214
1215  /*------------------ Logical address allocation -----------------------------*/
1216  /* Get the device type */
1217  /* Device type = CEC_TV */
1218  if (DeviceType == HDMI_CEC_TV)
1219  {
1220    if (HDMI_CEC_ROOT)
1221    {
1222      MyLogicalAddress = 0x00;
1223    }
1224    else
1225    {
1226      CEC_OwnAddressConfig(0xE); /* Own address = 0xE */
1227
1228      CEC_EndOfMessageCmd(ENABLE);
1229
1230      CEC_SendDataByte(0xEE);
1231
1232      /* Start of message */
1233      CEC_StartOfMessage();
1234
1235      /* Wait till the polling message is sent */
1236      while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1237      {
1238        count++;
1239      }
1240
1241      if (count >= HDMI_CEC_TIMEOUT_VALUE)
1242      {
1243        errorstatus = HDMI_CEC_TIMEOUT;
1244        return(errorstatus);
1245      }
1246
1247      errorstatus = HDMI_CEC_GetErrorStatus();
1248
1249      if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1250      {
1251        MyLogicalAddress = 0x0E;
1252        errorstatus = HDMI_CEC_OK;
1253      }
1254      else if (errorstatus == HDMI_CEC_OK)
1255      {
1256        MyLogicalAddress = 0x0F;
1257        errorstatus = HDMI_CEC_DEVICE_UNREGISTRED;
1258      }
1259    }
1260    /* Clear CEC CSR register */
1261    CEC_ClearFlag(CEC_FLAG_TBTRF);
1262    CEC_EndOfMessageCmd(DISABLE);
1263  }
1264
1265  /* Device type = CEC_RECORDING */
1266  if (DeviceType == HDMI_CEC_RECORDING)
1267  {
1268    CEC_OwnAddressConfig(0x1); /* Own address = 0x1 */
1269
1270    CEC_EndOfMessageCmd(ENABLE);
1271
1272    CEC_SendDataByte(0x11);
1273
1274    /* Start of message */
1275    CEC_StartOfMessage();
1276
1277    /* Wait till the header message is sent */
1278    while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1279    {
1280      count++;
1281    }
1282
1283    if (count >= HDMI_CEC_TIMEOUT_VALUE)
1284    {
1285      errorstatus = HDMI_CEC_TIMEOUT;
1286      return(errorstatus);
1287    }
1288
1289    errorstatus = HDMI_CEC_GetErrorStatus();
1290
1291    if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1292    {
1293      MyLogicalAddress = 0x01;
1294      errorstatus = HDMI_CEC_OK;
1295    }
1296    else if (errorstatus == HDMI_CEC_OK)
1297    {
1298      /* Clear CEC CSR register */
1299      CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1300
1301      CEC_EndOfMessageCmd(DISABLE);
1302
1303      CEC_OwnAddressConfig(0x2); /* Own address = 0x2 */
1304
1305      CEC_EndOfMessageCmd(ENABLE);
1306
1307      CEC_SendDataByte(0x22);
1308
1309      /* Start of message */
1310      CEC_StartOfMessage();
1311
1312      count = 0;
1313
1314      /* Wait till the header message is sent */
1315      while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1316      {
1317        count++;
1318      }
1319
1320      if (count >= HDMI_CEC_TIMEOUT_VALUE)
1321      {
1322        errorstatus = HDMI_CEC_TIMEOUT;
1323        return(errorstatus);
1324      }
1325      errorstatus = HDMI_CEC_GetErrorStatus();
1326
1327      if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1328      {
1329        MyLogicalAddress = 0x02;
1330        errorstatus = HDMI_CEC_OK;
1331      }
1332      else if (errorstatus == HDMI_CEC_OK)
1333      {
1334        /* Clear CEC CSR register */
1335        CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1336
1337        CEC_EndOfMessageCmd(DISABLE);
1338
1339        CEC_OwnAddressConfig(0x9); /* Own address = 0x9 */
1340
1341        CEC_EndOfMessageCmd(ENABLE);
1342
1343        CEC_SendDataByte(0x99);
1344
1345        /* Start of message */
1346        CEC_StartOfMessage();
1347
1348        count = 0;
1349
1350        /* Wait till the header message is sent */
1351        while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1352        {
1353          count++;
1354        }
1355
1356        if (count >= HDMI_CEC_TIMEOUT_VALUE)
1357        {
1358          errorstatus = HDMI_CEC_TIMEOUT;
1359          return(errorstatus);
1360        }
1361        errorstatus = HDMI_CEC_GetErrorStatus();
1362
1363        if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1364        {
1365          MyLogicalAddress = 0x09;
1366          errorstatus = HDMI_CEC_OK;
1367        }
1368        else if (errorstatus == HDMI_CEC_OK)
1369        {
1370          MyLogicalAddress = 0x0F;
1371          errorstatus = HDMI_CEC_DEVICE_UNREGISTRED;
1372        }
1373      }
1374    }
1375    /* Clear CEC CSR register */
1376    CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1377    CEC_EndOfMessageCmd(DISABLE);
1378  }
1379
1380  /* Device type = CEC_TUNER */
1381  if (DeviceType == HDMI_CEC_TUNER)
1382  {
1383    CEC_OwnAddressConfig(0x3); /* Own address = 0x3 */
1384
1385    CEC_EndOfMessageCmd(ENABLE);
1386
1387    CEC_SendDataByte(0x33);
1388
1389    /* Start of message */
1390    CEC_StartOfMessage();
1391
1392    count = 0;
1393
1394    /* Wait till the header message is sent */
1395    while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1396    {
1397      count++;
1398    }
1399
1400    if (count >= HDMI_CEC_TIMEOUT_VALUE)
1401    {
1402      errorstatus = HDMI_CEC_TIMEOUT;
1403      return(errorstatus);
1404    }
1405    errorstatus = HDMI_CEC_GetErrorStatus();
1406
1407    if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1408    {
1409      MyLogicalAddress = 0x03;
1410      errorstatus = HDMI_CEC_OK;
1411    }
1412    else if (errorstatus == HDMI_CEC_OK)
1413    {
1414      /* Clear CEC CSR register */
1415      CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1416
1417      CEC_EndOfMessageCmd(DISABLE);
1418
1419      CEC_OwnAddressConfig(0x6); /* Own address = 0x6 */
1420
1421      CEC_EndOfMessageCmd(ENABLE);
1422
1423      CEC_SendDataByte(0x66);
1424
1425      /* Start of message */
1426      CEC_StartOfMessage();
1427
1428      count = 0;
1429
1430      /* Wait till the header message is sent */
1431      while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1432      {
1433        count++;
1434      }
1435
1436      if (count >= HDMI_CEC_TIMEOUT_VALUE)
1437      {
1438        errorstatus = HDMI_CEC_TIMEOUT;
1439        return(errorstatus);
1440      }
1441      errorstatus = HDMI_CEC_GetErrorStatus();
1442
1443      if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1444      {
1445        MyLogicalAddress = 0x06;
1446        errorstatus = HDMI_CEC_OK;
1447      }
1448      else if (errorstatus == HDMI_CEC_OK)
1449      {
1450        /* Clear CEC CSR register */
1451        CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1452
1453        CEC_EndOfMessageCmd(DISABLE);
1454
1455        CEC_OwnAddressConfig(0x7); /* Own address = 0x7 */
1456
1457        CEC_EndOfMessageCmd(ENABLE);
1458
1459        CEC_SendDataByte(0x77);
1460
1461        /* Start of message */
1462        CEC_StartOfMessage();
1463
1464        count = 0;
1465
1466        /* Wait till the header message is sent */
1467        while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1468        {
1469          count++;
1470        }
1471
1472        if (count >= HDMI_CEC_TIMEOUT_VALUE)
1473        {
1474          errorstatus = HDMI_CEC_TIMEOUT;
1475          return(errorstatus);
1476        }
1477        errorstatus = HDMI_CEC_GetErrorStatus();
1478
1479        if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1480        {
1481          MyLogicalAddress = 0x07;
1482          errorstatus = HDMI_CEC_OK;
1483        }
1484        else if (errorstatus == HDMI_CEC_OK)
1485        {
1486          /* Clear CEC CSR register */
1487          CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1488
1489          CEC_EndOfMessageCmd(DISABLE);
1490
1491          CEC_OwnAddressConfig(0xA); /* Own address = 0xA */
1492
1493          CEC_EndOfMessageCmd(ENABLE);
1494
1495          CEC_SendDataByte(0xAA);
1496
1497          /* Start of message */
1498          CEC_StartOfMessage();
1499
1500          count = 0;
1501
1502          /* Wait till the header message is sent */
1503          while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1504          {
1505            count++;
1506          }
1507
1508          if (count >= HDMI_CEC_TIMEOUT_VALUE)
1509          {
1510            errorstatus = HDMI_CEC_TIMEOUT;
1511            return(errorstatus);
1512          }
1513          errorstatus = HDMI_CEC_GetErrorStatus();
1514
1515          if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1516          {
1517            MyLogicalAddress = 0x0A;
1518            errorstatus = HDMI_CEC_OK;
1519          }
1520          else if (errorstatus == HDMI_CEC_OK)
1521          {
1522            MyLogicalAddress = 0x0F;
1523            errorstatus = HDMI_CEC_DEVICE_UNREGISTRED;
1524          }
1525        }
1526      }
1527    }
1528    /* Clear CEC CSR register */
1529    CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1530    CEC_EndOfMessageCmd(DISABLE);
1531  }
1532
1533  /* Device type = CEC_PLAYBACK */
1534  if (DeviceType == HDMI_CEC_PLAYBACK)
1535  {
1536    CEC_OwnAddressConfig(0x4); /* Own address = 0x4 */
1537
1538    CEC_EndOfMessageCmd(ENABLE);
1539
1540    CEC_SendDataByte(0x44);
1541
1542    /* Start of message */
1543    CEC_StartOfMessage();
1544
1545    count = 0;
1546
1547    /* Wait till the header message is sent */
1548    while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1549    {
1550      count++;
1551    }
1552
1553    if (count >= HDMI_CEC_TIMEOUT_VALUE)
1554    {
1555      errorstatus = HDMI_CEC_TIMEOUT;
1556      return(errorstatus);
1557    }
1558
1559    errorstatus = HDMI_CEC_GetErrorStatus();
1560
1561    if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1562    {
1563      MyLogicalAddress = 0x04;
1564      errorstatus = HDMI_CEC_OK;
1565    }
1566    else if (errorstatus == HDMI_CEC_OK)
1567    {
1568      /* Clear CEC CSR register */
1569      CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1570
1571      CEC_EndOfMessageCmd(DISABLE);
1572
1573      CEC_OwnAddressConfig(0x8); /* Own address = 0x8 */
1574
1575      CEC_EndOfMessageCmd(ENABLE);
1576
1577      CEC_SendDataByte(0x88);
1578
1579      /* Start of message */
1580      CEC_StartOfMessage();
1581
1582      count = 0;
1583
1584      /* Wait till the header message is sent */
1585      while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1586      {
1587        count++;
1588      }
1589
1590      if (count >= HDMI_CEC_TIMEOUT_VALUE)
1591      {
1592        errorstatus = HDMI_CEC_TIMEOUT;
1593        return(errorstatus);
1594      }
1595      errorstatus = HDMI_CEC_GetErrorStatus();
1596
1597      if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1598      {
1599        MyLogicalAddress = 0x08;
1600        errorstatus = HDMI_CEC_OK;
1601      }
1602      else if (errorstatus == HDMI_CEC_OK)
1603      {
1604        /* Clear CEC CSR register */
1605        CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1606
1607        CEC_EndOfMessageCmd(DISABLE);
1608
1609        CEC_OwnAddressConfig(0xB); /* Own address = 0xBB */
1610
1611        CEC_EndOfMessageCmd(ENABLE);
1612
1613        CEC_SendDataByte(0xBB);
1614
1615        /* Start of message */
1616        CEC_StartOfMessage();
1617
1618        count = 0;
1619
1620        /* Wait till the header message is sent */
1621        while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1622        {
1623          count++;
1624        }
1625
1626        if (count >= HDMI_CEC_TIMEOUT_VALUE)
1627        {
1628          errorstatus = HDMI_CEC_TIMEOUT;
1629          return(errorstatus);
1630        }
1631
1632        errorstatus = HDMI_CEC_GetErrorStatus();
1633
1634        if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1635        {
1636          MyLogicalAddress = 0x0B;
1637          errorstatus = HDMI_CEC_OK;
1638        }
1639        else if (errorstatus == HDMI_CEC_OK)
1640        {
1641          MyLogicalAddress = 0x0F;
1642          errorstatus = HDMI_CEC_DEVICE_UNREGISTRED;
1643        }
1644      }
1645    }
1646
1647    /* Clear CEC CSR register */
1648    CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1649    CEC_EndOfMessageCmd(DISABLE);
1650  }
1651
1652  /* Device type = CEC Audio System */
1653  if (DeviceType == HDMI_CEC_AUDIOSYSTEM)
1654  {
1655    CEC_OwnAddressConfig(0x5); /* Own address = 0x5 */
1656
1657    CEC_EndOfMessageCmd(ENABLE);
1658
1659    CEC_SendDataByte(0x55);
1660
1661    /* Start of message */
1662    CEC_StartOfMessage();
1663
1664    count = 0;
1665
1666    /* Wait till the header message is sent */
1667    while ((CEC_GetFlagStatus(CEC_FLAG_TBTRF) == RESET) && (CEC_GetFlagStatus(CEC_FLAG_TERR) == RESET) && (count < HDMI_CEC_TIMEOUT_VALUE))
1668    {
1669      count++;
1670    }
1671
1672    if (count >= HDMI_CEC_TIMEOUT_VALUE)
1673    {
1674      errorstatus = HDMI_CEC_TIMEOUT;
1675      return(errorstatus);
1676    }
1677
1678    errorstatus = HDMI_CEC_GetErrorStatus();
1679
1680    if (errorstatus == HDMI_CEC_BLOCK_ACKNOWLEDGE)
1681    {
1682      MyLogicalAddress = 0x05;
1683      errorstatus = HDMI_CEC_OK;
1684    }
1685    else if (errorstatus == HDMI_CEC_OK)
1686    {
1687      MyLogicalAddress = 0x0F;
1688      errorstatus = HDMI_CEC_DEVICE_UNREGISTRED;
1689    }
1690
1691    /* Clear CEC CSR register */
1692    CEC_ClearFlag(CEC_FLAG_TBTRF | CEC_FLAG_TERR);
1693    CEC_EndOfMessageCmd(DISABLE);
1694  }
1695
1696  return errorstatus;
1697}
1698
1699/**
1700  * @}
1701  */
1702
1703/**
1704  * @}
1705  */
1706
1707/**
1708  * @}
1709  */
1710
1711/**
1712  * @}
1713  */
1714
1715/**
1716  * @}
1717  */
1718  
1719/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
1720
1721