text: /**
    ******************************************************************************
    * @file    USART/USART_TwoBoards/DataExchangeInterrupt/main.h
    * @author  MCD Application Team
    * @version V1.2.2
    * @date    17-November-2021
    * @brief   Main program body
    ******************************************************************************
    * @attention
    *
    * Copyright (c) 2015 STMicroelectronics.
    * All rights reserved.
    *
    * This software is licensed under terms that can be found in the LICENSE file
    * in the root directory of this software component.
    * If no LICENSE file comes with this software, it is provided AS-IS.
    *
    ******************************************************************************
    */
  
  /* Define to prevent recursive inclusion -------------------------------------*/
  #ifndef __MAIN_H
  #define __MAIN_H
  
  #ifdef __cplusplus
   extern "C" {
  #endif 
  
  /* Includes ------------------------------------------------------------------*/
  #include "stm32l1xx.h"
  
  #ifdef USE_STM32L152D_EVAL 
    #include "stm32l152d_eval.h"
  #elif defined USE_STM32L152_EVAL 
    #include "stm32l152_eval.h"
  #endif 
  
  
  /* Exported typedef -----------------------------------------------------------*/
  #define countof(a)   (sizeof(a) / sizeof(*(a)))
  typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;
  
  /* Exported define ------------------------------------------------------------*/
  
  /* USER_TIMEOUT value for waiting loops. This timeout is just guarantee that the
     application will not remain stuck if the USART communication is corrupted. 
     You may modify this timeout value depending on CPU frequency and application
     conditions (interrupts routines, number of data to transfer, baudrate, frequence
     CPU...). */ 
  #define USER_TIMEOUT                    ((uint32_t)0x64) /* Waiting 1s */
  
  /* USART Mode Selected */
  #define USART_MODE_TRANSMITTER           0x00
  #define USART_MODE_RECEIVER              0x01      
  /* USART Transaction Type */
  #define USART_TRANSACTIONTYPE_CMD        0x00
  #define USART_TRANSACTIONTYPE_DATA       0x01
  
  /* USART Communication boards Interface */
  #define USARTx                           USART1
  #define USARTx_CLK                       RCC_APB2Periph_USART1
  #define USARTx_APBPERIPHCLOCK            RCC_APB2PeriphClockCmd
  #define USARTx_IRQn                      USART1_IRQn
  #define USARTx_IRQHandler                USART1_IRQHandler
  
  #define USARTx_TX_PIN                    GPIO_Pin_9                
  #define USARTx_TX_GPIO_PORT              GPIOA                       
  #define USARTx_TX_GPIO_CLK               RCC_AHBPeriph_GPIOA
  #define USARTx_TX_SOURCE                 GPIO_PinSource9
  #define USARTx_TX_AF                     GPIO_AF_USART1
  
  #define USARTx_RX_PIN                    GPIO_Pin_10                
  #define USARTx_RX_GPIO_PORT              GPIOA                    
  #define USARTx_RX_GPIO_CLK               RCC_AHBPeriph_GPIOA
  #define USARTx_RX_SOURCE                 GPIO_PinSource10
  #define USARTx_RX_AF                     GPIO_AF_USART1
  
  #define TXBUFFERSIZE                     (countof(TxBuffer) - 1)
  #define RXBUFFERSIZE                     TXBUFFERSIZE
  
  /* Joystick Commands */
  #define CMD_RIGHT                        0x55
  #define CMD_LEFT                         0xAA
  #define CMD_UP                           0x33
  #define CMD_DOWN                         0xCC
  #define CMD_SEL                          0xFF 
  
  #define CMD_ACK                          0x66 
  
  /* Define numbers of bytes to transmit from TxBuffer */
  #define CMD_RIGHT_SIZE                   0x01
  #define CMD_LEFT_SIZE                    0x05
  #define CMD_UP_SIZE                      0x14
  #define CMD_DOWN_SIZE                    0x1E
  #define CMD_SEL_SIZE                     TXBUFFERSIZE
  
  /* Exported types ------------------------------------------------------------*/
  /* Exported constants --------------------------------------------------------*/
  /* Exported macro ------------------------------------------------------------*/
  /* Exported functions ------------------------------------------------------- */
  uint8_t GetVar_NbrOfData(void);
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* __MAIN_H */
  
  