Пример #1
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{  
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file startup_stm32f446xx.s) before to branch to application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */      
  
  /* CEC device initialization */
#if defined (DEVICE_1)
  DestinationAddress = DEVICE_ADDRESS_2; /* follower address */
  MyOwnAddress       = DEVICE_ADDRESS_1;
#elif defined (DEVICE_2)
  DestinationAddress = DEVICE_ADDRESS_1; /* follower address */
  MyOwnAddress       = DEVICE_ADDRESS_2;
#endif  
  
  /* IP configuration */ 
  CEC_Config();
  
  /* User Button Configuration */
  EXTILine13_15_Config();
   
  /* Build the Header block to send */
  HeaderBlockValueToSend = (uint8_t)((uint32_t)(MyOwnAddress) << CEC_INITIATOR_LSB_POS) | DestinationAddress;
  
  /* Test start */
  
  /* Enter infinite reception loop:
  * Each Time a reception is done, according to the value 
  * of "ReceivedFrame" the examples runs a specified 
  * Routine :
  * If the reception is correct TransferStatus value is PASSED ,otherwise it is FAILED */
  
  while(1)
  {
    if(ReceivedFrame == 0)
    {
    }
    /* If Bad Reception  */
    if(ReceivedFrame == 2)
    {
      /* Not Ok */
      TransferStatus = FAILED;
      ReceivedFrame = 0;
    }
    if (ReceivedFrame == 1)
    {
      /* OK */
      if ((Tab_Rx[1] ==0x44) && (Tab_Rx[2] == 0x42)) /* Test on the opcode value */
      {
        TransferStatus = PASSED;
        ReceivedFrame = 0;
        CEC_FlushRxBuffer();
      }     
    }
  }
}      
Пример #2
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32f0xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f0xx.c file
  */
#ifdef LCD_DISPLAY
  /* LCD initialization */
  STM320518_LCD_Init();
#endif

  /* Initialize LEDs available on STM320518-EVAL board */
  /* Configure LED1, LED2, LED3 and LED4 */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

#if defined (DEVICE_1)
  /* Configure the Joystick button and its associated EXTI Line */
  STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_EXTI);

  MyLogicalAddress1 = DEVICE_ADDRESS_1;
  MyFollowerAddress1 = DEVICE_ADDRESS_2;
  MyFollowerAddress2 = DEVICE_ADDRESS_3;
#elif defined (DEVICE_2)
  MyLogicalAddress1 = DEVICE_ADDRESS_2;
  MyLogicalAddress2 = DEVICE_ADDRESS_3;
  MyFollowerAddress1 = DEVICE_ADDRESS_1;
#endif

  /* CEC configuration */
  CEC_Config();

#ifdef LCD_DISPLAY
  /* Clear the LCD */
  LCD_Clear(LCD_COLOR_WHITE);
  LCD_SetBackColor(LCD_COLOR_BLACK);
  LCD_SetTextColor(LCD_COLOR_WHITE);
#if defined (DEVICE_1)
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)"CEC Initiator device");
  LCD_SetBackColor(LCD_COLOR_WHITE);
  LCD_SetTextColor(LCD_COLOR_BLUE);
  LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *)"Choose CEC Follower ");
  LCD_DisplayStringLine(LCD_LINE_3, (uint8_t *)"Address :           ");
  LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"RIGHT=> Tuner       ");
  LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"LEFT => Audio System");
