STM32F0xx Standard Peripherals Firmware Library
|
STM32F0xx_StdPeriph_Examples/USART/USART_TwoBoards/DataExchangeDMA/main.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file USART/USART_TwoBoards/DataExchangeDMA/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>© 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 /* Communication boards USART Interface */ 00054 #ifdef USE_STM320518_EVAL 00055 #define USARTx_TDR_ADDRESS 0x40013828 00056 #define USARTx_RDR_ADDRESS 0x40013824 00057 00058 #define USARTx_TX_DMA_CHANNEL DMA1_Channel2 00059 #define USARTx_TX_DMA_FLAG_TC DMA1_FLAG_TC2 00060 #define USARTx_TX_DMA_FLAG_GL DMA1_FLAG_GL2 00061 #define USARTx_RX_DMA_CHANNEL DMA1_Channel3 00062 #define USARTx_RX_DMA_FLAG_TC DMA1_FLAG_TC3 00063 #define USARTx_RX_DMA_FLAG_GL DMA1_FLAG_GL3 00064 #else 00065 #define USARTx_TDR_ADDRESS 0x40004428 00066 #define USARTx_RDR_ADDRESS 0x40004424 00067 00068 #define USARTx_TX_DMA_CHANNEL DMA1_Channel4 00069 #define USARTx_TX_DMA_FLAG_TC DMA1_FLAG_TC4 00070 #define USARTx_TX_DMA_FLAG_GL DMA1_FLAG_GL4 00071 #define USARTx_RX_DMA_CHANNEL DMA1_Channel5 00072 #define USARTx_RX_DMA_FLAG_TC DMA1_FLAG_TC5 00073 #define USARTx_RX_DMA_FLAG_GL DMA1_FLAG_GL5 00074 #endif /* USE_STM320518_EVAL */ 00075 00076 #define DMAx_CLK RCC_AHBPeriph_DMA1 00077 00078 /* USART Communication boards Interface */ 00079 #ifdef USE_STM320518_EVAL 00080 #define USARTx USART1 00081 #define USARTx_CLK RCC_APB2Periph_USART1 00082 #define USARTx_APBPERIPHCLOCK RCC_APB2PeriphClockCmd 00083 #define USARTx_IRQn USART1_IRQn 00084 #define USARTx_IRQHandler USART1_IRQHandler 00085 00086 #define USARTx_TX_PIN GPIO_Pin_9 00087 #define USARTx_TX_GPIO_PORT GPIOA 00088 #define USARTx_TX_GPIO_CLK RCC_AHBPeriph_GPIOA 00089 #define USARTx_TX_SOURCE GPIO_PinSource9 00090 #define USARTx_TX_AF GPIO_AF_1 00091 00092 #define USARTx_RX_PIN GPIO_Pin_10 00093 #define USARTx_RX_GPIO_PORT GPIOA 00094 #define USARTx_RX_GPIO_CLK RCC_AHBPeriph_GPIOA 00095 #define USARTx_RX_SOURCE GPIO_PinSource10 00096 #define USARTx_RX_AF GPIO_AF_1 00097 #else 00098 #define USARTx USART2 00099 #define USARTx_CLK RCC_APB1Periph_USART2 00100 #define USARTx_APBPERIPHCLOCK RCC_APB1PeriphClockCmd 00101 #define USARTx_IRQn USART2_IRQn 00102 #define USARTx_IRQHandler USART2_IRQHandler 00103 00104 #define USARTx_TX_PIN GPIO_Pin_5 00105 #define USARTx_TX_GPIO_PORT GPIOD 00106 #define USARTx_TX_GPIO_CLK RCC_AHBPeriph_GPIOD 00107 #define USARTx_TX_SOURCE GPIO_PinSource5 00108 #define USARTx_TX_AF GPIO_AF_0 00109 00110 #define USARTx_RX_PIN GPIO_Pin_6 00111 #define USARTx_RX_GPIO_PORT GPIOD 00112 #define USARTx_RX_GPIO_CLK RCC_AHBPeriph_GPIOD 00113 #define USARTx_RX_SOURCE GPIO_PinSource6 00114 #define USARTx_RX_AF GPIO_AF_0 00115 #endif /* USE_STM320518_EVAL */ 00116 00117 #define TXBUFFERSIZE (countof(TxBuffer) - 1) 00118 #define RXBUFFERSIZE TXBUFFERSIZE 00119 00120 /* Joystick Commands */ 00121 #define CMD_RIGHT 0x55 00122 #define CMD_LEFT 0xAA 00123 #define CMD_UP 0x33 00124 #define CMD_DOWN 0xCC 00125 #define CMD_SEL 0xFF 00126 00127 #define CMD_ACK 0x66 00128 00129 /* Define numbers of bytes to transmit from TxBuffer */ 00130 #define CMD_RIGHT_SIZE 0x01 00131 #define CMD_LEFT_SIZE 0x05 00132 #define CMD_UP_SIZE 0x14 00133 #define CMD_DOWN_SIZE 0x1E 00134 #define CMD_SEL_SIZE TXBUFFERSIZE 00135 00136 /* Exported types ------------------------------------------------------------*/ 00137 /* Exported constants --------------------------------------------------------*/ 00138 /* Exported macro ------------------------------------------------------------*/ 00139 /* Exported functions ------------------------------------------------------- */ 00140 00141 00142 #endif /* __MAIN_H */ 00143 00144 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/