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 stm32f3xx_hal_spi.h
tushki7 0:60d829a0353a 4 * @author MCD Application Team
tushki7 0:60d829a0353a 5 * @version V1.1.0
tushki7 0:60d829a0353a 6 * @date 12-Sept-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 __STM32F3xx_HAL_SPI_H
tushki7 0:60d829a0353a 40 #define __STM32F3xx_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 "stm32f3xx_hal_def.h"
tushki7 0:60d829a0353a 48
tushki7 0:60d829a0353a 49 /** @addtogroup STM32F3xx_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 mode is activated by the NSSP bit in the SPIx_CR2 register and
tushki7 0:60d829a0353a 110 it takes effect only if the SPI interface is configured as Motorola SPI
tushki7 0:60d829a0353a 111 master (FRF=0) with capture on the first edge (SPIx_CR1 CPHA = 0,
tushki7 0:60d829a0353a 112 CPOL setting is ignored).. */
tushki7 0:60d829a0353a 113 } SPI_InitTypeDef;
tushki7 0:60d829a0353a 114
tushki7 0:60d829a0353a 115 /**
tushki7 0:60d829a0353a 116 * @brief HAL State structures definition
tushki7 0:60d829a0353a 117 */
tushki7 0:60d829a0353a 118 typedef enum
tushki7 0:60d829a0353a 119 {
tushki7 0:60d829a0353a 120 HAL_SPI_STATE_RESET = 0x00, /*!< Peripheral not Initialized */
tushki7 0:60d829a0353a 121 HAL_SPI_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
tushki7 0:60d829a0353a 122 HAL_SPI_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
tushki7 0:60d829a0353a 123 HAL_SPI_STATE_BUSY_TX = 0x03, /*!< Data Transmission process is ongoing */
tushki7 0:60d829a0353a 124 HAL_SPI_STATE_BUSY_RX = 0x04, /*!< Data Reception process is ongoing */
tushki7 0:60d829a0353a 125 HAL_SPI_STATE_BUSY_TX_RX = 0x05, /*!< Data Transmission and Reception process is ongoing */
tushki7 0:60d829a0353a 126 HAL_SPI_STATE_TIMEOUT = 0x06, /*!< Timeout state */
tushki7 0:60d829a0353a 127 HAL_SPI_STATE_ERROR = 0x07 /*!< Data Transmission and Reception process is ongoing */
tushki7 0:60d829a0353a 128
tushki7 0:60d829a0353a 129 }HAL_SPI_StateTypeDef;
tushki7 0:60d829a0353a 130
tushki7 0:60d829a0353a 131 /**
tushki7 0:60d829a0353a 132 * @brief HAL SPI Error Code structure definition
tushki7 0:60d829a0353a 133 */
tushki7 0:60d829a0353a 134 typedef enum
tushki7 0:60d829a0353a 135 {
tushki7 0:60d829a0353a 136 HAL_SPI_ERROR_NONE = 0x00, /*!< No error */
tushki7 0:60d829a0353a 137 HAL_SPI_ERROR_MODF = 0x01, /*!< MODF error */
tushki7 0:60d829a0353a 138 HAL_SPI_ERROR_CRC = 0x02, /*!< CRC error */
tushki7 0:60d829a0353a 139 HAL_SPI_ERROR_OVR = 0x04, /*!< OVR error */
tushki7 0:60d829a0353a 140 HAL_SPI_ERROR_FRE = 0x08, /*!< FRE error */
tushki7 0:60d829a0353a 141 HAL_SPI_ERROR_DMA = 0x10, /*!< DMA transfer error */
tushki7 0:60d829a0353a 142 HAL_SPI_ERROR_FLAG = 0x20, /*!< Error on BSY/TXE/FTLVL/FRLVL Flag */
tushki7 0:60d829a0353a 143 HAL_SPI_ERROR_UNKNOW = 0x40, /*!< Unknow Error error */
tushki7 0:60d829a0353a 144 }HAL_SPI_ErrorTypeDef;
tushki7 0:60d829a0353a 145
tushki7 0:60d829a0353a 146 /**
tushki7 0:60d829a0353a 147 * @brief SPI handle Structure definition
tushki7 0:60d829a0353a 148 */
tushki7 0:60d829a0353a 149 typedef struct __SPI_HandleTypeDef
tushki7 0:60d829a0353a 150 {
tushki7 0:60d829a0353a 151 SPI_TypeDef *Instance; /* SPI registers base address */
tushki7 0:60d829a0353a 152
tushki7 0:60d829a0353a 153 SPI_InitTypeDef Init; /* SPI communication parameters */
tushki7 0:60d829a0353a 154
tushki7 0:60d829a0353a 155 uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */
tushki7 0:60d829a0353a 156
tushki7 0:60d829a0353a 157 uint16_t TxXferSize; /* SPI Tx Transfer size */
tushki7 0:60d829a0353a 158
tushki7 0:60d829a0353a 159 uint16_t TxXferCount; /* SPI Tx Transfer Counter */
tushki7 0:60d829a0353a 160
tushki7 0:60d829a0353a 161 uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */
tushki7 0:60d829a0353a 162
tushki7 0:60d829a0353a 163 uint16_t RxXferSize; /* SPI Rx Transfer size */
tushki7 0:60d829a0353a 164
tushki7 0:60d829a0353a 165 uint16_t RxXferCount; /* SPI Rx Transfer Counter */
tushki7 0:60d829a0353a 166
tushki7 0:60d829a0353a 167 uint32_t CRCSize; /* SPI CRC size used for the transfer */
tushki7 0:60d829a0353a 168
tushki7 0:60d829a0353a 169 void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /* function pointer on Rx IRQ handler */
tushki7 0:60d829a0353a 170
tushki7 0:60d829a0353a 171 void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /* function pointer on Tx IRQ handler */
tushki7 0:60d829a0353a 172
tushki7 0:60d829a0353a 173 DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA Handle parameters */
tushki7 0:60d829a0353a 174
tushki7 0:60d829a0353a 175 DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA Handle parameters */
tushki7 0:60d829a0353a 176
tushki7 0:60d829a0353a 177 HAL_LockTypeDef Lock; /* Locking object */
tushki7 0:60d829a0353a 178
tushki7 0:60d829a0353a 179 HAL_SPI_StateTypeDef State; /* SPI communication state */
tushki7 0:60d829a0353a 180
tushki7 0:60d829a0353a 181 HAL_SPI_ErrorTypeDef ErrorCode; /* SPI Error code */
tushki7 0:60d829a0353a 182
tushki7 0:60d829a0353a 183 }SPI_HandleTypeDef;
tushki7 0:60d829a0353a 184
tushki7 0:60d829a0353a 185 /**
tushki7 0:60d829a0353a 186 * @}
tushki7 0:60d829a0353a 187 */
tushki7 0:60d829a0353a 188
tushki7 0:60d829a0353a 189 /* Exported constants --------------------------------------------------------*/
tushki7 0:60d829a0353a 190
tushki7 0:60d829a0353a 191 /** @defgroup SPI_Exported_Constants SPI Exported Constants
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
tushki7 0:60d829a0353a 199 #define SPI_MODE_SLAVE ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 200 #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
tushki7 0:60d829a0353a 201 #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \
tushki7 0:60d829a0353a 202 ((MODE) == SPI_MODE_MASTER))
tushki7 0:60d829a0353a 203 /**
tushki7 0:60d829a0353a 204 * @}
tushki7 0:60d829a0353a 205 */
tushki7 0:60d829a0353a 206
tushki7 0:60d829a0353a 207 /** @defgroup SPI_Direction SPI Direction
tushki7 0:60d829a0353a 208 * @{
tushki7 0:60d829a0353a 209 */
tushki7 0:60d829a0353a 210 #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 211 #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
tushki7 0:60d829a0353a 212 #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
tushki7 0:60d829a0353a 213
tushki7 0:60d829a0353a 214 #define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \
tushki7 0:60d829a0353a 215 ((MODE) == SPI_DIRECTION_2LINES_RXONLY) ||\
tushki7 0:60d829a0353a 216 ((MODE) == SPI_DIRECTION_1LINE))
tushki7 0:60d829a0353a 217
tushki7 0:60d829a0353a 218 #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES)
tushki7 0:60d829a0353a 219
tushki7 0:60d829a0353a 220 #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES)|| \
tushki7 0:60d829a0353a 221 ((MODE) == SPI_DIRECTION_1LINE))
tushki7 0:60d829a0353a 222 /**
tushki7 0:60d829a0353a 223 * @}
tushki7 0:60d829a0353a 224 */
tushki7 0:60d829a0353a 225
tushki7 0:60d829a0353a 226 /** @defgroup SPI_data_size SPI data size
tushki7 0:60d829a0353a 227 * @{
tushki7 0:60d829a0353a 228 */
tushki7 0:60d829a0353a 229
tushki7 0:60d829a0353a 230 #define SPI_DATASIZE_4BIT ((uint16_t)0x0300)
tushki7 0:60d829a0353a 231 #define SPI_DATASIZE_5BIT ((uint16_t)0x0400)
tushki7 0:60d829a0353a 232 #define SPI_DATASIZE_6BIT ((uint16_t)0x0500)
tushki7 0:60d829a0353a 233 #define SPI_DATASIZE_7BIT ((uint16_t)0x0600)
tushki7 0:60d829a0353a 234 #define SPI_DATASIZE_8BIT ((uint16_t)0x0700)
tushki7 0:60d829a0353a 235 #define SPI_DATASIZE_9BIT ((uint16_t)0x0800)
tushki7 0:60d829a0353a 236 #define SPI_DATASIZE_10BIT ((uint16_t)0x0900)
tushki7 0:60d829a0353a 237 #define SPI_DATASIZE_11BIT ((uint16_t)0x0A00)
tushki7 0:60d829a0353a 238 #define SPI_DATASIZE_12BIT ((uint16_t)0x0B00)
tushki7 0:60d829a0353a 239 #define SPI_DATASIZE_13BIT ((uint16_t)0x0C00)
tushki7 0:60d829a0353a 240 #define SPI_DATASIZE_14BIT ((uint16_t)0x0D00)
tushki7 0:60d829a0353a 241 #define SPI_DATASIZE_15BIT ((uint16_t)0x0E00)
tushki7 0:60d829a0353a 242 #define SPI_DATASIZE_16BIT ((uint16_t)0x0F00)
tushki7 0:60d829a0353a 243 #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \
tushki7 0:60d829a0353a 244 ((DATASIZE) == SPI_DATASIZE_15BIT) || \
tushki7 0:60d829a0353a 245 ((DATASIZE) == SPI_DATASIZE_14BIT) || \
tushki7 0:60d829a0353a 246 ((DATASIZE) == SPI_DATASIZE_13BIT) || \
tushki7 0:60d829a0353a 247 ((DATASIZE) == SPI_DATASIZE_12BIT) || \
tushki7 0:60d829a0353a 248 ((DATASIZE) == SPI_DATASIZE_11BIT) || \
tushki7 0:60d829a0353a 249 ((DATASIZE) == SPI_DATASIZE_10BIT) || \
tushki7 0:60d829a0353a 250 ((DATASIZE) == SPI_DATASIZE_9BIT) || \
tushki7 0:60d829a0353a 251 ((DATASIZE) == SPI_DATASIZE_8BIT) || \
tushki7 0:60d829a0353a 252 ((DATASIZE) == SPI_DATASIZE_7BIT) || \
tushki7 0:60d829a0353a 253 ((DATASIZE) == SPI_DATASIZE_6BIT) || \
tushki7 0:60d829a0353a 254 ((DATASIZE) == SPI_DATASIZE_5BIT) || \
tushki7 0:60d829a0353a 255 ((DATASIZE) == SPI_DATASIZE_4BIT))
tushki7 0:60d829a0353a 256
tushki7 0:60d829a0353a 257 /**
tushki7 0:60d829a0353a 258 * @}
tushki7 0:60d829a0353a 259 */
tushki7 0:60d829a0353a 260
tushki7 0:60d829a0353a 261 /** @defgroup SPI_Clock_Polarity SPI Clock Polarity
tushki7 0:60d829a0353a 262 * @{
tushki7 0:60d829a0353a 263 */
tushki7 0:60d829a0353a 264
tushki7 0:60d829a0353a 265 #define SPI_POLARITY_LOW ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 266 #define SPI_POLARITY_HIGH SPI_CR1_CPOL
tushki7 0:60d829a0353a 267 #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \
tushki7 0:60d829a0353a 268 ((CPOL) == SPI_POLARITY_HIGH))
tushki7 0:60d829a0353a 269 /**
tushki7 0:60d829a0353a 270 * @}
tushki7 0:60d829a0353a 271 */
tushki7 0:60d829a0353a 272
tushki7 0:60d829a0353a 273 /** @defgroup SPI_Clock_Phase SPI Clock Phase
tushki7 0:60d829a0353a 274 * @{
tushki7 0:60d829a0353a 275 */
tushki7 0:60d829a0353a 276
tushki7 0:60d829a0353a 277 #define SPI_PHASE_1EDGE ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 278 #define SPI_PHASE_2EDGE SPI_CR1_CPHA
tushki7 0:60d829a0353a 279 #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \
tushki7 0:60d829a0353a 280 ((CPHA) == SPI_PHASE_2EDGE))
tushki7 0:60d829a0353a 281 /**
tushki7 0:60d829a0353a 282 * @}
tushki7 0:60d829a0353a 283 */
tushki7 0:60d829a0353a 284
tushki7 0:60d829a0353a 285 /** @defgroup SPI_Slave_Select_management SPI Slave Select management
tushki7 0:60d829a0353a 286 * @{
tushki7 0:60d829a0353a 287 */
tushki7 0:60d829a0353a 288
tushki7 0:60d829a0353a 289 #define SPI_NSS_SOFT SPI_CR1_SSM
tushki7 0:60d829a0353a 290 #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 291 #define SPI_NSS_HARD_OUTPUT ((uint32_t)0x00040000)
tushki7 0:60d829a0353a 292 #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \
tushki7 0:60d829a0353a 293 ((NSS) == SPI_NSS_HARD_INPUT) || \
tushki7 0:60d829a0353a 294 ((NSS) == SPI_NSS_HARD_OUTPUT))
tushki7 0:60d829a0353a 295
tushki7 0:60d829a0353a 296 /**
tushki7 0:60d829a0353a 297 * @}
tushki7 0:60d829a0353a 298 */
tushki7 0:60d829a0353a 299
tushki7 0:60d829a0353a 300
tushki7 0:60d829a0353a 301 /** @defgroup SPI_NSS SPI NSS pulse management
tushki7 0:60d829a0353a 302 * @{
tushki7 0:60d829a0353a 303 */
tushki7 0:60d829a0353a 304 #define SPI_NSS_PULSE_ENABLED SPI_CR2_NSSP
tushki7 0:60d829a0353a 305 #define SPI_NSS_PULSE_DISABLED ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 306
tushki7 0:60d829a0353a 307 #define IS_SPI_NSSP(NSSP) (((NSSP) == SPI_NSS_PULSE_ENABLED) || \
tushki7 0:60d829a0353a 308 ((NSSP) == SPI_NSS_PULSE_DISABLED))
tushki7 0:60d829a0353a 309
tushki7 0:60d829a0353a 310 /**
tushki7 0:60d829a0353a 311 * @}
tushki7 0:60d829a0353a 312 */
tushki7 0:60d829a0353a 313
tushki7 0:60d829a0353a 314
tushki7 0:60d829a0353a 315 /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
tushki7 0:60d829a0353a 316 * @{
tushki7 0:60d829a0353a 317 */
tushki7 0:60d829a0353a 318
tushki7 0:60d829a0353a 319 #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 320 #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)0x00000008)
tushki7 0:60d829a0353a 321 #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)0x00000010)
tushki7 0:60d829a0353a 322 #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)0x00000018)
tushki7 0:60d829a0353a 323 #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)0x00000020)
tushki7 0:60d829a0353a 324 #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)0x00000028)
tushki7 0:60d829a0353a 325 #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)0x00000030)
tushki7 0:60d829a0353a 326 #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)0x00000038)
tushki7 0:60d829a0353a 327 #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \
tushki7 0:60d829a0353a 328 ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \
tushki7 0:60d829a0353a 329 ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \
tushki7 0:60d829a0353a 330 ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \
tushki7 0:60d829a0353a 331 ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \
tushki7 0:60d829a0353a 332 ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \
tushki7 0:60d829a0353a 333 ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \
tushki7 0:60d829a0353a 334 ((PRESCALER) == SPI_BAUDRATEPRESCALER_256))
tushki7 0:60d829a0353a 335 /**
tushki7 0:60d829a0353a 336 * @}
tushki7 0:60d829a0353a 337 */
tushki7 0:60d829a0353a 338
tushki7 0:60d829a0353a 339 /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB transmission
tushki7 0:60d829a0353a 340 * @{
tushki7 0:60d829a0353a 341 */
tushki7 0:60d829a0353a 342
tushki7 0:60d829a0353a 343 #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 344 #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
tushki7 0:60d829a0353a 345 #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \
tushki7 0:60d829a0353a 346 ((BIT) == SPI_FIRSTBIT_LSB))
tushki7 0:60d829a0353a 347 /**
tushki7 0:60d829a0353a 348 * @}
tushki7 0:60d829a0353a 349 */
tushki7 0:60d829a0353a 350
tushki7 0:60d829a0353a 351 /** @defgroup SPI_TI_mode SPI TI mode
tushki7 0:60d829a0353a 352 * @{
tushki7 0:60d829a0353a 353 */
tushki7 0:60d829a0353a 354
tushki7 0:60d829a0353a 355 #define SPI_TIMODE_DISABLED ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 356 #define SPI_TIMODE_ENABLED SPI_CR2_FRF
tushki7 0:60d829a0353a 357 #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLED) || \
tushki7 0:60d829a0353a 358 ((MODE) == SPI_TIMODE_ENABLED))
tushki7 0:60d829a0353a 359 /**
tushki7 0:60d829a0353a 360 * @}
tushki7 0:60d829a0353a 361 */
tushki7 0:60d829a0353a 362
tushki7 0:60d829a0353a 363 /** @defgroup SPI_CRC_Calculation SPI CRC Calculation
tushki7 0:60d829a0353a 364 * @{
tushki7 0:60d829a0353a 365 */
tushki7 0:60d829a0353a 366
tushki7 0:60d829a0353a 367 #define SPI_CRCCALCULATION_DISABLED ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 368 #define SPI_CRCCALCULATION_ENABLED SPI_CR1_CRCEN
tushki7 0:60d829a0353a 369 #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLED) || \
tushki7 0:60d829a0353a 370 ((CALCULATION) == SPI_CRCCALCULATION_ENABLED))
tushki7 0:60d829a0353a 371 /**
tushki7 0:60d829a0353a 372 * @}
tushki7 0:60d829a0353a 373 */
tushki7 0:60d829a0353a 374
tushki7 0:60d829a0353a 375 /** @defgroup SPI_CRC_length SPI CRC length
tushki7 0:60d829a0353a 376 * @{
tushki7 0:60d829a0353a 377 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 378 * SPI_CRC_LENGTH_DATASIZE: aligned with the data size
tushki7 0:60d829a0353a 379 * SPI_CRC_LENGTH_8BIT : CRC 8bit
tushki7 0:60d829a0353a 380 * SPI_CRC_LENGTH_16BIT : CRC 16bit
tushki7 0:60d829a0353a 381 */
tushki7 0:60d829a0353a 382 #define SPI_CRC_LENGTH_DATASIZE 0
tushki7 0:60d829a0353a 383 #define SPI_CRC_LENGTH_8BIT 1
tushki7 0:60d829a0353a 384 #define SPI_CRC_LENGTH_16BIT 2
tushki7 0:60d829a0353a 385 #define IS_SPI_CRC_LENGTH(LENGTH) (((LENGTH) == SPI_CRC_LENGTH_DATASIZE) ||\
tushki7 0:60d829a0353a 386 ((LENGTH) == SPI_CRC_LENGTH_8BIT) || \
tushki7 0:60d829a0353a 387 ((LENGTH) == SPI_CRC_LENGTH_16BIT))
tushki7 0:60d829a0353a 388 /**
tushki7 0:60d829a0353a 389 * @}
tushki7 0:60d829a0353a 390 */
tushki7 0:60d829a0353a 391
tushki7 0:60d829a0353a 392 /** @defgroup SPI_FIFO_reception_threshold SPI FIFO reception threshold
tushki7 0:60d829a0353a 393 * @{
tushki7 0:60d829a0353a 394 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 395 * SPI_RxFIFOThreshold_HF: RXNE event is generated if the FIFO
tushki7 0:60d829a0353a 396 * level is greater or equal to 1/2(16-bits).
tushki7 0:60d829a0353a 397 * SPI_RxFIFOThreshold_QF: RXNE event is generated if the FIFO
tushki7 0:60d829a0353a 398 * level is greater or equal to 1/4(8 bits).
tushki7 0:60d829a0353a 399 */
tushki7 0:60d829a0353a 400 #define SPI_RXFIFO_THRESHOLD SPI_CR2_FRXTH
tushki7 0:60d829a0353a 401 #define SPI_RXFIFO_THRESHOLD_QF SPI_CR2_FRXTH
tushki7 0:60d829a0353a 402 #define SPI_RXFIFO_THRESHOLD_HF ((uint32_t)0x0)
tushki7 0:60d829a0353a 403
tushki7 0:60d829a0353a 404 /**
tushki7 0:60d829a0353a 405 * @}
tushki7 0:60d829a0353a 406 */
tushki7 0:60d829a0353a 407
tushki7 0:60d829a0353a 408 /** @defgroup SPI_Interrupt_configuration_definition SPI Interrupt configuration definition
tushki7 0:60d829a0353a 409 * @brief SPI Interrupt definition
tushki7 0:60d829a0353a 410 * Elements values convention: 0xXXXXXXXX
tushki7 0:60d829a0353a 411 * - XXXXXXXX : Interrupt control mask
tushki7 0:60d829a0353a 412 * @{
tushki7 0:60d829a0353a 413 */
tushki7 0:60d829a0353a 414 #define SPI_IT_TXE SPI_CR2_TXEIE
tushki7 0:60d829a0353a 415 #define SPI_IT_RXNE SPI_CR2_RXNEIE
tushki7 0:60d829a0353a 416 #define SPI_IT_ERR SPI_CR2_ERRIE
tushki7 0:60d829a0353a 417 #define IS_SPI_IT(IT) (((IT) == SPI_IT_TXE) || \
tushki7 0:60d829a0353a 418 ((IT) == SPI_IT_RXNE) || \
tushki7 0:60d829a0353a 419 ((IT) == SPI_IT_ERR))
tushki7 0:60d829a0353a 420 /**
tushki7 0:60d829a0353a 421 * @}
tushki7 0:60d829a0353a 422 */
tushki7 0:60d829a0353a 423
tushki7 0:60d829a0353a 424
tushki7 0:60d829a0353a 425 /** @defgroup SPI_Flag_definition SPI Flag definition
tushki7 0:60d829a0353a 426 * @brief Flag definition
tushki7 0:60d829a0353a 427 * Elements values convention: 0xXXXXYYYY
tushki7 0:60d829a0353a 428 * - XXXX : Flag register Index
tushki7 0:60d829a0353a 429 * - YYYY : Flag mask
tushki7 0:60d829a0353a 430 * @{
tushki7 0:60d829a0353a 431 */
tushki7 0:60d829a0353a 432 #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
tushki7 0:60d829a0353a 433 #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
tushki7 0:60d829a0353a 434 #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
tushki7 0:60d829a0353a 435 #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
tushki7 0:60d829a0353a 436 #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
tushki7 0:60d829a0353a 437 #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
tushki7 0:60d829a0353a 438 #define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */
tushki7 0:60d829a0353a 439 #define SPI_FLAG_FTLVL SPI_SR_FTLVL /* SPI fifo transmission level */
tushki7 0:60d829a0353a 440 #define SPI_FLAG_FRLVL SPI_SR_FRLVL /* SPI fifo reception level */
tushki7 0:60d829a0353a 441 #define IS_SPI_FLAG(FLAG) (((FLAG) == SPI_FLAG_RXNE) || \
tushki7 0:60d829a0353a 442 ((FLAG) == SPI_FLAG_TXE) || \
tushki7 0:60d829a0353a 443 ((FLAG) == SPI_FLAG_BSY) || \
tushki7 0:60d829a0353a 444 ((FLAG) == SPI_FLAG_CRCERR)|| \
tushki7 0:60d829a0353a 445 ((FLAG) == SPI_FLAG_MODF) || \
tushki7 0:60d829a0353a 446 ((FLAG) == SPI_FLAG_OVR) || \
tushki7 0:60d829a0353a 447 ((FLAG) == SPI_FLAG_FTLVL) || \
tushki7 0:60d829a0353a 448 ((FLAG) == SPI_FLAG_FRLVL) || \
tushki7 0:60d829a0353a 449 ((FLAG) == SPI_IT_FRE))
tushki7 0:60d829a0353a 450 /**
tushki7 0:60d829a0353a 451 * @}
tushki7 0:60d829a0353a 452 */
tushki7 0:60d829a0353a 453
tushki7 0:60d829a0353a 454
tushki7 0:60d829a0353a 455 /** @defgroup SPI_transmission_fifo_status_level SPI transmission fifo status level
tushki7 0:60d829a0353a 456 * @{
tushki7 0:60d829a0353a 457 */
tushki7 0:60d829a0353a 458
tushki7 0:60d829a0353a 459 #define SPI_FTLVL_EMPTY ((uint16_t)0x0000)
tushki7 0:60d829a0353a 460 #define SPI_FTLVL_QUARTER_FULL ((uint16_t)0x0800)
tushki7 0:60d829a0353a 461 #define SPI_FTLVL_HALF_FULL ((uint16_t)0x1000)
tushki7 0:60d829a0353a 462 #define SPI_FTLVL_FULL ((uint16_t)0x1800)
tushki7 0:60d829a0353a 463
tushki7 0:60d829a0353a 464
tushki7 0:60d829a0353a 465 /**
tushki7 0:60d829a0353a 466 * @}
tushki7 0:60d829a0353a 467 */
tushki7 0:60d829a0353a 468
tushki7 0:60d829a0353a 469 /** @defgroup SPI_reception_fifo_status_level SPI reception fifo status level
tushki7 0:60d829a0353a 470 * @{
tushki7 0:60d829a0353a 471 */
tushki7 0:60d829a0353a 472 #define SPI_FRLVL_EMPTY ((uint16_t)0x0000)
tushki7 0:60d829a0353a 473 #define SPI_FRLVL_QUARTER_FULL ((uint16_t)0x0200)
tushki7 0:60d829a0353a 474 #define SPI_FRLVL_HALF_FULL ((uint16_t)0x0400)
tushki7 0:60d829a0353a 475 #define SPI_FRLVL_FULL ((uint16_t)0x0600)
tushki7 0:60d829a0353a 476
tushki7 0:60d829a0353a 477 /**
tushki7 0:60d829a0353a 478 * @}
tushki7 0:60d829a0353a 479 */
tushki7 0:60d829a0353a 480
tushki7 0:60d829a0353a 481 /**
tushki7 0:60d829a0353a 482 * @}
tushki7 0:60d829a0353a 483 */
tushki7 0:60d829a0353a 484
tushki7 0:60d829a0353a 485
tushki7 0:60d829a0353a 486 /* Exported macros ------------------------------------------------------------*/
tushki7 0:60d829a0353a 487 /** @defgroup SPI_Exported_Macros SPI Exported Macros
tushki7 0:60d829a0353a 488 * @{
tushki7 0:60d829a0353a 489 */
tushki7 0:60d829a0353a 490
tushki7 0:60d829a0353a 491 /** @brief Reset SPI handle state
tushki7 0:60d829a0353a 492 * @param __HANDLE__: SPI handle.
tushki7 0:60d829a0353a 493 * @retval None
tushki7 0:60d829a0353a 494 */
tushki7 0:60d829a0353a 495 #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
tushki7 0:60d829a0353a 496
tushki7 0:60d829a0353a 497 /** @brief Enables or disables the specified SPI interrupts.
tushki7 0:60d829a0353a 498 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 499 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 500 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
tushki7 0:60d829a0353a 501 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 502 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
tushki7 0:60d829a0353a 503 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
tushki7 0:60d829a0353a 504 * @arg SPI_IT_ERR: Error interrupt enable
tushki7 0:60d829a0353a 505 * @retval None
tushki7 0:60d829a0353a 506 */
tushki7 0:60d829a0353a 507
tushki7 0:60d829a0353a 508 #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
tushki7 0:60d829a0353a 509 #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__)))
tushki7 0:60d829a0353a 510
tushki7 0:60d829a0353a 511 /** @brief Checks if the specified SPI interrupt source is enabled or disabled.
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 * @param __INTERRUPT__: specifies the SPI interrupt source to check.
tushki7 0:60d829a0353a 515 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 516 * @arg SPI_IT_TXE: Tx buffer empty interrupt enable
tushki7 0:60d829a0353a 517 * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
tushki7 0:60d829a0353a 518 * @arg SPI_IT_ERR: Error interrupt enable
tushki7 0:60d829a0353a 519 * @retval The new state of __IT__ (TRUE or FALSE).
tushki7 0:60d829a0353a 520 */
tushki7 0:60d829a0353a 521 #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
tushki7 0:60d829a0353a 522
tushki7 0:60d829a0353a 523 /** @brief Checks whether the specified SPI flag is set or not.
tushki7 0:60d829a0353a 524 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 525 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 526 * @param __FLAG__: specifies the flag to check.
tushki7 0:60d829a0353a 527 * This parameter can be one of the following values:
tushki7 0:60d829a0353a 528 * @arg SPI_FLAG_RXNE: Receive buffer not empty flag
tushki7 0:60d829a0353a 529 * @arg SPI_FLAG_TXE: Transmit buffer empty flag
tushki7 0:60d829a0353a 530 * @arg SPI_FLAG_CRCERR: CRC error flag
tushki7 0:60d829a0353a 531 * @arg SPI_FLAG_MODF: Mode fault flag
tushki7 0:60d829a0353a 532 * @arg SPI_FLAG_OVR: Overrun flag
tushki7 0:60d829a0353a 533 * @arg SPI_FLAG_BSY: Busy flag
tushki7 0:60d829a0353a 534 * @arg SPI_FLAG_FRE: Frame format error flag
tushki7 0:60d829a0353a 535 * @retval The new state of __FLAG__ (TRUE or FALSE).
tushki7 0:60d829a0353a 536 */
tushki7 0:60d829a0353a 537 #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
tushki7 0:60d829a0353a 538
tushki7 0:60d829a0353a 539 /** @brief Clears the SPI CRCERR pending flag.
tushki7 0:60d829a0353a 540 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 541 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 542 * @retval None
tushki7 0:60d829a0353a 543 */
tushki7 0:60d829a0353a 544 #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = ~(SPI_FLAG_CRCERR))
tushki7 0:60d829a0353a 545
tushki7 0:60d829a0353a 546 /** @brief Clears the SPI MODF pending flag.
tushki7 0:60d829a0353a 547 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 548 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 549 *
tushki7 0:60d829a0353a 550 * @retval None
tushki7 0:60d829a0353a 551 */
tushki7 0:60d829a0353a 552 #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\
tushki7 0:60d829a0353a 553 (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE);}while(0)
tushki7 0:60d829a0353a 554
tushki7 0:60d829a0353a 555 /** @brief Clears the SPI OVR pending flag.
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 *
tushki7 0:60d829a0353a 559 * @retval None
tushki7 0:60d829a0353a 560 */
tushki7 0:60d829a0353a 561 #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) do{(__HANDLE__)->Instance->DR;\
tushki7 0:60d829a0353a 562 (__HANDLE__)->Instance->SR;}while(0)
tushki7 0:60d829a0353a 563
tushki7 0:60d829a0353a 564 /** @brief Clears the SPI FRE pending flag.
tushki7 0:60d829a0353a 565 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 566 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 567 *
tushki7 0:60d829a0353a 568 * @retval None
tushki7 0:60d829a0353a 569 */
tushki7 0:60d829a0353a 570 #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR)
tushki7 0:60d829a0353a 571
tushki7 0:60d829a0353a 572 /** @brief Enables the SPI.
tushki7 0:60d829a0353a 573 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 574 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 575 * @retval None
tushki7 0:60d829a0353a 576 */
tushki7 0:60d829a0353a 577 #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE)
tushki7 0:60d829a0353a 578
tushki7 0:60d829a0353a 579 /** @brief Disables the SPI.
tushki7 0:60d829a0353a 580 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 581 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 582 * @retval None
tushki7 0:60d829a0353a 583 */
tushki7 0:60d829a0353a 584 #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_SPE)
tushki7 0:60d829a0353a 585
tushki7 0:60d829a0353a 586 /** @brief Sets the SPI transmit-only mode.
tushki7 0:60d829a0353a 587 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 588 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 589 * @retval None
tushki7 0:60d829a0353a 590 */
tushki7 0:60d829a0353a 591 #define __HAL_SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE)
tushki7 0:60d829a0353a 592
tushki7 0:60d829a0353a 593 /** @brief Sets the SPI receive-only mode.
tushki7 0:60d829a0353a 594 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 595 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 596 * @retval None
tushki7 0:60d829a0353a 597 */
tushki7 0:60d829a0353a 598 #define __HAL_SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_BIDIOE)
tushki7 0:60d829a0353a 599
tushki7 0:60d829a0353a 600 /** @brief Resets the CRC calculation of the SPI.
tushki7 0:60d829a0353a 601 * @param __HANDLE__: specifies the SPI Handle.
tushki7 0:60d829a0353a 602 * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
tushki7 0:60d829a0353a 603 * @retval None
tushki7 0:60d829a0353a 604 */
tushki7 0:60d829a0353a 605 #define __HAL_SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (~SPI_CR1_CRCEN);\
tushki7 0:60d829a0353a 606 (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0)
tushki7 0:60d829a0353a 607
tushki7 0:60d829a0353a 608
tushki7 0:60d829a0353a 609 #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x1) && ((POLYNOMIAL) <= 0xFFFF))
tushki7 0:60d829a0353a 610 /**
tushki7 0:60d829a0353a 611 * @}
tushki7 0:60d829a0353a 612 */
tushki7 0:60d829a0353a 613
tushki7 0:60d829a0353a 614 /* Exported functions --------------------------------------------------------*/
tushki7 0:60d829a0353a 615 /** @addtogroup SPI_Exported_Functions SPI Exported Functions
tushki7 0:60d829a0353a 616 * @{
tushki7 0:60d829a0353a 617 */
tushki7 0:60d829a0353a 618
tushki7 0:60d829a0353a 619 /** @addtogroup SPI_Exported_Functions_Group1 Initialization and de-initialization functions
tushki7 0:60d829a0353a 620 * @{
tushki7 0:60d829a0353a 621 */
tushki7 0:60d829a0353a 622
tushki7 0:60d829a0353a 623 /* Initialization and de-initialization functions ****************************/
tushki7 0:60d829a0353a 624 HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 625 HAL_StatusTypeDef HAL_SPI_InitExtended(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 626 HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 627 void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 628 void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 629 /**
tushki7 0:60d829a0353a 630 * @}
tushki7 0:60d829a0353a 631 */
tushki7 0:60d829a0353a 632
tushki7 0:60d829a0353a 633 /** @addtogroup SPI_Exported_Functions_Group2 Input and Output operation functions
tushki7 0:60d829a0353a 634 * @{
tushki7 0:60d829a0353a 635 */
tushki7 0:60d829a0353a 636
tushki7 0:60d829a0353a 637 /* IO operation functions *****************************************************/
tushki7 0:60d829a0353a 638 HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
tushki7 0:60d829a0353a 639 HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
tushki7 0:60d829a0353a 640 HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
tushki7 0:60d829a0353a 641 HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 642 HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 643 HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
tushki7 0:60d829a0353a 644 HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 645 HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
tushki7 0:60d829a0353a 646 HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
tushki7 0:60d829a0353a 647 void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 648 void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 649 void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 650 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 651 void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
tushki7 0:60d829a0353a 652 /**
tushki7 0:60d829a0353a 653 * @}
tushki7 0:60d829a0353a 654 */
tushki7 0:60d829a0353a 655
tushki7 0:60d829a0353a 656 /** @addtogroup SPI_Exported_Functions_Group3 Peripheral Control functions
tushki7 0:60d829a0353a 657 * @{
tushki7 0:60d829a0353a 658 */
tushki7 0:60d829a0353a 659
tushki7 0:60d829a0353a 660 /* Peripheral State and Error functions ***************************************/
tushki7 0:60d829a0353a 661 HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi);
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 /**
tushki7 0:60d829a0353a 671 * @}
tushki7 0:60d829a0353a 672 */
tushki7 0:60d829a0353a 673
tushki7 0:60d829a0353a 674 /**
tushki7 0:60d829a0353a 675 * @}
tushki7 0:60d829a0353a 676 */
tushki7 0:60d829a0353a 677
tushki7 0:60d829a0353a 678 #ifdef __cplusplus
tushki7 0:60d829a0353a 679 }
tushki7 0:60d829a0353a 680 #endif
tushki7 0:60d829a0353a 681
tushki7 0:60d829a0353a 682 #endif /* __STM32F3xx_HAL_SPI_H */
tushki7 0:60d829a0353a 683
tushki7 0:60d829a0353a 684 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/