STM32F0xx Standard Peripherals Firmware Library: main.h Source File

STM32F0xx Standard Peripherals Library

STM32F0xx_StdPeriph_Examples/SPI/SPI_TwoBoards/DataExchangeInterrupt/main.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    SPI/SPI_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 /* 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 
00058 /* USE//R_TIMEOUT value for waiting loops. This timeout is just guarantee that the
00059    application will not remain stuck if the USART communication is corrupted. 
00060    You may modify this timeout value depending on CPU frequency and application
00061    conditions (interrupts routines, number of data to transfer, baudrate, CPU
00062    frequency...). */ 
00063 #define USER_TIMEOUT                    ((uint32_t)0x64) /* Waiting 1s */
00064 
00065 /* Communication boards SPIx Interface */
00066 #define SPIx                             SPI1
00067 #define SPIx_CLK                         RCC_APB2Periph_SPI1
00068 #define SPIx_IRQn                        SPI1_IRQn
00069 #define SPIx_IRQHandler                  SPI1_IRQHandler
00070 
00071 #ifdef USE_STM320518_EVAL
00072   #define SPIx_SCK_PIN                     GPIO_Pin_5
00073   #define SPIx_SCK_GPIO_PORT               GPIOA
00074   #define SPIx_SCK_GPIO_CLK                RCC_AHBPeriph_GPIOA
00075   #define SPIx_SCK_SOURCE                  GPIO_PinSource5
00076   #define SPIx_SCK_AF                      GPIO_AF_0
00077 
00078   #define SPIx_MISO_PIN                    GPIO_Pin_4
00079   #define SPIx_MISO_GPIO_PORT              GPIOB
00080   #define SPIx_MISO_GPIO_CLK               RCC_AHBPeriph_GPIOB
00081   #define SPIx_MISO_SOURCE                 GPIO_PinSource4
00082   #define SPIx_MISO_AF                     GPIO_AF_0
00083 
00084   #define SPIx_MOSI_PIN                    GPIO_Pin_7
00085   #define SPIx_MOSI_GPIO_PORT              GPIOA
00086   #define SPIx_MOSI_GPIO_CLK               RCC_AHBPeriph_GPIOA
00087   #define SPIx_MOSI_SOURCE                 GPIO_PinSource7
00088   #define SPIx_MOSI_AF                     GPIO_AF_0
00089 #else 
00090   #define SPIx_SCK_PIN                     GPIO_Pin_3                  /* PB.03 */
00091   #define SPIx_SCK_GPIO_PORT               GPIOB                       /* GPIOB */
00092   #define SPIx_SCK_GPIO_CLK                RCC_AHBPeriph_GPIOB
00093   #define SPIx_SCK_SOURCE                  GPIO_PinSource3
00094   #define SPIx_SCK_AF                      GPIO_AF_0
00095 
00096   #define SPIx_MISO_PIN                    GPIO_Pin_14                  /* PE.14 */
00097   #define SPIx_MISO_GPIO_PORT              GPIOE                       /* GPIOE */
00098   #define SPIx_MISO_GPIO_CLK               RCC_AHBPeriph_GPIOE
00099   #define SPIx_MISO_SOURCE                 GPIO_PinSource14
00100   #define SPIx_MISO_AF                     GPIO_AF_1
00101 
00102   #define SPIx_MOSI_PIN                    GPIO_Pin_15                  /* PE.15 */
00103   #define SPIx_MOSI_GPIO_PORT              GPIOE                       /* GPIOE */
00104   #define SPIx_MOSI_GPIO_CLK               RCC_AHBPeriph_GPIOE
00105   #define SPIx_MOSI_SOURCE                 GPIO_PinSource15
00106   #define SPIx_MOSI_AF                     GPIO_AF_1
00107 #endif /* USE_STM320518_EVAL */
00108 
00109 #define TXBUFFERSIZE                     (countof(TxBuffer) - 1)
00110 #define RXBUFFERSIZE                     TXBUFFERSIZE
00111 
00112 /* Joystick Commands */
00113 #define CMD_RIGHT                        0x15
00114 #define CMD_LEFT                         0x1A
00115 #define CMD_UP                           0x13
00116 #define CMD_DOWN                         0x1C
00117 #define CMD_SEL                          0x1F 
00118 
00119 #define CMD_ACK                          0x16 
00120 
00121 /* Define numbers of bytes to transmit from TxBuffer */
00122 #define DATA_SIZE                        TXBUFFERSIZE
00123 
00124 /* Define data size and data masks */
00125 #ifdef SPI_DATASIZE_8
00126  #define SPI_DATASIZE                     SPI_DataSize_8b
00127  #define SPI_DATAMASK                     (uint8_t)0xFF
00128 #elif defined (SPI_DATASIZE_7)
00129  #define SPI_DATASIZE                     SPI_DataSize_7b
00130  #define SPI_DATAMASK                     (uint8_t)0x7F
00131 #elif defined (SPI_DATASIZE_6)
00132  #define SPI_DATASIZE                     SPI_DataSize_6b
00133  #define SPI_DATAMASK                     (uint8_t)0x3F
00134 #elif defined (SPI_DATASIZE_5)
00135  #define SPI_DATASIZE                     SPI_DataSize_5b
00136  #define SPI_DATAMASK                     (uint8_t)0x1F
00137 #else
00138  #error " Select at least one data size in main.h file " 
00139 #endif
00140 
00141 /* Exported types ------------------------------------------------------------*/
00142 /* Exported constants --------------------------------------------------------*/
00143 /* Exported macro ------------------------------------------------------------*/
00144 /* Exported functions ------------------------------------------------------- */
00145 uint8_t GetVar_NbrOfData(void);
00146 
00147 #endif /* __MAIN_H */
00148 
00149 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM32L1xx Standard Peripherals Library: Footer

 

 

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