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