STM32F0xx Standard Peripherals Firmware Library: main.h Source File

STM32F0xx Standard Peripherals Library

STM32F0xx_StdPeriph_Examples/USART/USART_TwoBoards/DataExchangeInterrupt/main.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    USART/USART_TwoBoards/DataExchangeInterrupt/main.h 
00004   * @author  MCD Application Team
00005   * @version V1.4.0
00006   * @date    24-July-2014
00007   * @brief   Header for main.c module
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */
00027   
00028 /* Define to prevent recursive inclusion -------------------------------------*/
00029 #ifndef __MAIN_H
00030 #define __MAIN_H
00031 
00032 /* Includes ------------------------------------------------------------------*/
00033 #include "stm32f0xx.h"
00034 #ifdef USE_STM320518_EVAL
00035   #include "stm320518_eval.h"
00036 #else 
00037   #include "stm32072b_eval.h"
00038 #endif /* USE_STM320518_EVAL */
00039 
00040 /* Exported typedef ----------------------------------------------------------*/
00041 #define countof(a)   (sizeof(a) / sizeof(*(a)))
00042 typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;
00043 
00044 /* Exported define -----------------------------------------------------------*/
00045 
00046 /* USER_TIMEOUT value for waiting loops. This timeout is just guarantee that the
00047    application will not remain stuck if the USART communication is corrupted. 
00048    You may modify this timeout value depending on CPU frequency and application
00049    conditions (interrupts routines, number of data to transfer, baudrate, CPU
00050    frequency...). */ 
00051 #define USER_TIMEOUT                    ((uint32_t)0x64) /* Waiting 1s */
00052 
00053 /* USART Mode Selected */
00054 #define USART_MODE_TRANSMITTER           0x00
00055 #define USART_MODE_RECEIVER              0x01      
00056 /* USART Transaction Type */
00057 #define USART_TRANSACTIONTYPE_CMD        0x00
00058 #define USART_TRANSACTIONTYPE_DATA       0x01
00059 
00060 /* USART Communication boards Interface */
00061 #ifdef USE_STM320518_EVAL
00062   #define USARTx                           USART1
00063   #define USARTx_CLK                       RCC_APB2Periph_USART1
00064   #define USARTx_APBPERIPHCLOCK            RCC_APB2PeriphClockCmd
00065   #define USARTx_IRQn                      USART1_IRQn
00066   #define USARTx_IRQHandler                USART1_IRQHandler
00067 
00068   #define USARTx_TX_PIN                    GPIO_Pin_9
00069   #define USARTx_TX_GPIO_PORT              GPIOA
00070   #define USARTx_TX_GPIO_CLK               RCC_AHBPeriph_GPIOA
00071   #define USARTx_TX_SOURCE                 GPIO_PinSource9
00072   #define USARTx_TX_AF                     GPIO_AF_1
00073 
00074   #define USARTx_RX_PIN                    GPIO_Pin_10          
00075   #define USARTx_RX_GPIO_PORT              GPIOA            
00076   #define USARTx_RX_GPIO_CLK               RCC_AHBPeriph_GPIOA
00077   #define USARTx_RX_SOURCE                 GPIO_PinSource10
00078   #define USARTx_RX_AF                     GPIO_AF_1
00079 #else 
00080   #define USARTx                           USART2
00081   #define USARTx_CLK                       RCC_APB1Periph_USART2
00082   #define USARTx_APBPERIPHCLOCK            RCC_APB1PeriphClockCmd
00083   #define USARTx_IRQn                      USART2_IRQn
00084   #define USARTx_IRQHandler                USART2_IRQHandler
00085 
00086   #define USARTx_TX_PIN                    GPIO_Pin_5
00087   #define USARTx_TX_GPIO_PORT              GPIOD
00088   #define USARTx_TX_GPIO_CLK               RCC_AHBPeriph_GPIOD
00089   #define USARTx_TX_SOURCE                 GPIO_PinSource5
00090   #define USARTx_TX_AF                     GPIO_AF_0
00091 
00092   #define USARTx_RX_PIN                    GPIO_Pin_6          
00093   #define USARTx_RX_GPIO_PORT              GPIOD              
00094   #define USARTx_RX_GPIO_CLK               RCC_AHBPeriph_GPIOD
00095   #define USARTx_RX_SOURCE                 GPIO_PinSource6
00096   #define USARTx_RX_AF                     GPIO_AF_0
00097 #endif /* USE_STM320518_EVAL */
00098 
00099 #define TXBUFFERSIZE                     (countof(TxBuffer) - 1)
00100 #define RXBUFFERSIZE                     TXBUFFERSIZE
00101 
00102 /* Joystick Commands */
00103 #define CMD_RIGHT                        0x55
00104 #define CMD_LEFT                         0xAA
00105 #define CMD_UP                           0x33
00106 #define CMD_DOWN                         0xCC
00107 #define CMD_SEL                          0xFF 
00108 
00109 #define CMD_ACK                          0x66 
00110 
00111 /* Define numbers of bytes to transmit from TxBuffer */
00112 #define CMD_RIGHT_SIZE                   0x01
00113 #define CMD_LEFT_SIZE                    0x05
00114 #define CMD_UP_SIZE                      0x14
00115 #define CMD_DOWN_SIZE                    0x1E
00116 #define CMD_SEL_SIZE                     TXBUFFERSIZE
00117 
00118 /* Exported types ------------------------------------------------------------*/
00119 /* Exported constants --------------------------------------------------------*/
00120 /* Exported macro ------------------------------------------------------------*/
00121 /* Exported functions ------------------------------------------------------- */
00122 uint8_t GetVar_NbrOfData(void);
00123 
00124 #endif /* __MAIN_H */
00125 
00126 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM32L1xx Standard Peripherals Library: Footer

 

 

 For complete documentation on STM32 Microcontrollers visit www.st.com/STM32