A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tushki7 0:60d829a0353a 1 /**
tushki7 0:60d829a0353a 2 ******************************************************************************
tushki7 0:60d829a0353a 3 * @file stm32f0xx_hal_spi.h
tushki7 0:60d829a0353a 4 * @author MCD Application Team
tushki7 0:60d829a0353a 5 * @version V1.2.0
tushki7 0:60d829a0353a 6 * @date 11-December-2014
tushki7 0:60d829a0353a 7 * @brief Header file of SPI HAL module.
tushki7 0:60d829a0353a 8 ******************************************************************************
tushki7 0:60d829a0353a 9 * @attention
tushki7 0:60d829a0353a 10 *
tushki7 0:60d829a0353a 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
tushki7 0:60d829a0353a 12 *
tushki7 0:60d829a0353a 13 * Redistribution and use in source and binary forms, with or without modification,
tushki7 0:60d829a0353a 14 * are permitted provided that the following conditions are met:
tushki7 0:60d829a0353a 15 * 1. Redistributions of source code must retain the above copyright notice,
tushki7 0:60d829a0353a 16 * this list of conditions and the following disclaimer.
tushki7 0:60d829a0353a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
tushki7 0:60d829a0353a 18 * this list of conditions and the following disclaimer in the documentation
tushki7 0:60d829a0353a 19 * and/or other materials provided with the distribution.
tushki7 0:60d829a0353a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
tushki7 0:60d829a0353a 21 * may be used to endorse or promote products derived from this software
tushki7 0:60d829a0353a 22 * without specific prior written permission.
tushki7 0:60d829a0353a 23 *
tushki7 0:60d829a0353a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
tushki7 0:60d829a0353a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
tushki7 0:60d829a0353a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
tushki7 0:60d829a0353a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
tushki7 0:60d829a0353a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
tushki7 0:60d829a0353a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
tushki7 0:60d829a0353a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
tushki7 0:60d829a0353a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
tushki7 0:60d829a0353a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
tushki7 0:60d829a0353a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tushki7 0:60d829a0353a 34 *
tushki7 0:60d829a0353a 35 ******************************************************************************
tushki7 0:60d829a0353a 36 */
tushki7 0:60d829a0353a 37
tushki7 0:60d829a0353a 38 /* Define to prevent recursive inclusion -------------------------------------*/
tushki7 0:60d829a0353a 39 #ifndef __STM32F0xx_HAL_SPI_H
tushki7 0:60d829a0353a 40 #define __STM32F0xx_HAL_SPI_H
tushki7 0:60d829a0353a 41
tushki7 0:60d829a0353a 42 #ifdef __cplusplus
tushki7 0:60d829a0353a 43 extern "C" {
tushki7 0:60d829a0353a 44 #endif
tushki7 0:60d829a0353a 45
tushki7 0:60d829a0353a 46 /* Includes ------------------------------------------------------------------*/
tushki7 0:60d829a0353a 47 #include "stm32f0xx_hal_def.h"
tushki7 0:60d829a0353a 48
tushki7 0:60d829a0353a 49 /** @addtogroup STM32F0xx_HAL_Driver
tushki7 0:60d829a0353a 50 * @{
tushki7 0:60d829a0353a 51 */
tushki7 0:60d829a0353a 52
tushki7 0:60d829a0353a 53 /** @addtogroup SPI
tushki7 0:60d829a0353a 54 * @{
tushki7 0:60d829a0353a 55 */
tushki7 0:60d829a0353a 56
tushki7 0:60d829a0353a 57 /* Exported types ------------------------------------------------------------*/
tushki7 0:60d829a0353a 58 /** @defgroup SPI_Exported_Types SPI Exported Types
tushki7 0:60d829a0353a 59 * @{
tushki7 0:60d829a0353a 60 */
tushki7 0:60d829a0353a 61
tushki7 0:60d829a0353a 62 /**
tushki7 0:60d829a0353a 63 * @brief SPI Configuration Structure definition
tushki7 0:60d829a0353a 64 */
tushki7 0:60d829a0353a 65 typedef struct
tushki7 0:60d829a0353a 66 {
tushki7 0:60d829a0353a 67 uint32_t Mode; /*!< Specifies the SPI operating mode.
tushki7 0:60d829a0353a 68 This parameter can be a value of @ref SPI_mode */
tushki7 0:60d829a0353a 69
tushki7 0:60d829a0353a 70 uint32_t Direction; /*!< Specifies the SPI bidirectional mode state.
tushki7 0:60d829a0353a 71 This parameter can be a value of @ref SPI_Direction */
tushki7 0:60d829a0353a 72
tushki7 0:60d829a0353a 73 uint32_t DataSize; /*!< Specifies the SPI data size.
tushki7 0:60d829a0353a 74 This parameter can be a value of @ref SPI_data_size */
tushki7 0:60d829a0353a 75
tushki7 0:60d829a0353a 76 uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
tushki7 0:60d829a0353a 77 This parameter can be a value of @ref SPI_Clock_Polarity */
tushki7 0:60d829a0353a 78
tushki7 0:60d829a0353a 79 uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
tushki7 0:60d829a0353a 80 This parameter can be a value of @ref SPI_Clock_Phase */
tushki7 0:60d829a0353a 81
tushki7 0:60d829a0353a 82 uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
tushki7 0:60d829a0353a 83 hardware (NSS pin) or by software using the SSI bit.
tushki7 0:60d829a0353a 84 This parameter can be a value of @ref SPI_Slave_Select_management */
tushki7 0:60d829a0353a 85
tushki7 0:60d829a0353a 86 uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
tushki7 0:60d829a0353a 87 used to configure the transmit and receive SCK clock.
tushki7 0:60d829a0353a 88 This parameter can be a value of @ref SPI_BaudRate_Prescaler
tushki7 0:60d829a0353a 89 @note The communication clock is derived from the master
tushki7 0:60d829a0353a 90 clock. The slave clock does not need to be set. */
tushki7 0:60d829a0353a 91
tushki7 0:60d829a0353a 92 uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
tushki7 0:60d829a0353a 93 This parameter can be a value of @ref SPI_MSB_LSB_transmission */
tushki7 0:60d829a0353a 94
tushki7 0:60d829a0353a 95 uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not .
tushki7 0:60d829a0353a 96 This parameter can be a value of @ref SPI_TI_mode */
tushki7 0:60d829a0353a 97
tushki7 0:60d829a0353a 98 uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
tushki7 0:60d829a0353a 99 This parameter can be a value of @ref SPI_CRC_Calculation */
tushki7 0:60d829a0353a 100
tushki7 0:60d829a0353a 101 uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation.
tushki7 0:60d829a0353a 102 This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */
tushki7 0:60d829a0353a 103
tushki7 0:60d829a0353a 104 uint32_t CRCLength; /*!< Specifies the CRC Length used for the CRC calculation.
tushki7 0:60d829a0353a 105 CRC Length is only used with Data8 and Data16, not other data size
tushki7 0:60d829a0353a 106 This parameter must 0 or 1 or 2*/
tushki7 0:60d829a0353a 107
tushki7 0:60d829a0353a 108 uint32_t NSSPMode; /*!< Specifies whether the NSSP signal is enabled or not .
tushki7 0:60d829a0353a 109 This parameter can be a value of @ref SPI_NSSP_Mode
tushki7 0:60d829a0353a 110 This mode is activated by the NSSP bit in the SPIx_CR2 register and
tushki7 0:60d829a0353a 111 it takes effect only if the SPI interface is configured as Motorola SPI
tushki7 0:60d829a0353a 112 master (FRF=0) with capture on the first edge (SPIx_CR1 CPHA = 0,
tushki7 0:60d829a0353a 113 CPOL setting is ignored).. */
tushki7 0:60d829a0353a 114 } SPI_InitTypeDef;
tushki7 0:60d829a0353a 115
tushki7 0:60d829a0353a 116 /**
tushki7 0:60d829a0353a 117 * @brief HAL State structures definition
tushki7 0:60d829a0353a 118 */
tushki7 0:60d829a0353a 119 typedef enum
tushki7 0:60d829a0353a 120 {
tushki7 0:60d829a0353a 121 HAL_SPI_STATE_RESET = 0x00, /*!< Peripheral not Initialized */
tushki7 0:60d829a0353a 122 HAL_SPI_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
tushki7 0:60d829a0353a 123 HAL_SPI_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
tushki7 0:60d829a0353a 124 HAL_SPI_STATE_BUSY_TX = 0x03, /*!< Data Transmission process is ongoing */
tushki7 0:60d829a0353a 125 HAL_SPI_STATE_BUSY_RX = 0x04, /*!< Data Reception process is ongoing */
tushki7 0:60d829a0353a 126 HAL_SPI_STATE_BUSY_TX_RX = 0x05, /*!< Data Transmission and Reception process is ongoing */
tushki7 0:60d829a0353a 127 HAL_SPI_STATE_ERROR = 0x06 /*!< SPI error state */
tushki7 0:60d829a0353a 128 }HAL_SPI_StateTypeDef;
tushki7 0:60d829a0353a 129
tushki7 0:60d829a0353a 130 /**
tushki7 0:60d829a0353a 131 * @brief SPI handle Structure definition
tushki7 0:60d829a0353a 132 */
tushki7 0:60d829a0353a 133 typedef struct __SPI_HandleTypeDef
tushki7 0:60d829a0353a 134 {
tushki7 0:60d829a0353a 135 SPI_TypeDef *Instance; /*!< SPI registers base address */
tushki7 0:60d829a0353a 136
tushki7 0:60d829a0353a 137 SPI_InitTypeDef Init; /*!< SPI communication parameters */
tushki7 0:60d829a0353a 138
tushki7 0:60d829a0353a 139 uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */
tushki7 0:60d829a0353a 140
tushki7 0:60d829a0353a 141 uint16_t TxXferSize; /*!< SPI Tx Transfer size */
tushki7 0:60d829a0353a 142
tushki7 0:60d829a0353a 143 uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */
tushki7 0:60d829a0353a 144
tushki7 0:60d829a0353a 145 uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */
tushki7 0:60d829a0353a 146
tushki7 0:60d829a0353a 147 uint16_t RxXferSize; /*!< SPI Rx Transfer size */
tushki7 0:60d829a0353a 148
tushki7 0:60d829a0353a 149 uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */
tushki7 0:60d829a0353a 150
tushki7 0:60d829a0353a 151 uint32_t CRCSize; /*!< SPI CRC size used for the transfer */
tushki7 0:60d829a0353a 152
tushki7 0:60d829a0353a 153 void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx IRQ handler */
tushki7 0:60d829a0353a 154
tushki7 0:60d829a0353a 155 void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx IRQ handler */
tushki7 0:60d829a0353a 156
tushki7 0:60d829a0353a 157 DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */
tushki7 0:60d829a0353a 158
tushki7 0:60d829a0353a 159 DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */
tushki7 0:60d829a0353a 160
tushki7 0:60d829a0353a 161 HAL_LockTypeDef Lock; /*!< Locking object */
tushki7 0:60d829a0353a 162
tushki7 0:60d829a0353a 163 HAL_SPI_StateTypeDef State; /*!< SPI communication state */
tushki7 0:60d829a0353a 164
tushki7 0:60d829a0353a 165 __IO uint32_t ErrorCode; /*!< SPI Error code
tushki7 0:60d829a0353a 166 This parameter can be a value of @ref SPI_Error */
tushki7 0:60d829a0353a 167
tushki7 0:60d829a0353a 168 }SPI_HandleTypeDef;
tushki7 0:60d829a0353a 169
tushki7 0:60d829a0353a 170 /**
tushki7 0:60d829a0353a 171 * @}
tushki7 0:60d829a0353a 172 */
tushki7 0:60d829a0353a 173
tushki7 0:60d829a0353a 174 /* Exported constants --------------------------------------------------------*/
tushki7 0:60d829a0353a 175
tushki7 0:60d829a0353a 176 /** @defgroup SPI_Exported_Constants SPI Exported Constants
tushki7 0:60d829a0353a 177 * @{
tushki7 0:60d829a0353a 178 */
tushki7 0:60d829a0353a 179
tushki7 0:60d829a0353a 180 /** @defgroup SPI_Error SPI Error
tushki7 0:60d829a0353a 181 * @{
tushki7 0:60d829a0353a 182 */
tushki7 0:60d829a0353a 183 #define HAL_SPI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
tushki7 0:60d829a0353a 184 #define HAL_SPI_ERROR_MODF ((uint32_t)0x00000001) /*!< MODF error */
tushki7 0:60d829a0353a 185 #define HAL_SPI_ERROR_CRC ((uint32_t)0x00000002) /*!< CRC error */
tushki7 0:60d829a0353a 186 #define HAL_SPI_ERROR_OVR ((uint32_t)0x00000004) /*!< OVR error */
tushki7 0:60d829a0353a 187 #define HAL_SPI_ERROR_FRE ((uint32_t)0x00000008) /*!< FRE error */
tushki7 0:60d829a0353a 188 #define HAL_SPI_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
tushki7 0:60d829a0353a 189 #define HAL_SPI_ERROR_FLAG ((uint32_t)0x00000020) /*!< Error on BSY/TXE/FTLVL/FRLVL Flag */
tushki7 0:60d829a0353a 190 #define HAL_SPI_ERROR_UNKNOW ((uint32_t)0x00000040) /*!< Unknow Error error */
tushki7 0:60d829a0353a 191 /**
tushki7 0:60d829a0353a 192 * @}
tushki7 0:60d829a0353a 193 */
tushki7 0:60d829a0353a 194
tushki7 0:60d829a0353a 195 /** @defgroup SPI_mode SPI mode
tushki7 0:60d829a0353a 196 * @{
tushki7 0:60d829a0353a 197 */
tushki7 0:60d829a0353a 198 #define SPI_MODE_SLAVE ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 199 #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
tushki7 0:60d829a0353a 200 #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \
tushki7 0:60d829a0353a 201 ((MODE) == SPI_MODE_MASTER))
tushki7 0:60d829a0353a 202 /**
tushki7 0:60d829a0353a 203 * @}
tushki7 0:60d829a0353a 204 */
tushki7 0:60d829a0353a 205
tushki7 0:60d829a0353a 206 /** @defgroup SPI_Direction SPI Direction
tushki7 0:60d829a0353a 207 * @{
tushki7 0:60d829a0353a 208 */
tushki7 0:60d829a0353a 209 #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 210 #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
tushki7 0:60d829a0353a 211 #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
tushki7 0:60d829a0353a 212
tushki7 0:60d829a0353a 213 #define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \
tushki7 0:60d829a0353a 214 ((MODE) == SPI_DIRECTION_2LINES_RXONLY) ||\
tushki7 0:60d829a0353a 215 ((MODE) == SPI_DIRECTION_1LINE))
tushki7 0:60d829a0353a 216
tushki7 0:60d829a0353a 217 #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES)
tushki7 0:60d829a0353a 218
tushki7 0:60d829a0353a 219 #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES)|| \
tushki7 0:60d829a0353a 220 ((MODE) == SPI_DIRECTION_1LINE))
tushki7 0:60d829a0353a 221 /**
tushki7 0:60d829a0353a 222 * @}
tushki7 0:60d829a0353a 223 */
tushki7 0:60d829a0353a 224
tushki7 0:60d829a0353a 225 /** @defgroup SPI_data_size SPI Data size
tushki7 0:60d829a0353a 226 * @{
tushki7 0:60d829a0353a 227 */
tushki7 0:60d829a0353a 228 #define SPI_DATASIZE_4BIT ((uint32_t)0x0300) /*!< SPI Datasize = 4bits */
tushki7 0:60d829a0353a 229 #define SPI_DATASIZE_5BIT ((uint32_t)0x0400) /*!< SPI Datasize = 5bits */
tushki7 0:60d829a0353a 230 #define SPI_DATASIZE_6BIT ((uint32_t)0x0500) /*!< SPI Datasize = 6bits */
tushki7 0:60d829a0353a 231 #define SPI_DATASIZE_7BIT ((uint32_t)0x0600) /*!< SPI Datasize = 7bits */
tushki7 0:60d829a0353a 232 #define SPI_DATASIZE_8BIT ((uint32_t)0x0700) /*!< SPI Datasize = 8bits */
tushki7 0:60d829a0353a 233 #define SPI_DATASIZE_9BIT ((uint32_t)0x0800) /*!< SPI Datasize = 9bits */
tushki7 0:60d829a0353a 234 #define SPI_DATASIZE_10BIT ((uint32_t)0x0900) /*!< SPI Datasize = 10bits */
tushki7 0:60d829a0353a 235 #define SPI_DATASIZE_11BIT ((uint32_t)0x0A00) /*!< SPI Datasize = 11bits */
tushki7 0:60d829a0353a 236 #define SPI_DATASIZE_12BIT ((uint32_t)0x0B00) /*!< SPI Datasize = 12bits */
tushki7 0:60d829a0353a 237 #define SPI_DATASIZE_13BIT ((uint32_t)0x0C00) /*!< SPI Datasize = 13bits */
tushki7 0:60d829a0353a 238 #define SPI_DATASIZE_14BIT ((uint32_t)0x0D00) /*!< SPI Datasize = 14bits */
tushki7 0:60d829a0353a 239 #define SPI_DATASIZE_15BIT ((uint32_t)0x0E00) /*!< SPI Datasize = 15bits */
tushki7 0:60d829a0353a 240 #define SPI_DATASIZE_16BIT ((uint32_t)0x0F00) /*!< SPI Datasize = 16bits */
tushki7 0:60d829a0353a 241 #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \
tushki7 0:60d829a0353a 242 ((DATASIZE) == SPI_DATASIZE_15BIT) || \
tushki7 0:60d829a0353a 243 ((DATASIZE) == SPI_DATASIZE_14BIT) || \
tushki7 0:60d829a0353a 244 ((DATASIZE) == SPI_DATASIZE_13BIT) || \
tushki7 0:60d829a0353a 245 ((DATASIZE) == SPI_DATASIZE_12BIT) || \
tushki7 0:60d829a0353a 246 ((DATASIZE) == SPI_DATASIZE_11BIT) || \
tushki7 0:60d829a0353a 247 ((DATASIZE) == SPI_DATASIZE_10BIT) || \
tushki7 0:60d829a0353a 248 ((DATASIZE) == SPI_DATASIZE_9BIT) || \
tushki7 0:60d829a0353a 249 ((DATASIZE) == SPI_DATASIZE_8BIT) || \
tushki7 0:60d829a0353a 250 ((DATASIZE) == SPI_DATASIZE_7BIT) || \
tushki7 0:60d829a0353a 251 ((DATASIZE) == SPI_DATASIZE_6BIT) || \
tushki7 0:60d829a0353a 252 ((DATASIZE) == SPI_DATASIZE_5BIT) || \
tushki7 0:60d829a0353a 253 ((DATASIZE) == SPI_DATASIZE_4BIT))
tushki7 0:60d829a0353a 254
tushki7 0:60d829a0353a 255 /**
tushki7 0:60d829a0353a 256 * @}
tushki7 0:60d829a0353a 257 */
tushki7 0:60d829a0353a 258
tushki7 0:60d829a0353a 259 /** @defgroup SPI_Clock_Polarity SPI Clock Polarity
tushki7 0:60d829a0353a 260 * @{
tushki7 0:60d829a0353a 261 */
tushki7 0:60d829a0353a 262 #define SPI_POLARITY_LOW ((uint32_t)0x00000000) /*!< SPI polarity Low */
tushki7 0:60d829a0353a 263 #define SPI_POLARITY_HIGH SPI_CR1_CPOL /*!< SPI polarity High */
tushki7 0:60d829a0353a 264 #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \
tushki7 0:60d829a0353a 265 ((CPOL) == SPI_POLARITY_HIGH))
tushki7 0:60d829a0353a 266 /**
tushki7 0:60d829a0353a 267 * @}
tushki7 0:60d829a0353a 268 */
tushki7 0:60d829a0353a 269
tushki7 0:60d829a0353a 270 /** @defgroup SPI_Clock_Phase SPI Clock Phase
tushki7 0:60d829a0353a 271 * @{
tushki7 0:60d829a0353a 272 */
tushki7 0:60d829a0353a 273 #define SPI_PHASE_1EDGE ((uint32_t)0x00000000) /*!< SPI Phase 1EDGE */
tushki7 0:60d829a0353a 274 #define SPI_PHASE_2EDGE SPI_CR1_CPHA /*!< SPI Phase 2EDGE */
tushki7 0:60d829a0353a 275 #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \
tushki7 0:60d829a0353a 276 ((CPHA) == SPI_PHASE_2EDGE))
tushki7 0:60d829a0353a 277 /**
tushki7 0:60d829a0353a 278 * @}
tushki7 0:60d829a0353a 279 */
tushki7 0:60d829a0353a 280
tushki7 0:60d829a0353a 281 /** @defgroup SPI_Slave_Select_management SPI Slave Select management
tushki7 0:60d829a0353a 282 * @{
tushki7 0:60d829a0353a 283 */
tushki7 0:60d829a0353a 284 #define SPI_NSS_SOFT SPI_CR1_SSM
tushki7 0:60d829a0353a 285 #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 286 #define SPI_NSS_HARD_OUTPUT ((uint32_t)0x00040000)
tushki7 0:60d829a0353a 287 #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \
tushki7 0:60d829a0353a 288 ((NSS) == SPI_NSS_HARD_INPUT) || \
tushki7 0:60d829a0353a 289 ((NSS) == SPI_NSS_HARD_OUTPUT))
tushki7 0:60d829a0353a 290 /**
tushki7 0:60d829a0353a 291 * @}
tushki7 0:60d829a0353a 292 */
tushki7 0:60d829a0353a 293
tushki7 0:60d829a0353a 294 /** @defgroup SPI_NSSP_Mode SPI NSS pulse management
tushki7 0:60d829a0353a 295 * @{
tushki7 0:60d829a0353a 296 */
tushki7 0:60d829a0353a 297 #define SPI_NSS_PULSE_ENABLED SPI_CR2_NSSP
tushki7 0:60d829a0353a 298 #define SPI_NSS_PULSE_DISABLED ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 299
tushki7 0:60d829a0353a 300 #define IS_SPI_NSSP(NSSP) (((NSSP) == SPI_NSS_PULSE_ENABLED) || \
tushki7 0:60d829a0353a 301 ((NSSP) == SPI_NSS_PULSE_DISABLED))
tushki7 0:60d829a0353a 302 /**
tushki7 0:60d829a0353a 303 * @}
tushki7 0:60d829a0353a 304 */
tushki7 0:60d829a0353a 305
tushki7 0:60d829a0353a 306 /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
tushki7 0:60d829a0353a 307 * @{
tushki7 0:60d829a0353a 308 */
tushki7 0:60d829a0353a 309 #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 310 #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)0x00000008)
tushki7 0:60d829a0353a 311 #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)0x00000010)
tushki7 0:60d829a0353a 312 #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)0x00000018)
tushki7 0:60d829a0353a 313 #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)0x00000020)
tushki7 0:60d829a0353a 314 #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)0x00000028)
tushki7 0:60d829a0353a 315 #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)0x00000030)
tushki7 0:60d829a0353a 316 #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)0x00000038)
tushki7 0:60d829a0353a 317 #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \
tushki7 0:60d829a0353a 318 ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \
tushki7 0:60d829a0353a 319 ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \
tushki7 0:60d829a0353a 320 ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \
tushki7 0:60d829a0353a 321 ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \
tushki7 0:60d829a0353a 322 ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \
tushki7 0:60d829a0353a 323 ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \
tushki7 0:60d829a0353a 324 ((PRESCALER) == SPI_BAUDRATEPRESCALER_256))
tushki7 0:60d829a0353a 325 /**
tushki7 0:60d829a0353a 326 * @}
tushki7 0:60d829a0353a 327 */
tushki7 0:60d829a0353a 328
tushki7 0:60d829a0353a 329 /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB transmission
tushki7 0:60d829a0353a 330 * @{
tushki7 0:60d829a0353a 331 */
tushki7 0:60d829a0353a 332 #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 333 #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
tushki7 0:60d829a0353a 334 #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \
tushki7 0:60d829a0353a 335 ((BIT) == SPI_FIRSTBIT_LSB))
tushki7 0:60d829a0353a 336 /**
tushki7 0:60d829a0353a 337 * @}
tushki7 0:60d829a0353a 338 */
tushki7 0:60d829a0353a 339
tushki7 0:60d829a0353a 340 /** @defgroup SPI_TI_mode SPI TI mode
tushki7 0:60d829a0353a 341 * @{
tushki7 0:60d829a0353a 342 */
tushki7 0:60d829a0353a 343 #define SPI_TIMODE_DISABLED ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 344 #define SPI_TIMODE_ENABLED SPI_CR2_FRF
tushki7 0:60d829a0353a 345 #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLED) || \
tushki7 0:60d829a0353a 346 ((MODE) == SPI_TIMODE_ENABLED))
tushki7 0:60d829a0353a 347 /**
tushki7 0:60d829a0353a 348 * @}
tushki7 0:60d829a0353a 349 */
tushki7 0:60d829a0353a 350
tushki7 0:60d829a0353a 351 /** @defgroup SPI_CRC_Calculation SPI CRC Calculation
tushki7 0:60d829a0353a 352 * @{
tushki7 0:60d829a0353a 353 */
tushki7 0:60d829a0353a 354 #define SPI_CRCCALCULATION_DISABLED ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 355 #define SPI_CRCCALCULATION_ENABLED SPI_CR1_CRCEN
tushki7 0:60d829a0353a 356 #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLED) || \
tushki7 0:60d829a0353a 357 ((CALCULATION) == SPI_CRCCALCULATION_ENABLED))
tushki7 0:60d829a0353a 358 /**
tushki7 0:60d829a0353a 359 * @}
tushki7 0:60d829a0353a 360 */
tushki7 0:60d829a0353a 361
tushki7 0:60d829a0353a 362 /** @defgroup SPI_CRC_length SPI CRC length
tushki7 0:60d829a0353a 363 * @{
tushki7 0:60d829a0353a 364 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 365 * SPI_CRC_LENGTH_DATASIZE: aligned with the data size
tushki7 0:60d829a0353a 366 * SPI_CRC_LENGTH_8BIT : CRC 8bit
tushki7 0:60d829a0353a 367 * SPI_CRC_LENGTH_16BIT : CRC 16bit
tushki7 0:60d829a0353a 368 */
tushki7 0:60d829a0353a 369 #define SPI_CRC_LENGTH_DATASIZE 0
tushki7 0:60d829a0353a 370 #define SPI_CRC_LENGTH_8BIT 1
tushki7 0:60d829a0353a 371 #define SPI_CRC_LENGTH_16BIT 2
tushki7 0:60d829a0353a 372 #define IS_SPI_CRC_LENGTH(LENGTH) (((LENGTH) == SPI_CRC_LENGTH_DATASIZE) ||\
tushki7 0:60d829a0353a 373 ((LENGTH) == SPI_CRC_LENGTH_8BIT) || \
tushki7 0:60d829a0353a 374 ((LENGTH) == SPI_CRC_LENGTH_16BIT))
tushki7 0:60d829a0353a 375 /**
tushki7 0:60d829a0353a 376 * @}
tushki7 0:60d829a0353a 377 */
tushki7 0:60d829a0353a 378
tushki7 0:60d829a0353a 379 /** @defgroup SPI_FIFO_reception_threshold SPI FIFO reception threshold
tushki7 0:60d829a0353a 380 * @{
tushki7 0:60d829a0353a 381 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 382 * SPI_RXFIFO_THRESHOLD or SPI_RXFIFO_THRESHOLD_QF :
tushki7 0:60d829a0353a 383 * RXNE event is generated if the FIFO
tushki7 0:60d829a0353a 384 * level is greater or equal to 1/2(16-bits).
tushki7 0:60d829a0353a 385 * SPI_RXFIFO_THRESHOLD_HF: RXNE event is generated if the FIFO
tushki7 0:60d829a0353a 386 * level is greater or equal to 1/4(8 bits). */
tushki7 0:60d829a0353a 387 #define SPI_RXFIFO_THRESHOLD SPI_CR2_FRXTH
tushki7 0:60d829a0353a 388 #define SPI_RXFIFO_THRESHOLD_QF SPI_CR2_FRXTH
tushki7 0:60d829a0353a 389 #define SPI_RXFIFO_THRESHOLD_HF ((uint32_t)0x0)
tushki7 0:60d829a0353a 390
tushki7 0:60d829a0353a 391 /**
tushki7 0:60d829a0353a 392 * @}
tushki7 0:60d829a0353a 393 */
tushki7 0:60d829a0353a 394
tushki7 0:60d829a0353a 395 /** @defgroup SPI_Interrupt_configuration_definition SPI Interrupt configuration definition
tushki7 0:60d829a0353a 396 * @brief SPI Interrupt definition
tushki7 0:60d829a0353a 397 * Elements values convention: 0xXXXXXXXX
tushki7 0:60d829a0353a 398 * - XXXXXXXX : Interrupt control mask
tushki7 0:60d829a0353a 399 * @{
tushki7 0:60d829a0353a 400 */
tushki7 0:60d829a0353a 401 #define SPI_IT_TXE SPI_CR2_TXEIE
tushki7 0:60d829a0353a 402 #define SPI_IT_RXNE SPI_CR2_RXNEIE
tushki7 0:60d829a0353a 403 #define SPI_IT_ERR SPI_CR2_ERRIE
tushki7 0:60d829a0353a 404 /**
tushki7 0:60d829a0353a 405 * @}
tushki7 0:60d829a0353a 406 */
tushki7 0:60d829a0353a 407
tushki7 0:60d829a0353a 408
tushki7 0:60d829a0353a 409 /** @defgroup SPI_Flag_definition SPI Flag definition
tushki7 0:60d829a0353a 410 * @brief Flag definition
tushki7 0:60d829a0353a 411 * Elements values convention: 0xXXXXYYYY
tushki7 0:60d829a0353a 412 * - XXXX : Flag register Index
tushki7 0:60d829a0353a 413 * - YYYY : Flag mask
tushki7 0:60d829a0353a 414 * @{
tushki7 0:60d829a0353a 415 */
tushki7 0:60d829a0353a 416 #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
tushki7 0:60d829a0353a 417 #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
tushki7 0:60d829a0353a 418 #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
tushki7 0:60d829a0353a 419 #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
tushki7 0:60d829a0353a 420 #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
tushki7 0:60d829a0353a 421 #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
tushki7 0:60d829a0353a 422 #define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */
tushki7 0:60d829a0353a 423 #define SPI_FLAG_FTLVL SPI_SR_FTLVL /* SPI fifo transmission level */
tushki7 0:60d829a0353a 424 #define SPI_FLAG_FRLVL SPI_SR_FRLVL /* SPI fifo reception level */
tushki7 0:60d829a0353a 425 /**
tushki7 0:60d829a0353a 426 * @}
tushki7 0:60d829a0353a 427 */
tushki7 0:60d829a0353a 428
tushki7 0:60d829a0353a 429 /** @defgroup SPI_transmission_fifo_status_level SPI transmission fifo status level
tushki7 0:60d829a0353a 430 * @{
tushki7 0:60d829a0353a 431 */
tushki7 0:60d829a0353a 432 #define SPI_FTLVL_EMPTY ((uint32_t)0x0000)
tushki7 0:60d829a0353a 433 #define SPI_FTLVL_QUARTER_FULL ((uint32_t)0x0800)
tushki7 0:60d829a0353a 434 #define SPI_FTLVL_HALF_FULL ((uint32_t)0x1000)
tushki7 0:60d829a0353a 435 #define SPI_FTLVL_FULL ((uint32_t)0x1800)
tushki7 0:60d829a0353a 436
tushki7 0:60d829a0353a 437 /**
tushki7 0:60d829a0353a 438 * @}
tushki7 0:60d829a0353a 439 */
tushki7 0:60d829a0353a 440
tushki7 0:60d829a0353a 441 /** @defgroup SPI_reception_fifo_status_level SPI reception fifo status level
tushki7 0:60d829a0353a 442 * @{
tushki7 0:60d829a0353a 443 */
tushki7 0:60d829a0353a 444 #define SPI_FRLVL_EMPTY ((uint32_t)0x0000)
tushki7 0:60d829a0353a 445 #define SPI_FRLVL_QUARTER_FULL ((uint32_t)0x0200)
tushki7 0:60d829a0353a 446 #define SPI_FRLVL_HALF_FULL ((uint32_t)0x0400)
tushki7 0:60d829a0353a 447 #define SPI_FRLVL_FULL ((uint32_t)0x0600)
tushki7 0:60d829a0353a 448 /**
tushki7 0:60d829a0353a 449 * @}
tushki7 0:60d829a0353a 450 */
tushki7 0:60d829a0353a 451
tushki7 0:60d829a0353a 452 /**
tushki7 0:60d829a0353a 453 * @}
tushki7 0:60d829a0353a 454 */
tushki7 0:60d829a0353a 455
tushki7 0:60d829a0353a 456
tushki7 0:60d829a0353a 457 /* Exported macros ------------------------------------------------------------*/
tushki7 0:60d829a0353a 458 /** @defgroup SPI_Exported_Macros SPI Exported Macros
tushki7 0:60d829a0353a 459 * @{
tushki7 0:60d829a0353a 460 */
tushki7 0:60d829a0353a 461
tushki7 0:60d829a0353a 462 /** @brief Reset SPI handle state
tushki7 0:60d829a0353a 463 * @param __HANDLE__: SPI handle.
tushki7 0:60d829a0353a 464 * @retval None
tushki7 0:60d829a0353a 465 */
tushki7 0:60d829a0353a 466 #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
tushki7 0:60d829a0353a 467
tushki7 0:60d829a0353a 468 /** @brief Enables or disables the specified SPI interrupts.
tushki7 0:60d829a0353a 469 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 470 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 471 * @param __INTERRUPT__ : specifies the interrupt source to enable or disable.
tushki7 0:60d829a0353a 472 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 473 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
tushki7 0:60d829a0353a 474 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
tushki7 0:60d829a0353a 475 * @arg SPI_IT_ERR: Error interrupt enable
tushki7 0:60d829a0353a 476 * @retval None
tushki7 0:60d829a0353a 477 */
tushki7 0:60d829a0353a 478 #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
tushki7 0:60d829a0353a 479 #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__)))
tushki7 0:60d829a0353a 480
tushki7 0:60d829a0353a 481 /** @brief Checks if the specified SPI interrupt source is enabled or disabled.
tushki7 0:60d829a0353a 482 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 483 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 484 * @param __INTERRUPT__ : specifies the SPI interrupt source to check.
tushki7 0:60d829a0353a 485 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 486 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
tushki7 0:60d829a0353a 487 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
tushki7 0:60d829a0353a 488 * @arg SPI_IT_ERR: Error interrupt enable
tushki7 0:60d829a0353a 489 * @retval The new state of __IT__ (TRUE or FALSE).
tushki7 0:60d829a0353a 490 */
tushki7 0:60d829a0353a 491 #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
tushki7 0:60d829a0353a 492
tushki7 0:60d829a0353a 493 /** @brief Checks whether the specified SPI flag is set or not.
tushki7 0:60d829a0353a 494 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 495 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 496 * @param __FLAG__ : specifies the flag to check.
tushki7 0:60d829a0353a 497 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 498 * @arg SPI_FLAG_RXNE: Receive buffer not empty flag
tushki7 0:60d829a0353a 499 * @arg SPI_FLAG_TXE: Transmit buffer empty flag
tushki7 0:60d829a0353a 500 * @arg SPI_FLAG_CRCERR: CRC error flag
tushki7 0:60d829a0353a 501 * @arg SPI_FLAG_MODF: Mode fault flag
tushki7 0:60d829a0353a 502 * @arg SPI_FLAG_OVR: Overrun flag
tushki7 0:60d829a0353a 503 * @arg SPI_FLAG_BSY: Busy flag
tushki7 0:60d829a0353a 504 * @arg SPI_FLAG_FRE: Frame format error flag
tushki7 0:60d829a0353a 505 * @arg SPI_FLAG_FTLVL: SPI fifo transmission level
tushki7 0:60d829a0353a 506 * @arg SPI_FLAG_FRLVL: SPI fifo reception level
tushki7 0:60d829a0353a 507 * @retval The new state of __FLAG__ (TRUE or FALSE).
tushki7 0:60d829a0353a 508 */
tushki7 0:60d829a0353a 509 #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
tushki7 0:60d829a0353a 510
tushki7 0:60d829a0353a 511 /** @brief Clears the SPI CRCERR pending flag.
tushki7 0:60d829a0353a 512 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 513 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 514 * @retval None
tushki7 0:60d829a0353a 515 */
tushki7 0:60d829a0353a 516 #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR))
tushki7 0:60d829a0353a 517
tushki7 0:60d829a0353a 518 /** @brief Clears the SPI MODF pending flag.
tushki7 0:60d829a0353a 519 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 520 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 521 *
tushki7 0:60d829a0353a 522 * @retval None
tushki7 0:60d829a0353a 523 */
tushki7 0:60d829a0353a 524 #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) do{\
tushki7 0:60d829a0353a 525 __IO uint32_t tmpreg;\
tushki7 0:60d829a0353a 526 tmpreg = (__HANDLE__)->Instance->SR;\
tushki7 0:60d829a0353a 527 UNUSED(tmpreg); \
tushki7 0:60d829a0353a 528 (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE);\
tushki7 0:60d829a0353a 529 }while(0)
tushki7 0:60d829a0353a 530
tushki7 0:60d829a0353a 531 /** @brief Clears the SPI OVR pending flag.
tushki7 0:60d829a0353a 532 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 533 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 534 *
tushki7 0:60d829a0353a 535 * @retval None
tushki7 0:60d829a0353a 536 */
tushki7 0:60d829a0353a 537 #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) do{ \
tushki7 0:60d829a0353a 538 __IO uint32_t tmpreg; \
tushki7 0:60d829a0353a 539 tmpreg = (__HANDLE__)->Instance->DR; \
tushki7 0:60d829a0353a 540 tmpreg = (__HANDLE__)->Instance->SR; \
tushki7 0:60d829a0353a 541 UNUSED(tmpreg); \
tushki7 0:60d829a0353a 542 } while(0)
tushki7 0:60d829a0353a 543
tushki7 0:60d829a0353a 544 /** @brief Clears the SPI FRE pending flag.
tushki7 0:60d829a0353a 545 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 546 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 547 *
tushki7 0:60d829a0353a 548 * @retval None
tushki7 0:60d829a0353a 549 */
tushki7 0:60d829a0353a 550 #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) do{\
tushki7 0:60d829a0353a 551 __IO uint32_t tmpreg;\
tushki7 0:60d829a0353a 552 tmpreg = ((__HANDLE__)->Instance->SR);\
tushki7 0:60d829a0353a 553 UNUSED(tmpreg); \
tushki7 0:60d829a0353a 554 }while(0)
tushki7 0:60d829a0353a 555 /** @brief Enables the SPI.
tushki7 0:60d829a0353a 556 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 557 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 558 * @retval None
tushki7 0:60d829a0353a 559 */
tushki7 0:60d829a0353a 560 #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE)
tushki7 0:60d829a0353a 561
tushki7 0:60d829a0353a 562 /** @brief Disables the SPI.
tushki7 0:60d829a0353a 563 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 564 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 565 * @retval None
tushki7 0:60d829a0353a 566 */
tushki7 0:60d829a0353a 567 #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE))
tushki7 0:60d829a0353a 568
tushki7 0:60d829a0353a 569 /** @brief Sets the SPI transmit-only mode.
tushki7 0:60d829a0353a 570 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 571 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 572 * @retval None
tushki7 0:60d829a0353a 573 */
tushki7 0:60d829a0353a 574 #define __HAL_SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE)
tushki7 0:60d829a0353a 575
tushki7 0:60d829a0353a 576 /** @brief Sets the SPI receive-only mode.
tushki7 0:60d829a0353a 577 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 578 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 579 * @retval None
tushki7 0:60d829a0353a 580 */
tushki7 0:60d829a0353a 581 #define __HAL_SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_BIDIOE))
tushki7 0:60d829a0353a 582
tushki7 0:60d829a0353a 583 /** @brief Resets the CRC calculation of the SPI.
tushki7 0:60d829a0353a 584 * @param __HANDLE__ : specifies the SPI Handle.
tushki7 0:60d829a0353a 585 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 586 * @retval None
tushki7 0:60d829a0353a 587 */
tushki7 0:60d829a0353a 588 #define __HAL_SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (uint16_t)(~SPI_CR1_CRCEN);\
tushki7 0:60d829a0353a 589 (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0)
tushki7 0:60d829a0353a 590
tushki7 0:60d829a0353a 591
tushki7 0:60d829a0353a 592 #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x1) && ((POLYNOMIAL) <= 0xFFFF))
tushki7 0:60d829a0353a 593 /**
tushki7 0:60d829a0353a 594 * @}
tushki7 0:60d829a0353a 595 */
tushki7 0:60d829a0353a 596
tushki7 0:60d829a0353a 597 /* Exported functions --------------------------------------------------------*/
tushki7 0:60d829a0353a 598 /** @addtogroup SPI_Exported_Functions
tushki7 0:60d829a0353a 599 * @{
tushki7 0:60d829a0353a 600 */
tushki7 0:60d829a0353a 601
tushki7 0:60d829a0353a 602 /** @addtogroup SPI_Exported_Functions_Group1
tushki7 0:60d829a0353a 603 * @{
tushki7 0:60d829a0353a 604 */
tushki7 0:60d829a0353a 605
tushki7 0:60d829a0353a 606 /* Initialization and de-initialization functions ****************************/
tushki7 0:60d829a0353a 607 HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 608 HAL_StatusTypeDef HAL_SPI_InitExtended(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 609 HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 610 void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 611 void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 612 /**
tushki7 0:60d829a0353a 613 * @}
tushki7 0:60d829a0353a 614 */
tushki7 0:60d829a0353a 615
tushki7 0:60d829a0353a 616 /** @addtogroup SPI_Exported_Functions_Group2
tushki7 0:60d829a0353a 617 * @{
tushki7 0:60d829a0353a 618 */
tushki7 0:60d829a0353a 619
tushki7 0:60d829a0353a 620 /* IO operation functions *****************************************************/
tushki7 0:60d829a0353a 621 HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
tushki7 0:60d829a0353a 622 HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
tushki7 0:60d829a0353a 623 HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
tushki7 0:60d829a0353a 624 HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 625 HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 626 HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
tushki7 0:60d829a0353a 627 HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 628 HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 629 HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
tushki7 0:60d829a0353a 630 HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 631 HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 632 HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 633 HAL_StatusTypeDef HAL_SPI_FlushRxFifo(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 634
tushki7 0:60d829a0353a 635 void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 636 void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 637 void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 638 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 639 void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 640 void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 641 void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 642 void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 643 /**
tushki7 0:60d829a0353a 644 * @}
tushki7 0:60d829a0353a 645 */
tushki7 0:60d829a0353a 646
tushki7 0:60d829a0353a 647 /** @addtogroup SPI_Exported_Functions_Group3
tushki7 0:60d829a0353a 648 * @{
tushki7 0:60d829a0353a 649 */
tushki7 0:60d829a0353a 650
tushki7 0:60d829a0353a 651 /* Peripheral State and Error functions ***************************************/
tushki7 0:60d829a0353a 652 HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 653 uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 654 /**
tushki7 0:60d829a0353a 655 * @}
tushki7 0:60d829a0353a 656 */
tushki7 0:60d829a0353a 657
tushki7 0:60d829a0353a 658 /**
tushki7 0:60d829a0353a 659 * @}
tushki7 0:60d829a0353a 660 */
tushki7 0:60d829a0353a 661
tushki7 0:60d829a0353a 662 /**
tushki7 0:60d829a0353a 663 * @}
tushki7 0:60d829a0353a 664 */
tushki7 0:60d829a0353a 665
tushki7 0:60d829a0353a 666 /**
tushki7 0:60d829a0353a 667 * @}
tushki7 0:60d829a0353a 668 */
tushki7 0:60d829a0353a 669
tushki7 0:60d829a0353a 670 #ifdef __cplusplus
tushki7 0:60d829a0353a 671 }
tushki7 0:60d829a0353a 672 #endif
tushki7 0:60d829a0353a 673
tushki7 0:60d829a0353a 674 #endif /* __STM32F0xx_HAL_SPI_H */
tushki7 0:60d829a0353a 675
tushki7 0:60d829a0353a 676 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
tushki7 0:60d829a0353a 677