#elif defined (DEVICE_2) 
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)"CEC Follower device ");
#endif
#endif

  while(1)
  {
    /* If a frame has been received */
    while(CECReceivedFrame == 0)
    {}

    if (CECReceivedFrame == 1)
    {
      if ((ReceiverAddress&0xF) == 0x03) /* Test on the Receiver value */
      {
        /* Turn on LED1 */
        STM_EVAL_LEDOn(LED1);
        /* Turn off LED4 */
        STM_EVAL_LEDOff(LED4);
        /* Turn off LED3 */
        STM_EVAL_LEDOff(LED3);
#ifdef LCD_DISPLAY
        LCD_SetBackColor(LCD_COLOR_GREEN);
        LCD_SetTextColor(LCD_COLOR_WHITE);
        LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"Receive : Succeeded ");
        LCD_DisplayStringLine(LCD_LINE_8, (uint8_t *)"Receiver Address is ");
        LCD_DisplayStringLine(LCD_LINE_9, (uint8_t *)"       Tuner        ");
#endif
      }
      else if ((ReceiverAddress &0xF) ==0x05) /* Test on the Receiver value */
      {
        /* Turn on LED4 */
        STM_EVAL_LEDOn(LED4);
        /* Turn off LED1 */
        STM_EVAL_LEDOff(LED1);
         /* Turn off LED3 */
        STM_EVAL_LEDOff(LED3);
#ifdef LCD_DISPLAY
        LCD_SetBackColor(LCD_COLOR_BLUE2);
        LCD_SetTextColor(LCD_COLOR_WHITE);
        LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"Receive : Succeeded ");
        LCD_DisplayStringLine(LCD_LINE_8, (uint8_t *)"Receiver Address is ");
        LCD_DisplayStringLine(LCD_LINE_9, (uint8_t *)"   Audio System     ");
#endif
      }
    }
    else
    {
      /* KO */
      /* Turn on LED3 */
      STM_EVAL_LEDOn(LED3);
#ifdef LCD_DISPLAY
      LCD_SetTextColor(LCD_COLOR_WHITE);
      LCD_SetBackColor(LCD_COLOR_RED);
      LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"Receive : Failed    ");
#endif
    }

    CECReceivedFrame = 0;
  }
}
Пример #3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
 /* This sample code shows how to use STM32F3xx CEC HAL API to transmit and 
  * receive data. The device is set in waiting to receive mode and sends
  * messages when the evaluation board buttons are pushed by the user */
  
  /* STM32F3xx HAL library initialization:
       - Configure the Flash prefetch
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();
  /* Configure the system clock to 72 MHz */
  SystemClock_Config();

  /* LED and button-triggered interruptions initialization */

  /* -1- Initialize LEDs mounted on EVAL board */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* -2- Configure EXTI Line0 (connected to PA0 pin) in Interrupt mode */
  /* Do basically the same as BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI); */
  EXTILine0_Config();
  
  /* -3- Configure EXTI Line2 (connected to PA2 pin) in interrupt mode */
  /* Do basically the same as BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); */
  EXTILine2_TSC_Config();

  /* -4- Configure EXTI Line9-5 (connected to PE6 pin) in interrupt mode */
  /* Do basically the same as BSP_PB_Init(BUTTON_SEL, BUTTON_MODE_EXTI); */
  EXTILine9_5_Config();

  /* -5- Configure EXTI Line15-10 (connected to PF10 pin) in interrupt mode */
  /* Do basically the same as BSP_PB_Init(JOY_UP, BUTTON_MODE_EXTI); */
  EXTILine15_10_Config();
  
  
  /* CEC device initialization */


#if defined (DEVICE_1)
  DestinationAddress = DEVICE_ADDRESS_2; /* follower address */
#elif defined (DEVICE_2)
  DestinationAddress = DEVICE_ADDRESS_1; /* follower address */
