STM32F0xx Standard Peripherals Firmware Library: main.h Source File

STM32F0xx Standard Peripherals Library

STM32F0xx_StdPeriph_Examples/SPI/SPI_TwoBoards/DataExchangeDMA/main.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    SPI/SPI_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>&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 /* Uncomment the line below if you will use the SPI peripheral as a Master */
00047 #define SPI_MASTER 
00048 /* Uncomment the line below if you will use the SPI peripheral as a Slave */
00049 //#define SPI_SLAVE
00050 
00051 /* Uncomment the size of data to be transmetted (only one data size must be selected) */
00052 #define SPI_DATASIZE_8
00053 //#define SPI_DATASIZE_7
00054 //#define SPI_DATASIZE_6
00055 //#define SPI_DATASIZE_5
00056 
00057 /* USER_TIMEOUT value for waiting loops. This timeout is just guarantee that the
00058    application will not remain stuck if the USART communication is corrupted. 
00059    You may modify this timeout value depending on CPU frequency and application
00060    conditions (interrupts routines, number of data to transfer, baudrate, CPU
00061    frequency...). */ 
00062 #define USER_TIMEOUT                    ((uint32_t)0x64) /* Waiting 1s */
00063 
00064 /* Communication boards SPIx Interface */
00065 #define SPIx_DR_ADDRESS                  0x4001300C
00066 #define SPIx_TX_DMA_CHANNEL              DMA1_Channel3
00067 #define SPIx_TX_DMA_FLAG_TC              DMA1_FLAG_TC3
00068 #define SPIx_TX_DMA_FLAG_GL              DMA1_FLAG_GL3
00069 #define SPIx_RX_DMA_CHANNEL              DMA1_Channel2
00070 #define SPIx_RX_DMA_FLAG_TC              DMA1_FLAG_TC2
00071 #define SPIx_RX_DMA_FLAG_GL              DMA1_FLAG_GL2
00072 
00073 #define DMAx_CLK                         RCC_AHBPeriph_DMA1
00074 
00075 #define SPIx                             SPI1
00076 #define SPIx_CLK                         RCC_APB2Periph_SPI1
00077 #define SPIx_IRQn                        SPI1_IRQn
00078 #define SPIx_IRQHandler                  SPI1_IRQHandler
00079 
00080 #ifdef USE_STM320518_EVAL
00081   #define SPIx_SCK_PIN                     GPIO_Pin_5
00082   #define SPIx_SCK_GPIO_PORT               GPIOA
00083   #define SPIx_SCK_GPIO_CLK                RCC_AHBPeriph_GPIOA
00084   #define SPIx_SCK_SOURCE                  GPIO_PinSource5
00085   #define SPIx_SCK_AF                      GPIO_AF_0
00086 
00087   #define SPIx_MISO_PIN                    GPIO_Pin_4
00088   #define SPIx_MISO_GPIO_PORT              GPIOB
00089   #define SPIx_MISO_GPIO_CLK               RCC_AHBPeriph_GPIOB
00090   #define SPIx_MISO_SOURCE                 GPIO_PinSource4
00091   #define SPIx_MISO_AF                     GPIO_AF_0
00092 
00093   #define SPIx_MOSI_PIN                    GPIO_Pin_7
00094   #define SPIx_MOSI_GPIO_PORT              GPIOA
00095   #define SPIx_MOSI_GPIO_CLK               RCC_AHBPeriph_GPIOA
00096   #define SPIx_MOSI_SOURCE                 GPIO_PinSource7
00097   #define SPIx_MOSI_AF                     GPIO_AF_0
00098 
00099   #define SPIx_NSS_PIN                     GPIO_Pin_15
00100   #define SPIx_NSS_GPIO_PORT               GPIOA
00101   #define SPIx_NSS_GPIO_CLK                RCC_AHBPeriph_GPIOA
00102   #define SPIx_NSS_SOURCE                  GPIO_PinSource15
00103   #define SPIx_NSS_AF                      GPIO_AF_0
00104 #else 
00105   #define SPIx_SCK_PIN                     GPIO_Pin_3                  /* PB.03 */
00106   #define SPIx_SCK_GPIO_PORT               GPIOB                       /* GPIOB */
00107   #define SPIx_SCK_GPIO_CLK                RCC_AHBPeriph_GPIOB
00108   #define SPIx_SCK_SOURCE                  GPIO_PinSource3
00109   #define SPIx_SCK_AF                      GPIO_AF_0
00110 
00111   #define SPIx_MISO_PIN                    GPIO_Pin_14                  /* PE.14 */
00112   #define SPIx_MISO_GPIO_PORT              GPIOE                       /* GPIOE */
00113   #define SPIx_MISO_GPIO_CLK               RCC_AHBPeriph_GPIOE
00114   #define SPIx_MISO_SOURCE                 GPIO_PinSource14
00115   #define SPIx_MISO_AF                     GPIO_AF_1
00116 
00117   #define SPIx_MOSI_PIN                    GPIO_Pin_15                  /* PE.15 */
00118   #define SPIx_MOSI_GPIO_PORT              GPIOE                       /* GPIOE */
00119   #define SPIx_MOSI_GPIO_CLK               RCC_AHBPeriph_GPIOE
00120   #define SPIx_MOSI_SOURCE                 GPIO_PinSource15
00121   #define SPIx_MOSI_AF                     GPIO_AF_1
00122 
00123   #define SPIx_NSS_PIN                     GPIO_Pin_15
00124   #define SPIx_NSS_GPIO_PORT               GPIOA
00125   #define SPIx_NSS_GPIO_CLK                RCC_AHBPeriph_GPIOA
00126   #define SPIx_NSS_SOURCE                  GPIO_PinSource15
00127   #define SPIx_NSS_AF                      GPIO_AF_0
00128 #endif /* USE_STM320518_EVAL */
00129 
00130 /* TIM Trigger Configuration */
00131 #define TIMx                             TIM2
00132 #define TIMx_CLK                         RCC_APB1Periph_TIM2
00133 #define TIMx_DMA_CHANNEL                 TIM_DMA_CC2
00134 
00135 #define TIMx_TRIGGER_PIN                 GPIO_Pin_1
00136 #define TIMx_TRIGGER_GPIO_PORT           GPIOA
00137 #define TIMx_TRIGGER_GPIO_CLK            RCC_AHBPeriph_GPIOA
00138 #define TIMx_TRIGGER_SOURCE              GPIO_PinSource1
00139 #define TIMx_TRIGGER_AF                  GPIO_AF_2
00140 #define TIMx_CHANNEL_INIT                TIM_OC2Init
00141 #define TIMx_CHANNEL_DMA_CHANNEL         DMA1_Channel3
00142 #define TIMx_CHANNEL_DMA_FLAG_TC         DMA1_FLAG_TC3
00143 #define TIMx_CHANNEL_DMA_FLAG_GL         DMA1_FLAG_GL3
00144 
00145 #define TXBUFFERSIZE                     (countof(TxBuffer) - 1)
00146 #define RXBUFFERSIZE                     TXBUFFERSIZE
00147 
00148 /* Joystick Commands */
00149 #define CMD_RIGHT                        0x15
00150 #define CMD_LEFT                         0x1A
00151 #define CMD_UP                           0x13
00152 #define CMD_DOWN                         0x1C
00153 #define CMD_SEL                          0x1F 
00154 
00155 #define CMD_ACK                          0x16 
00156 
00157 /* Define numbers of bytes to transmit from TxBuffer */
00158 #define CMD_RIGHT_SIZE                   0x01
00159 #define CMD_LEFT_SIZE                    0x05
00160 #define CMD_UP_SIZE                      0x14
00161 #define CMD_DOWN_SIZE                    0x1E
00162 #define CMD_SEL_SIZE                     TXBUFFERSIZE
00163 
00164 /* Define data size and data masks */
00165 #ifdef SPI_DATASIZE_8
00166  #define SPI_DATASIZE                     SPI_DataSize_8b
00167  #define SPI_DATAMASK                     (uint8_t)0xFF
00168 #elif defined (SPI_DATASIZE_7)
00169  #define SPI_DATASIZE                     SPI_DataSize_7b
00170  #define SPI_DATAMASK                     (uint8_t)0x7F
00171 #elif defined (SPI_DATASIZE_6)
00172  #define SPI_DATASIZE                     SPI_DataSize_6b
00173  #define SPI_DATAMASK                     (uint8_t)0x3F
00174 #elif defined (SPI_DATASIZE_5)
00175  #define SPI_DATASIZE                     SPI_DataSize_5b
00176  #define SPI_DATAMASK                     (uint8_t)0x1F
00177 #else
00178  #error " Select at least one data size in main.h file " 
00179 #endif
00180 
00181 /* TIM2 Autoreload and Capture Compare register values */
00182 #define TIM_ARR                          ((uint16_t)0x2EDF)
00183 #define TIM_CCR                          ((uint16_t)0x1770)
00184 
00185 /* Exported types ------------------------------------------------------------*/
00186 /* Exported constants --------------------------------------------------------*/
00187 /* Exported macro ------------------------------------------------------------*/
00188 /* Exported functions ------------------------------------------------------- */
00189 
00190 #endif /* __MAIN_H */
00191 
00192 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM32L1xx Standard Peripherals Library: Footer

 

 

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