#endif  
    
  /* -6- CEC configuration (transfer will take place in Interrupt mode) */
  hcec.Instance = CEC;
  /* Deinitialize CEC to reinitialize from scratch */
  HAL_CEC_DeInit(&hcec);
  /* IP configuration */ 
  CEC_Config(&hcec);
  

  /* -7- CEC transfer general variables initialization */
  ReceivedFrame = 0;
  StartSending = 0;
  NbOfReceivedBytes = 0;
  CEC_FlushRxBuffer();
  
  
  /* Test start */
    
  /* Enter infinite reception loop: the CEC device is set in
   * waiting to receive mode. 
   * The CEC "background" state is HAL_CEC_STATE_STANDBY_RX.
   * Upon any message reception or transmission, the CEC 
   * comes back to that state.
   * It is up to the user to define exit conditions in modifying
   * accordingly the RX, TX or Error callback functions. */
  HAL_CEC_Receive_IT(&hcec, (uint8_t *)&Tab_Rx); 
  while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY)
  {
    
    /* if no reception has occurred and no error has been detected,
     * transmit a message if the user has pushed a button */
    if( (StartSending == 1) && (ReceivedFrame == 0))
    { 
      HAL_CEC_Transmit_IT(&hcec, DestinationAddress, (uint8_t *)&Tab_Tx, TxSize);
      /* loop until TX ends or TX error reported */
        while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_STANDBY_RX);
      StartSending = 0;
    }  
    
    /* if a frame has been received */
    if (ReceivedFrame == 1)
    { 
      if (Tab_Rx[1] == 0x44) /* Test on the opcode value */
      {
        /* Receive command is equal to Volume Up(Button Up) */
        if (Tab_Rx[2] == 0x41) /* Test on the operand value */
        {       
          BSP_LED_On(LED1);
          BSP_LED_On(LED2);
          BSP_LED_On(LED3);
          BSP_LED_On(LED4);
        }
        else if (Tab_Rx[2] == 0x42) /* Receive command is equal to Volume Down(Button Down) */
        {
          BSP_LED_Off(LED1);
          BSP_LED_Off(LED2);
          BSP_LED_Off(LED3);
          BSP_LED_Off(LED4);
        }
      }
      else if (Tab_Rx[1] == 0x46) /* Test on the opcode value */
      {
        BSP_LED_On(LED1);
        BSP_LED_On(LED2);
        BSP_LED_Off(LED3);
        BSP_LED_Off(LED4);
      }
      else if (Tab_Rx[1] == 0x9F) /* Test on the opcode value */
      {
        BSP_LED_Off(LED1);
        BSP_LED_Off(LED2);
        BSP_LED_On(LED3);
        BSP_LED_On(LED4);
      }
      ReceivedFrame = 0;
    }
    else if (ReceivedFrame == 2) /* means CEC error detected */
    { 
      /* Turn on LED3 */
      BSP_LED_On(LED3);
      ReceivedFrame = 0;
    }
  }  /*  while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY) */
  
  return 0;
}
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
 /* This sample code shows how to use STM32F4xx CEC HAL API to transmit and 
  * receive data. The device is set in waiting to receive mode and sends
  * messages when the evaluation board buttons are pushed by the user */
  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure the system clock to 180 MHz */
  SystemClock_Config();

  /* -1- Initialize LEDs mounted on EVAL board */
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);

  /* -2- Configure User push-button in Interrupt mode */
  /* button-triggered interruptions initialization */
  BSP_PB_Init(BUTTON_TAMPER,BUTTON_MODE_EXTI);
  
  /* -3- Configure Joystick Selection push-button in Interrupt mode */
  BSP_JOY_Init(JOY_MODE_EXTI);

  
  /* CEC device initialization */
  /* -4- CEC configuration (transfer will take place in Interrupt mode) */
  
#if defined (DEVICE_1)
  /* Device 1: 
   * a single logical address ... */
  MyLogicalAddress1 = DEVICE_ADDRESS_1;
  /* ... and two different follower addresses */
  MyFollowerAddress1 = DEVICE_ADDRESS_2;
  MyFollowerAddress2 = DEVICE_ADDRESS_3;
#elif defined (DEVICE_2)
  /* Device 2: 
   * two different logical addresses ... */
  MyLogicalAddress1 = DEVICE_ADDRESS_2;
  MyLogicalAddress2 = DEVICE_ADDRESS_3;  
  /* ... and a single follower address */
  MyFollowerAddress1 = DEVICE_ADDRESS_1;
#endif /* DEVICE_1 */  
    
  /* -5- CEC configuration (transfer will take place in Interrupt mode) */
  hcec.Instance = CEC;
  /* Deinitialize CEC to reinitialize from scratch */
  HAL_CEC_DeInit(&hcec);
  /* IP configuration */ 
  CEC_Config(&hcec);
  

  /* -6- CEC transfer general variables initialization */
  ReceivedFrame = 0;
  StartSending = 0;
  NbOfReceivedBytes = 0;
  CEC_FlushRxBuffer();
  
  
  /* Test start */
    
  /* Enter infinite reception loop: the CEC device is set in
   * waiting to receive mode. 
   * The CEC "background" state is HAL_CEC_STATE_STANDBY_RX.
   * Upon any message reception or transmission, the CEC 
   * comes back to that state.
   * It is up to the user to define exit conditions in modifying
   * accordingly the RX, TX or Error callback functions. */
  HAL_CEC_Receive_IT(&hcec, (uint8_t *)&Tab_Rx); 
  while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY)
  {
    
    /* if no reception has occurred and no error has been detected,
     * transmit a message if the user has pushed a button */
    if( (StartSending == 1) && (ReceivedFrame == 0))
    { 
      HAL_CEC_Transmit_IT(&hcec, DestinationAddress, (uint8_t *)&Tab_Tx, TxSize);
      /* loop until TX ends or TX error reported */
        while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_STANDBY_RX);
      StartSending = 0;
    }  
    
    /* if a frame has been received */
    if (ReceivedFrame == 1)
    { 
      /* Test on the Destination Logical Address
       * (code applicable whatever the device):
       * if Receiver has address 0x01 */ 
      if ((Tab_Rx[0]&0x0F) == 0x01) 
      {
        /* Turn on LED1 */
        BSP_LED_On(LED1);
        /* Turn on LED4 */
        BSP_LED_On(LED4);
        /* Turn off LED3 */
        BSP_LED_Off(LED3);
        }
      /* if Receiver has address 0x03 */ 
      else if ((Tab_Rx[0]&0x0F) == 0x03) 
        {
        /* Turn on LED1 */
        BSP_LED_On(LED1);
        /* Turn off LED4 */
        BSP_LED_Off(LED4);
        /* Turn off LED3 */
        BSP_LED_Off(LED3);
        }
      /* if Receiver has address 0x05 */
      else if ((Tab_Rx[0]&0x0F) == 0x05) 
      {
        /* Turn on LED4 */
        BSP_LED_On(LED4);
        /* Turn off LED1 */
        BSP_LED_Off(LED1);
         /* Turn off LED3 */
        BSP_LED_Off(LED3);
      }
      /* if Broadcast message */
      else if ((Tab_Rx[0]&0x0F) == 0x0F) 
      {
        /* Turn off all LEDs */
        BSP_LED_Off(LED1);
        BSP_LED_Off(LED2);
        BSP_LED_Off(LED3);
        BSP_LED_Off(LED4);        
      }
      ReceivedFrame = 0;
    }
    else if (ReceivedFrame == 2) /* means CEC error detected */
    { 
      /* Turn on LED3 */
      BSP_LED_On(LED3);
      ReceivedFrame = 0;
    }
  }  /*  while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY) */
  return 0;
}
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32f0xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f0xx.c file
  */

  /* Initialize the LCD */
#ifdef USE_STM320518_EVAL
    STM320518_LCD_Init();
#else
    STM32072B_LCD_Init();
#endif /* USE_STM320518_EVAL */

  /* Initialize LEDs available on STM320518-EVAL board */
  /* Configure LED1, LED2, LED3 and LED4 */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

#if defined (DEVICE_1)
  MyLogicalAddress1 = DEVICE_ADDRESS_1;
  MyFollowerAddress = DEVICE_ADDRESS_2;
#elif defined (DEVICE_2)
  MyLogicalAddress1 = DEVICE_ADDRESS_2;
  MyFollowerAddress = DEVICE_ADDRESS_1;
#elif defined (DEVICE_3)
  MyLogicalAddress1 = DEVICE_ADDRESS_3;
#endif /* DEVICE_1 */

  /* CEC configuration */
  CEC_Config();

#if defined (DEVICE_3)
  LCD_Clear(LCD_COLOR_WHITE);
  LCD_SetBackColor(LCD_COLOR_BLACK);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)" Spy CEC Device  ");
#else

  /* Configure the Joystick button and its associated EXTI Line */
  STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(Button_UP, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(Button_DOWN, BUTTON_MODE_EXTI);

  /* Build the Header block to send */
  HeaderBlockValueToSend = (((MyLogicalAddress1 & 0xF) << 4)|(MyFollowerAddress & 0xF));

  /* Clear the LCD */
  LCD_Clear(LCD_COLOR_BLUE);
  LCD_SetBackColor(LCD_COLOR_BLACK);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)" Select CEC Command ");
  LCD_SetBackColor(LCD_COLOR_BLUE);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *)"RIGHT : OSD Name     ");
  LCD_DisplayStringLine(LCD_LINE_3, (uint8_t *)"LEFT  : CEC Version  ");
  LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"UP    : Volume Up    ");
  LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"DOWN  : Volume Down  ");
#endif /* DEVICE_3 */
  
  while(1)
  {
    /* If a frame has been received */
    while(ReceivedFrame1 == 0)
    {}

    if (ReceivedFrame1 == 1)
    {
      /* OK */
      if (ReceiveBuffer[1] ==0x44) /* Test on the opcode value */
      {
        /* Receive command is equal to Volume Up(Button Up) */
        if (ReceiveBuffer[2] == 0x41) /* Test on the operand value */
        {
          STM_EVAL_LEDOn(LED1);
          STM_EVAL_LEDOn(LED2);
          STM_EVAL_LEDOn(LED3);
          STM_EVAL_LEDOn(LED4);
        }/* Test on the operand value */
        else if (ReceiveBuffer[2] == 0x42) /* Receive command is equal to Volume Down(Button Down) */
        {
          STM_EVAL_LEDOff(LED1);
          STM_EVAL_LEDOff(LED2);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED4);
        }
      }
      else if (ReceiveBuffer[1] ==0x46) /* Test on the opcode value */
      {
        STM_EVAL_LEDOn(LED1);
        STM_EVAL_LEDOn(LED2);
        STM_EVAL_LEDOff(LED3);
        STM_EVAL_LEDOff(LED4);
      }
      else if (ReceiveBuffer[1] ==0x9F) /* Test on the opcode value */
      {
        STM_EVAL_LEDOff(LED1);
        STM_EVAL_LEDOff(LED2);
        STM_EVAL_LEDOn(LED3);
        STM_EVAL_LEDOn(LED4);
      }
      
      LCD_SetBackColor(LCD_COLOR_GREEN);
      LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"Receive : Succeeded ");
    }
    else
    {
      /* KO */
      /* Turn on LED2 */
      STM_EVAL_LEDOn(LED3);
      LCD_SetBackColor(LCD_COLOR_RED);
      LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"Receive : Failed   ");
    }
    ReceivedFrame1 = 0;

    for (rcv_inc=0;rcv_inc<10;rcv_inc++)
    {
      ReceiveBuffer[rcv_inc]=0;
    }
    rcv_inc=0;
  }
}
Пример #6
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
 /* This sample code shows how to use STM32F7xx CEC HAL API to transmit and 
  * receive data. The device is set in waiting to receive mode and sends
  * messages when the evaluation board buttons are pushed by the user */

  /* Configure the MPU attributes as Write Through */
  MPU_Config();

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
  
  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure the system clock to 200 MHz MHz */
  SystemClock_Config();


  /*##-1- Initialize the SDRAM  ##############################################*/
  BSP_SDRAM_Init();

  /*##-2- Initialize the LCD #################################################*/
  BSP_LCD_Init();
  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER);

  /* Enable the LCD */
  BSP_LCD_DisplayOn();

  /* Select the LCD Foreground layer */
  BSP_LCD_SelectLayer(1);

  /* Display test description on screen */
  CEC_SetHint();

  /* -2- Configure touch screen */
  BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
  BSP_TS_ITConfig();  /* Touch screen interrupt configuration and enable */
  
  /* -3- CEC configuration (transfer will take place in Interrupt mode) */
#if defined (DEVICE_1)
  DestinationAddress = DEVICE_ADDRESS_2; /* follower address */
#elif defined (DEVICE_2)
  DestinationAddress = DEVICE_ADDRESS_1; /* follower address */
#endif  
  hcec.Instance = CEC;
  /* Deinitialize CEC to reinitialize from scratch */
  HAL_CEC_DeInit(&hcec);
  /* IP configuration */ 
  CEC_Config(&hcec);
  

  /* -4- CEC transfer general variables initialization */
  ReceivedFrame = 0;
  StartSending = 0;
  NbOfReceivedBytes = 0;
  CEC_FlushRxBuffer();
  
  
  /* Test start */
    
  /* Enter infinite reception loop: the CEC device is set in
   * waiting to receive mode. 
   * The CEC "background" state is HAL_CEC_STATE_STANDBY_RX.
   * Upon any message reception or transmission, the CEC 
   * comes back to that state.
   * It is up to the user to define exit conditions in modifying
   * accordingly the RX, TX or Error callback functions. */
  HAL_CEC_Receive_IT(&hcec, (uint8_t *)&Tab_Rx); 
  while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY)
  {
    
    /* if no reception has occurred and no error has been detected,
     * transmit a message if the user has pushed a button */
    if( (StartSending == 1) && (ReceivedFrame == 0))
    { 
      HAL_CEC_Transmit_IT(&hcec, DestinationAddress, (uint8_t *)&Tab_Tx, TxSize);
      /* loop until TX ends or TX error reported */
      while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_STANDBY_RX);
      StartSending = 0;
    }  
    
    /* if a frame has been received */
    if (ReceivedFrame == 1)
    { 
      if (Tab_Rx[1] == 0x44) /* Test on the opcode value */
      {
        /* Receive command is equal to Command 1 */
        if (Tab_Rx[2] == 0x41) /* Test on the operand value */
        {       
          BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
          BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
          BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2)+30, (uint8_t *)"  Received opcode 44, operand 41  ", CENTER_MODE);
        }
        else if (Tab_Rx[2] == 0x42) /* Receive command is equal to Command 2 */
        {
          BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
          BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
          BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2)+30, (uint8_t *)"  Received opcode 44, operand 42  ", CENTER_MODE);
        }
      }
      else if (Tab_Rx[1] == 0x46) /* Test on the opcode value */
      {
        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
        BSP_LCD_SetBackColor(LCD_COLOR_ORANGE);
        BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2)+30, (uint8_t *)"       Received opcode 46         ", CENTER_MODE);
      }
      else if (Tab_Rx[1] == 0x9F) /* Test on the opcode value */
      {
        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
        BSP_LCD_SetBackColor(LCD_COLOR_DARKMAGENTA);
        BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2)+30, (uint8_t *)"       Received opcode 9F         ", CENTER_MODE);
      }
      ReceivedFrame = 0;
    }
    else if (ReceivedFrame == 2) /* means CEC error detected */
    { 
      BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
      BSP_LCD_SetBackColor(LCD_COLOR_RED);
      BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2)+45, (uint8_t *)"            CEC Error             ", CENTER_MODE);
      ReceivedFrame = 0;
    }
  }  /*  while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY) */
  return 0;
}