Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.
Dependents: 1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB
Fork of mbed by
TARGET_ARCH_MAX/stm32f4xx_hal_spi.h@99:dbbf35b96557, 2015-05-13 (annotated)
- Committer:
- Kojto
- Date:
- Wed May 13 08:08:21 2015 +0200
- Revision:
- 99:dbbf35b96557
- Parent:
- 92:4fc01daae5a5
- Child:
- 106:ba1f97679dad
Release 99 of the mbed library
Changes:
- new targets - MAXWSNENV, DISCO_L053C8
- STM32F4xx - ST Cube driver
- KSDK mcu - SPI timing fix
- Nordic - update to softdevice s130
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 89:552587b429a1 | 1 | /** |
bogdanm | 89:552587b429a1 | 2 | ****************************************************************************** |
bogdanm | 89:552587b429a1 | 3 | * @file stm32f4xx_hal_spi.h |
bogdanm | 89:552587b429a1 | 4 | * @author MCD Application Team |
Kojto | 99:dbbf35b96557 | 5 | * @version V1.3.0 |
Kojto | 99:dbbf35b96557 | 6 | * @date 09-March-2015 |
bogdanm | 89:552587b429a1 | 7 | * @brief Header file of SPI HAL module. |
bogdanm | 89:552587b429a1 | 8 | ****************************************************************************** |
bogdanm | 89:552587b429a1 | 9 | * @attention |
bogdanm | 89:552587b429a1 | 10 | * |
Kojto | 99:dbbf35b96557 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
bogdanm | 89:552587b429a1 | 12 | * |
bogdanm | 89:552587b429a1 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 89:552587b429a1 | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 89:552587b429a1 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 89:552587b429a1 | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 89:552587b429a1 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 89:552587b429a1 | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 89:552587b429a1 | 19 | * and/or other materials provided with the distribution. |
bogdanm | 89:552587b429a1 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 89:552587b429a1 | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 89:552587b429a1 | 22 | * without specific prior written permission. |
bogdanm | 89:552587b429a1 | 23 | * |
bogdanm | 89:552587b429a1 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 89:552587b429a1 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 89:552587b429a1 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 89:552587b429a1 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 89:552587b429a1 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 89:552587b429a1 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 89:552587b429a1 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 89:552587b429a1 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 89:552587b429a1 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 89:552587b429a1 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 89:552587b429a1 | 34 | * |
bogdanm | 89:552587b429a1 | 35 | ****************************************************************************** |
bogdanm | 89:552587b429a1 | 36 | */ |
bogdanm | 89:552587b429a1 | 37 | |
bogdanm | 89:552587b429a1 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 89:552587b429a1 | 39 | #ifndef __STM32F4xx_HAL_SPI_H |
bogdanm | 89:552587b429a1 | 40 | #define __STM32F4xx_HAL_SPI_H |
bogdanm | 89:552587b429a1 | 41 | |
bogdanm | 89:552587b429a1 | 42 | #ifdef __cplusplus |
bogdanm | 89:552587b429a1 | 43 | extern "C" { |
bogdanm | 89:552587b429a1 | 44 | #endif |
bogdanm | 89:552587b429a1 | 45 | |
bogdanm | 89:552587b429a1 | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 89:552587b429a1 | 47 | #include "stm32f4xx_hal_def.h" |
bogdanm | 89:552587b429a1 | 48 | |
bogdanm | 89:552587b429a1 | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
bogdanm | 89:552587b429a1 | 50 | * @{ |
bogdanm | 89:552587b429a1 | 51 | */ |
bogdanm | 89:552587b429a1 | 52 | |
bogdanm | 89:552587b429a1 | 53 | /** @addtogroup SPI |
bogdanm | 89:552587b429a1 | 54 | * @{ |
bogdanm | 89:552587b429a1 | 55 | */ |
bogdanm | 89:552587b429a1 | 56 | |
bogdanm | 89:552587b429a1 | 57 | /* Exported types ------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 58 | /** @defgroup SPI_Exported_Types SPI Exported Types |
Kojto | 99:dbbf35b96557 | 59 | * @{ |
Kojto | 99:dbbf35b96557 | 60 | */ |
Kojto | 99:dbbf35b96557 | 61 | |
bogdanm | 89:552587b429a1 | 62 | /** |
bogdanm | 89:552587b429a1 | 63 | * @brief SPI Configuration Structure definition |
bogdanm | 89:552587b429a1 | 64 | */ |
bogdanm | 89:552587b429a1 | 65 | typedef struct |
bogdanm | 89:552587b429a1 | 66 | { |
bogdanm | 89:552587b429a1 | 67 | uint32_t Mode; /*!< Specifies the SPI operating mode. |
bogdanm | 89:552587b429a1 | 68 | This parameter can be a value of @ref SPI_mode */ |
bogdanm | 89:552587b429a1 | 69 | |
bogdanm | 89:552587b429a1 | 70 | uint32_t Direction; /*!< Specifies the SPI Directional mode state. |
bogdanm | 89:552587b429a1 | 71 | This parameter can be a value of @ref SPI_Direction_mode */ |
bogdanm | 89:552587b429a1 | 72 | |
bogdanm | 89:552587b429a1 | 73 | uint32_t DataSize; /*!< Specifies the SPI data size. |
bogdanm | 89:552587b429a1 | 74 | This parameter can be a value of @ref SPI_data_size */ |
bogdanm | 89:552587b429a1 | 75 | |
bogdanm | 89:552587b429a1 | 76 | uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. |
bogdanm | 89:552587b429a1 | 77 | This parameter can be a value of @ref SPI_Clock_Polarity */ |
bogdanm | 89:552587b429a1 | 78 | |
bogdanm | 89:552587b429a1 | 79 | uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. |
bogdanm | 89:552587b429a1 | 80 | This parameter can be a value of @ref SPI_Clock_Phase */ |
bogdanm | 89:552587b429a1 | 81 | |
bogdanm | 89:552587b429a1 | 82 | uint32_t NSS; /*!< Specifies whether the NSS signal is managed by |
bogdanm | 89:552587b429a1 | 83 | hardware (NSS pin) or by software using the SSI bit. |
bogdanm | 89:552587b429a1 | 84 | This parameter can be a value of @ref SPI_Slave_Select_management */ |
bogdanm | 89:552587b429a1 | 85 | |
bogdanm | 89:552587b429a1 | 86 | uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be |
bogdanm | 89:552587b429a1 | 87 | used to configure the transmit and receive SCK clock. |
bogdanm | 89:552587b429a1 | 88 | This parameter can be a value of @ref SPI_BaudRate_Prescaler |
bogdanm | 89:552587b429a1 | 89 | @note The communication clock is derived from the master |
bogdanm | 89:552587b429a1 | 90 | clock. The slave clock does not need to be set */ |
bogdanm | 89:552587b429a1 | 91 | |
bogdanm | 89:552587b429a1 | 92 | uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
bogdanm | 89:552587b429a1 | 93 | This parameter can be a value of @ref SPI_MSB_LSB_transmission */ |
bogdanm | 89:552587b429a1 | 94 | |
bogdanm | 89:552587b429a1 | 95 | uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not. |
bogdanm | 89:552587b429a1 | 96 | This parameter can be a value of @ref SPI_TI_mode */ |
bogdanm | 89:552587b429a1 | 97 | |
bogdanm | 89:552587b429a1 | 98 | uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. |
bogdanm | 89:552587b429a1 | 99 | This parameter can be a value of @ref SPI_CRC_Calculation */ |
bogdanm | 89:552587b429a1 | 100 | |
bogdanm | 89:552587b429a1 | 101 | uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. |
bogdanm | 89:552587b429a1 | 102 | This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */ |
bogdanm | 89:552587b429a1 | 103 | |
bogdanm | 89:552587b429a1 | 104 | }SPI_InitTypeDef; |
bogdanm | 89:552587b429a1 | 105 | |
bogdanm | 89:552587b429a1 | 106 | /** |
bogdanm | 89:552587b429a1 | 107 | * @brief HAL SPI State structure definition |
bogdanm | 89:552587b429a1 | 108 | */ |
bogdanm | 89:552587b429a1 | 109 | typedef enum |
bogdanm | 89:552587b429a1 | 110 | { |
bogdanm | 89:552587b429a1 | 111 | HAL_SPI_STATE_RESET = 0x00, /*!< SPI not yet initialized or disabled */ |
bogdanm | 89:552587b429a1 | 112 | HAL_SPI_STATE_READY = 0x01, /*!< SPI initialized and ready for use */ |
bogdanm | 89:552587b429a1 | 113 | HAL_SPI_STATE_BUSY = 0x02, /*!< SPI process is ongoing */ |
bogdanm | 89:552587b429a1 | 114 | HAL_SPI_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
bogdanm | 89:552587b429a1 | 115 | HAL_SPI_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
bogdanm | 89:552587b429a1 | 116 | HAL_SPI_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ |
bogdanm | 89:552587b429a1 | 117 | HAL_SPI_STATE_ERROR = 0x03 /*!< SPI error state */ |
bogdanm | 89:552587b429a1 | 118 | |
bogdanm | 89:552587b429a1 | 119 | }HAL_SPI_StateTypeDef; |
bogdanm | 89:552587b429a1 | 120 | |
bogdanm | 89:552587b429a1 | 121 | /** |
bogdanm | 89:552587b429a1 | 122 | * @brief SPI handle Structure definition |
bogdanm | 89:552587b429a1 | 123 | */ |
bogdanm | 89:552587b429a1 | 124 | typedef struct __SPI_HandleTypeDef |
bogdanm | 89:552587b429a1 | 125 | { |
bogdanm | 89:552587b429a1 | 126 | SPI_TypeDef *Instance; /* SPI registers base address */ |
bogdanm | 89:552587b429a1 | 127 | |
bogdanm | 89:552587b429a1 | 128 | SPI_InitTypeDef Init; /* SPI communication parameters */ |
bogdanm | 89:552587b429a1 | 129 | |
bogdanm | 89:552587b429a1 | 130 | uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */ |
bogdanm | 89:552587b429a1 | 131 | |
bogdanm | 89:552587b429a1 | 132 | uint16_t TxXferSize; /* SPI Tx transfer size */ |
bogdanm | 89:552587b429a1 | 133 | |
bogdanm | 89:552587b429a1 | 134 | uint16_t TxXferCount; /* SPI Tx Transfer Counter */ |
bogdanm | 89:552587b429a1 | 135 | |
bogdanm | 89:552587b429a1 | 136 | uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */ |
bogdanm | 89:552587b429a1 | 137 | |
bogdanm | 89:552587b429a1 | 138 | uint16_t RxXferSize; /* SPI Rx transfer size */ |
bogdanm | 89:552587b429a1 | 139 | |
bogdanm | 89:552587b429a1 | 140 | uint16_t RxXferCount; /* SPI Rx Transfer Counter */ |
bogdanm | 89:552587b429a1 | 141 | |
bogdanm | 89:552587b429a1 | 142 | DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA handle parameters */ |
bogdanm | 89:552587b429a1 | 143 | |
bogdanm | 89:552587b429a1 | 144 | DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA handle parameters */ |
bogdanm | 89:552587b429a1 | 145 | |
bogdanm | 89:552587b429a1 | 146 | void (*RxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Rx ISR */ |
bogdanm | 89:552587b429a1 | 147 | |
bogdanm | 89:552587b429a1 | 148 | void (*TxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Tx ISR */ |
bogdanm | 89:552587b429a1 | 149 | |
bogdanm | 89:552587b429a1 | 150 | HAL_LockTypeDef Lock; /* SPI locking object */ |
bogdanm | 89:552587b429a1 | 151 | |
bogdanm | 89:552587b429a1 | 152 | __IO HAL_SPI_StateTypeDef State; /* SPI communication state */ |
bogdanm | 89:552587b429a1 | 153 | |
Kojto | 99:dbbf35b96557 | 154 | __IO uint32_t ErrorCode; /* SPI Error code */ |
bogdanm | 89:552587b429a1 | 155 | |
bogdanm | 89:552587b429a1 | 156 | }SPI_HandleTypeDef; |
Kojto | 99:dbbf35b96557 | 157 | /** |
Kojto | 99:dbbf35b96557 | 158 | * @} |
Kojto | 99:dbbf35b96557 | 159 | */ |
bogdanm | 89:552587b429a1 | 160 | |
bogdanm | 89:552587b429a1 | 161 | /* Exported constants --------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 162 | /** @defgroup SPI_Exported_Constants SPI Exported Constants |
bogdanm | 89:552587b429a1 | 163 | * @{ |
bogdanm | 89:552587b429a1 | 164 | */ |
bogdanm | 89:552587b429a1 | 165 | |
Kojto | 99:dbbf35b96557 | 166 | /** @defgroup SPI_Error_Code SPI Error Code |
Kojto | 99:dbbf35b96557 | 167 | * @brief SPI Error Code |
Kojto | 99:dbbf35b96557 | 168 | * @{ |
Kojto | 99:dbbf35b96557 | 169 | */ |
Kojto | 99:dbbf35b96557 | 170 | #define HAL_SPI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ |
Kojto | 99:dbbf35b96557 | 171 | #define HAL_SPI_ERROR_MODF ((uint32_t)0x00000001) /*!< MODF error */ |
Kojto | 99:dbbf35b96557 | 172 | #define HAL_SPI_ERROR_CRC ((uint32_t)0x00000002) /*!< CRC error */ |
Kojto | 99:dbbf35b96557 | 173 | #define HAL_SPI_ERROR_OVR ((uint32_t)0x00000004) /*!< OVR error */ |
Kojto | 99:dbbf35b96557 | 174 | #define HAL_SPI_ERROR_FRE ((uint32_t)0x00000008) /*!< FRE error */ |
Kojto | 99:dbbf35b96557 | 175 | #define HAL_SPI_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */ |
Kojto | 99:dbbf35b96557 | 176 | #define HAL_SPI_ERROR_FLAG ((uint32_t)0x00000010) /*!< Flag: RXNE,TXE, BSY */ |
Kojto | 99:dbbf35b96557 | 177 | /** |
Kojto | 99:dbbf35b96557 | 178 | * @} |
Kojto | 99:dbbf35b96557 | 179 | */ |
Kojto | 99:dbbf35b96557 | 180 | |
Kojto | 99:dbbf35b96557 | 181 | /** @defgroup SPI_mode SPI Mode |
bogdanm | 89:552587b429a1 | 182 | * @{ |
bogdanm | 89:552587b429a1 | 183 | */ |
bogdanm | 89:552587b429a1 | 184 | #define SPI_MODE_SLAVE ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 185 | #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) |
bogdanm | 89:552587b429a1 | 186 | /** |
bogdanm | 89:552587b429a1 | 187 | * @} |
bogdanm | 89:552587b429a1 | 188 | */ |
bogdanm | 89:552587b429a1 | 189 | |
Kojto | 99:dbbf35b96557 | 190 | /** @defgroup SPI_Direction_mode SPI Direction Mode |
bogdanm | 89:552587b429a1 | 191 | * @{ |
bogdanm | 89:552587b429a1 | 192 | */ |
bogdanm | 89:552587b429a1 | 193 | #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 194 | #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY |
bogdanm | 89:552587b429a1 | 195 | #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE |
bogdanm | 89:552587b429a1 | 196 | /** |
bogdanm | 89:552587b429a1 | 197 | * @} |
bogdanm | 89:552587b429a1 | 198 | */ |
bogdanm | 89:552587b429a1 | 199 | |
Kojto | 99:dbbf35b96557 | 200 | /** @defgroup SPI_data_size SPI Data Size |
bogdanm | 89:552587b429a1 | 201 | * @{ |
bogdanm | 89:552587b429a1 | 202 | */ |
bogdanm | 89:552587b429a1 | 203 | #define SPI_DATASIZE_8BIT ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 204 | #define SPI_DATASIZE_16BIT SPI_CR1_DFF |
bogdanm | 89:552587b429a1 | 205 | /** |
bogdanm | 89:552587b429a1 | 206 | * @} |
bogdanm | 89:552587b429a1 | 207 | */ |
bogdanm | 89:552587b429a1 | 208 | |
Kojto | 99:dbbf35b96557 | 209 | /** @defgroup SPI_Clock_Polarity SPI Clock Polarity |
bogdanm | 89:552587b429a1 | 210 | * @{ |
bogdanm | 89:552587b429a1 | 211 | */ |
bogdanm | 89:552587b429a1 | 212 | #define SPI_POLARITY_LOW ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 213 | #define SPI_POLARITY_HIGH SPI_CR1_CPOL |
bogdanm | 89:552587b429a1 | 214 | /** |
bogdanm | 89:552587b429a1 | 215 | * @} |
bogdanm | 89:552587b429a1 | 216 | */ |
bogdanm | 89:552587b429a1 | 217 | |
Kojto | 99:dbbf35b96557 | 218 | /** @defgroup SPI_Clock_Phase SPI Clock Phase |
bogdanm | 89:552587b429a1 | 219 | * @{ |
bogdanm | 89:552587b429a1 | 220 | */ |
bogdanm | 89:552587b429a1 | 221 | #define SPI_PHASE_1EDGE ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 222 | #define SPI_PHASE_2EDGE SPI_CR1_CPHA |
bogdanm | 89:552587b429a1 | 223 | /** |
bogdanm | 89:552587b429a1 | 224 | * @} |
bogdanm | 89:552587b429a1 | 225 | */ |
bogdanm | 89:552587b429a1 | 226 | |
Kojto | 99:dbbf35b96557 | 227 | /** @defgroup SPI_Slave_Select_management SPI Slave Select Management |
bogdanm | 89:552587b429a1 | 228 | * @{ |
bogdanm | 89:552587b429a1 | 229 | */ |
bogdanm | 89:552587b429a1 | 230 | #define SPI_NSS_SOFT SPI_CR1_SSM |
bogdanm | 89:552587b429a1 | 231 | #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 232 | #define SPI_NSS_HARD_OUTPUT ((uint32_t)0x00040000) |
bogdanm | 89:552587b429a1 | 233 | /** |
bogdanm | 89:552587b429a1 | 234 | * @} |
bogdanm | 89:552587b429a1 | 235 | */ |
bogdanm | 89:552587b429a1 | 236 | |
Kojto | 99:dbbf35b96557 | 237 | /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler |
bogdanm | 89:552587b429a1 | 238 | * @{ |
bogdanm | 89:552587b429a1 | 239 | */ |
bogdanm | 89:552587b429a1 | 240 | #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 241 | #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)0x00000008) |
bogdanm | 89:552587b429a1 | 242 | #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)0x00000010) |
bogdanm | 89:552587b429a1 | 243 | #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)0x00000018) |
bogdanm | 89:552587b429a1 | 244 | #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)0x00000020) |
bogdanm | 89:552587b429a1 | 245 | #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)0x00000028) |
bogdanm | 89:552587b429a1 | 246 | #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)0x00000030) |
bogdanm | 89:552587b429a1 | 247 | #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)0x00000038) |
bogdanm | 89:552587b429a1 | 248 | /** |
bogdanm | 89:552587b429a1 | 249 | * @} |
bogdanm | 89:552587b429a1 | 250 | */ |
bogdanm | 89:552587b429a1 | 251 | |
Kojto | 99:dbbf35b96557 | 252 | /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transsmission |
bogdanm | 89:552587b429a1 | 253 | * @{ |
bogdanm | 89:552587b429a1 | 254 | */ |
bogdanm | 89:552587b429a1 | 255 | #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000) |
bogdanm | 89:552587b429a1 | 256 | #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST |
bogdanm | 89:552587b429a1 | 257 | /** |
bogdanm | 89:552587b429a1 | 258 | * @} |
bogdanm | 89:552587b429a1 | 259 | */ |
bogdanm | 89:552587b429a1 | 260 | |
Kojto | 99:dbbf35b96557 | 261 | /** @defgroup SPI_TI_mode SPI TI Mode |
bogdanm | 89:552587b429a1 | 262 | * @{ |
bogdanm | 89:552587b429a1 | 263 | */ |
Kojto | 99:dbbf35b96557 | 264 | #define SPI_TIMODE_DISABLE ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 265 | #define SPI_TIMODE_ENABLE SPI_CR2_FRF |
bogdanm | 89:552587b429a1 | 266 | /** |
bogdanm | 89:552587b429a1 | 267 | * @} |
bogdanm | 89:552587b429a1 | 268 | */ |
bogdanm | 89:552587b429a1 | 269 | |
Kojto | 99:dbbf35b96557 | 270 | /** @defgroup SPI_CRC_Calculation SPI CRC Calculation |
bogdanm | 89:552587b429a1 | 271 | * @{ |
bogdanm | 89:552587b429a1 | 272 | */ |
Kojto | 99:dbbf35b96557 | 273 | #define SPI_CRCCALCULATION_DISABLE ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 274 | #define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN |
bogdanm | 89:552587b429a1 | 275 | /** |
bogdanm | 89:552587b429a1 | 276 | * @} |
bogdanm | 89:552587b429a1 | 277 | */ |
bogdanm | 89:552587b429a1 | 278 | |
Kojto | 99:dbbf35b96557 | 279 | /** @defgroup SPI_Interrupt_definition SPI Interrupt Definition |
bogdanm | 89:552587b429a1 | 280 | * @{ |
bogdanm | 89:552587b429a1 | 281 | */ |
bogdanm | 89:552587b429a1 | 282 | #define SPI_IT_TXE SPI_CR2_TXEIE |
bogdanm | 89:552587b429a1 | 283 | #define SPI_IT_RXNE SPI_CR2_RXNEIE |
bogdanm | 89:552587b429a1 | 284 | #define SPI_IT_ERR SPI_CR2_ERRIE |
bogdanm | 89:552587b429a1 | 285 | /** |
bogdanm | 89:552587b429a1 | 286 | * @} |
bogdanm | 89:552587b429a1 | 287 | */ |
bogdanm | 89:552587b429a1 | 288 | |
Kojto | 99:dbbf35b96557 | 289 | /** @defgroup SPI_Flags_definition SPI Flags Definition |
bogdanm | 89:552587b429a1 | 290 | * @{ |
bogdanm | 89:552587b429a1 | 291 | */ |
bogdanm | 89:552587b429a1 | 292 | #define SPI_FLAG_RXNE SPI_SR_RXNE |
bogdanm | 89:552587b429a1 | 293 | #define SPI_FLAG_TXE SPI_SR_TXE |
bogdanm | 89:552587b429a1 | 294 | #define SPI_FLAG_CRCERR SPI_SR_CRCERR |
bogdanm | 89:552587b429a1 | 295 | #define SPI_FLAG_MODF SPI_SR_MODF |
bogdanm | 89:552587b429a1 | 296 | #define SPI_FLAG_OVR SPI_SR_OVR |
bogdanm | 89:552587b429a1 | 297 | #define SPI_FLAG_BSY SPI_SR_BSY |
bogdanm | 89:552587b429a1 | 298 | #define SPI_FLAG_FRE SPI_SR_FRE |
bogdanm | 89:552587b429a1 | 299 | /** |
bogdanm | 89:552587b429a1 | 300 | * @} |
bogdanm | 89:552587b429a1 | 301 | */ |
bogdanm | 89:552587b429a1 | 302 | |
bogdanm | 89:552587b429a1 | 303 | /** |
bogdanm | 89:552587b429a1 | 304 | * @} |
bogdanm | 89:552587b429a1 | 305 | */ |
bogdanm | 89:552587b429a1 | 306 | |
bogdanm | 89:552587b429a1 | 307 | /* Exported macro ------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 308 | /** @defgroup SPI_Exported_Macros SPI Exported Macros |
Kojto | 99:dbbf35b96557 | 309 | * @{ |
Kojto | 99:dbbf35b96557 | 310 | */ |
bogdanm | 89:552587b429a1 | 311 | /** @brief Reset SPI handle state |
bogdanm | 89:552587b429a1 | 312 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 313 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 314 | * @retval None |
bogdanm | 89:552587b429a1 | 315 | */ |
bogdanm | 89:552587b429a1 | 316 | #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) |
bogdanm | 89:552587b429a1 | 317 | |
bogdanm | 89:552587b429a1 | 318 | /** @brief Enable or disable the specified SPI interrupts. |
bogdanm | 89:552587b429a1 | 319 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 320 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 321 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable. |
bogdanm | 89:552587b429a1 | 322 | * This parameter can be one of the following values: |
bogdanm | 89:552587b429a1 | 323 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
bogdanm | 89:552587b429a1 | 324 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
bogdanm | 89:552587b429a1 | 325 | * @arg SPI_IT_ERR: Error interrupt enable |
bogdanm | 89:552587b429a1 | 326 | * @retval None |
bogdanm | 89:552587b429a1 | 327 | */ |
bogdanm | 89:552587b429a1 | 328 | #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) |
bogdanm | 89:552587b429a1 | 329 | #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__))) |
bogdanm | 89:552587b429a1 | 330 | |
bogdanm | 89:552587b429a1 | 331 | /** @brief Check if the specified SPI interrupt source is enabled or disabled. |
bogdanm | 89:552587b429a1 | 332 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 333 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 334 | * @param __INTERRUPT__: specifies the SPI interrupt source to check. |
bogdanm | 89:552587b429a1 | 335 | * This parameter can be one of the following values: |
bogdanm | 89:552587b429a1 | 336 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
bogdanm | 89:552587b429a1 | 337 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
bogdanm | 89:552587b429a1 | 338 | * @arg SPI_IT_ERR: Error interrupt enable |
bogdanm | 89:552587b429a1 | 339 | * @retval The new state of __IT__ (TRUE or FALSE). |
bogdanm | 89:552587b429a1 | 340 | */ |
bogdanm | 89:552587b429a1 | 341 | #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
bogdanm | 89:552587b429a1 | 342 | |
bogdanm | 89:552587b429a1 | 343 | /** @brief Check whether the specified SPI flag is set or not. |
bogdanm | 89:552587b429a1 | 344 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 345 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 346 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 89:552587b429a1 | 347 | * This parameter can be one of the following values: |
bogdanm | 89:552587b429a1 | 348 | * @arg SPI_FLAG_RXNE: Receive buffer not empty flag |
bogdanm | 89:552587b429a1 | 349 | * @arg SPI_FLAG_TXE: Transmit buffer empty flag |
bogdanm | 89:552587b429a1 | 350 | * @arg SPI_FLAG_CRCERR: CRC error flag |
bogdanm | 89:552587b429a1 | 351 | * @arg SPI_FLAG_MODF: Mode fault flag |
bogdanm | 89:552587b429a1 | 352 | * @arg SPI_FLAG_OVR: Overrun flag |
bogdanm | 89:552587b429a1 | 353 | * @arg SPI_FLAG_BSY: Busy flag |
bogdanm | 89:552587b429a1 | 354 | * @arg SPI_FLAG_FRE: Frame format error flag |
bogdanm | 89:552587b429a1 | 355 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
bogdanm | 89:552587b429a1 | 356 | */ |
bogdanm | 89:552587b429a1 | 357 | #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
bogdanm | 89:552587b429a1 | 358 | |
bogdanm | 89:552587b429a1 | 359 | /** @brief Clear the SPI CRCERR pending flag. |
bogdanm | 89:552587b429a1 | 360 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 361 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 362 | * @retval None |
bogdanm | 89:552587b429a1 | 363 | */ |
bogdanm | 92:4fc01daae5a5 | 364 | #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = ~(SPI_FLAG_CRCERR)) |
bogdanm | 89:552587b429a1 | 365 | |
bogdanm | 89:552587b429a1 | 366 | /** @brief Clear the SPI MODF pending flag. |
bogdanm | 89:552587b429a1 | 367 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 368 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 369 | * @retval None |
bogdanm | 89:552587b429a1 | 370 | */ |
Kojto | 99:dbbf35b96557 | 371 | #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \ |
Kojto | 99:dbbf35b96557 | 372 | do{ \ |
Kojto | 99:dbbf35b96557 | 373 | __IO uint32_t tmpreg; \ |
Kojto | 99:dbbf35b96557 | 374 | tmpreg = (__HANDLE__)->Instance->SR; \ |
Kojto | 99:dbbf35b96557 | 375 | (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE); \ |
Kojto | 99:dbbf35b96557 | 376 | UNUSED(tmpreg); \ |
Kojto | 99:dbbf35b96557 | 377 | } while(0) |
bogdanm | 89:552587b429a1 | 378 | |
bogdanm | 89:552587b429a1 | 379 | /** @brief Clear the SPI OVR pending flag. |
bogdanm | 89:552587b429a1 | 380 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 381 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 382 | * @retval None |
bogdanm | 89:552587b429a1 | 383 | */ |
Kojto | 99:dbbf35b96557 | 384 | #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \ |
Kojto | 99:dbbf35b96557 | 385 | do{ \ |
Kojto | 99:dbbf35b96557 | 386 | __IO uint32_t tmpreg; \ |
Kojto | 99:dbbf35b96557 | 387 | tmpreg = (__HANDLE__)->Instance->DR; \ |
Kojto | 99:dbbf35b96557 | 388 | tmpreg = (__HANDLE__)->Instance->SR; \ |
Kojto | 99:dbbf35b96557 | 389 | UNUSED(tmpreg); \ |
Kojto | 99:dbbf35b96557 | 390 | } while(0) |
bogdanm | 89:552587b429a1 | 391 | |
bogdanm | 89:552587b429a1 | 392 | /** @brief Clear the SPI FRE pending flag. |
bogdanm | 89:552587b429a1 | 393 | * @param __HANDLE__: specifies the SPI handle. |
bogdanm | 89:552587b429a1 | 394 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
bogdanm | 89:552587b429a1 | 395 | * @retval None |
Kojto | 99:dbbf35b96557 | 396 | */ |
Kojto | 99:dbbf35b96557 | 397 | #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \ |
Kojto | 99:dbbf35b96557 | 398 | do{ \ |
Kojto | 99:dbbf35b96557 | 399 | __IO uint32_t tmpreg; \ |
Kojto | 99:dbbf35b96557 | 400 | tmpreg = (__HANDLE__)->Instance->SR; \ |
Kojto | 99:dbbf35b96557 | 401 | UNUSED(tmpreg); \ |
Kojto | 99:dbbf35b96557 | 402 | }while(0) |
Kojto | 99:dbbf35b96557 | 403 | |
Kojto | 99:dbbf35b96557 | 404 | /** @brief Enable SPI |
Kojto | 99:dbbf35b96557 | 405 | * @param __HANDLE__: specifies the SPI Handle. |
Kojto | 99:dbbf35b96557 | 406 | * @retval None |
bogdanm | 89:552587b429a1 | 407 | */ |
bogdanm | 89:552587b429a1 | 408 | #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE) |
bogdanm | 89:552587b429a1 | 409 | |
Kojto | 99:dbbf35b96557 | 410 | /** @brief Disable SPI |
Kojto | 99:dbbf35b96557 | 411 | * @param __HANDLE__: specifies the SPI Handle. |
Kojto | 99:dbbf35b96557 | 412 | * @retval None |
Kojto | 99:dbbf35b96557 | 413 | */ |
Kojto | 99:dbbf35b96557 | 414 | #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_SPE) |
Kojto | 99:dbbf35b96557 | 415 | /** |
Kojto | 99:dbbf35b96557 | 416 | * @} |
Kojto | 99:dbbf35b96557 | 417 | */ |
Kojto | 99:dbbf35b96557 | 418 | |
Kojto | 99:dbbf35b96557 | 419 | /* Exported functions --------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 420 | /** @addtogroup SPI_Exported_Functions |
Kojto | 99:dbbf35b96557 | 421 | * @{ |
Kojto | 99:dbbf35b96557 | 422 | */ |
bogdanm | 89:552587b429a1 | 423 | |
Kojto | 99:dbbf35b96557 | 424 | /** @addtogroup SPI_Exported_Functions_Group1 |
Kojto | 99:dbbf35b96557 | 425 | * @{ |
Kojto | 99:dbbf35b96557 | 426 | */ |
bogdanm | 89:552587b429a1 | 427 | /* Initialization/de-initialization functions **********************************/ |
bogdanm | 89:552587b429a1 | 428 | HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 429 | HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 430 | void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 431 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); |
Kojto | 99:dbbf35b96557 | 432 | /** |
Kojto | 99:dbbf35b96557 | 433 | * @} |
Kojto | 99:dbbf35b96557 | 434 | */ |
bogdanm | 89:552587b429a1 | 435 | |
Kojto | 99:dbbf35b96557 | 436 | /** @addtogroup SPI_Exported_Functions_Group2 |
Kojto | 99:dbbf35b96557 | 437 | * @{ |
Kojto | 99:dbbf35b96557 | 438 | */ |
bogdanm | 89:552587b429a1 | 439 | /* I/O operation functions *****************************************************/ |
bogdanm | 89:552587b429a1 | 440 | HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
bogdanm | 89:552587b429a1 | 441 | HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
bogdanm | 89:552587b429a1 | 442 | HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
bogdanm | 89:552587b429a1 | 443 | HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
bogdanm | 89:552587b429a1 | 444 | HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
bogdanm | 89:552587b429a1 | 445 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
bogdanm | 89:552587b429a1 | 446 | HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
bogdanm | 89:552587b429a1 | 447 | HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
bogdanm | 89:552587b429a1 | 448 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
bogdanm | 92:4fc01daae5a5 | 449 | HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); |
bogdanm | 92:4fc01daae5a5 | 450 | HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); |
bogdanm | 92:4fc01daae5a5 | 451 | HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi); |
bogdanm | 92:4fc01daae5a5 | 452 | |
bogdanm | 89:552587b429a1 | 453 | void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 454 | void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 455 | void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 456 | void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 457 | void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); |
bogdanm | 92:4fc01daae5a5 | 458 | void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi); |
bogdanm | 92:4fc01daae5a5 | 459 | void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi); |
bogdanm | 92:4fc01daae5a5 | 460 | void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi); |
Kojto | 99:dbbf35b96557 | 461 | /** |
Kojto | 99:dbbf35b96557 | 462 | * @} |
Kojto | 99:dbbf35b96557 | 463 | */ |
Kojto | 99:dbbf35b96557 | 464 | |
Kojto | 99:dbbf35b96557 | 465 | /** @addtogroup SPI_Exported_Functions_Group3 |
Kojto | 99:dbbf35b96557 | 466 | * @{ |
Kojto | 99:dbbf35b96557 | 467 | */ |
bogdanm | 89:552587b429a1 | 468 | /* Peripheral State and Control functions **************************************/ |
bogdanm | 89:552587b429a1 | 469 | HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); |
Kojto | 99:dbbf35b96557 | 470 | uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi); |
bogdanm | 89:552587b429a1 | 471 | |
bogdanm | 89:552587b429a1 | 472 | /** |
bogdanm | 89:552587b429a1 | 473 | * @} |
bogdanm | 89:552587b429a1 | 474 | */ |
bogdanm | 89:552587b429a1 | 475 | |
bogdanm | 89:552587b429a1 | 476 | /** |
bogdanm | 89:552587b429a1 | 477 | * @} |
bogdanm | 89:552587b429a1 | 478 | */ |
bogdanm | 89:552587b429a1 | 479 | |
Kojto | 99:dbbf35b96557 | 480 | /* Private types -------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 481 | /* Private variables ---------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 482 | /* Private constants ---------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 483 | /** @defgroup SPI_Private_Constants SPI Private Constants |
Kojto | 99:dbbf35b96557 | 484 | * @{ |
Kojto | 99:dbbf35b96557 | 485 | */ |
Kojto | 99:dbbf35b96557 | 486 | /** |
Kojto | 99:dbbf35b96557 | 487 | * @} |
Kojto | 99:dbbf35b96557 | 488 | */ |
Kojto | 99:dbbf35b96557 | 489 | |
Kojto | 99:dbbf35b96557 | 490 | /* Private macros ------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 491 | /** @defgroup SPI_Private_Macros SPI Private Macros |
Kojto | 99:dbbf35b96557 | 492 | * @{ |
Kojto | 99:dbbf35b96557 | 493 | */ |
Kojto | 99:dbbf35b96557 | 494 | |
Kojto | 99:dbbf35b96557 | 495 | #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \ |
Kojto | 99:dbbf35b96557 | 496 | ((MODE) == SPI_MODE_MASTER)) |
Kojto | 99:dbbf35b96557 | 497 | |
Kojto | 99:dbbf35b96557 | 498 | |
Kojto | 99:dbbf35b96557 | 499 | #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ |
Kojto | 99:dbbf35b96557 | 500 | ((MODE) == SPI_DIRECTION_2LINES_RXONLY) || \ |
Kojto | 99:dbbf35b96557 | 501 | ((MODE) == SPI_DIRECTION_1LINE)) |
Kojto | 99:dbbf35b96557 | 502 | |
Kojto | 99:dbbf35b96557 | 503 | #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ |
Kojto | 99:dbbf35b96557 | 504 | ((MODE) == SPI_DIRECTION_1LINE)) |
Kojto | 99:dbbf35b96557 | 505 | |
Kojto | 99:dbbf35b96557 | 506 | #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES) |
Kojto | 99:dbbf35b96557 | 507 | |
Kojto | 99:dbbf35b96557 | 508 | #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \ |
Kojto | 99:dbbf35b96557 | 509 | ((DATASIZE) == SPI_DATASIZE_8BIT)) |
Kojto | 99:dbbf35b96557 | 510 | |
Kojto | 99:dbbf35b96557 | 511 | #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \ |
Kojto | 99:dbbf35b96557 | 512 | ((CPOL) == SPI_POLARITY_HIGH)) |
Kojto | 99:dbbf35b96557 | 513 | |
Kojto | 99:dbbf35b96557 | 514 | #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \ |
Kojto | 99:dbbf35b96557 | 515 | ((CPHA) == SPI_PHASE_2EDGE)) |
Kojto | 99:dbbf35b96557 | 516 | |
Kojto | 99:dbbf35b96557 | 517 | #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \ |
Kojto | 99:dbbf35b96557 | 518 | ((NSS) == SPI_NSS_HARD_INPUT) || \ |
Kojto | 99:dbbf35b96557 | 519 | ((NSS) == SPI_NSS_HARD_OUTPUT)) |
Kojto | 99:dbbf35b96557 | 520 | |
Kojto | 99:dbbf35b96557 | 521 | #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \ |
Kojto | 99:dbbf35b96557 | 522 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \ |
Kojto | 99:dbbf35b96557 | 523 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \ |
Kojto | 99:dbbf35b96557 | 524 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \ |
Kojto | 99:dbbf35b96557 | 525 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \ |
Kojto | 99:dbbf35b96557 | 526 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \ |
Kojto | 99:dbbf35b96557 | 527 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \ |
Kojto | 99:dbbf35b96557 | 528 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_256)) |
Kojto | 99:dbbf35b96557 | 529 | |
Kojto | 99:dbbf35b96557 | 530 | #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \ |
Kojto | 99:dbbf35b96557 | 531 | ((BIT) == SPI_FIRSTBIT_LSB)) |
Kojto | 99:dbbf35b96557 | 532 | |
Kojto | 99:dbbf35b96557 | 533 | #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLE) || \ |
Kojto | 99:dbbf35b96557 | 534 | ((MODE) == SPI_TIMODE_ENABLE)) |
Kojto | 99:dbbf35b96557 | 535 | |
Kojto | 99:dbbf35b96557 | 536 | #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLE) || \ |
Kojto | 99:dbbf35b96557 | 537 | ((CALCULATION) == SPI_CRCCALCULATION_ENABLE)) |
Kojto | 99:dbbf35b96557 | 538 | |
Kojto | 99:dbbf35b96557 | 539 | #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x1) && ((POLYNOMIAL) <= 0xFFFF)) |
Kojto | 99:dbbf35b96557 | 540 | |
Kojto | 99:dbbf35b96557 | 541 | #define SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE) |
Kojto | 99:dbbf35b96557 | 542 | |
Kojto | 99:dbbf35b96557 | 543 | #define SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_BIDIOE) |
Kojto | 99:dbbf35b96557 | 544 | |
Kojto | 99:dbbf35b96557 | 545 | #define SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (~SPI_CR1_CRCEN);\ |
Kojto | 99:dbbf35b96557 | 546 | (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0) |
Kojto | 99:dbbf35b96557 | 547 | /** |
Kojto | 99:dbbf35b96557 | 548 | * @} |
Kojto | 99:dbbf35b96557 | 549 | */ |
Kojto | 99:dbbf35b96557 | 550 | |
Kojto | 99:dbbf35b96557 | 551 | /* Private functions ---------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 552 | /** @defgroup SPI_Private_Functions SPI Private Functions |
Kojto | 99:dbbf35b96557 | 553 | * @{ |
Kojto | 99:dbbf35b96557 | 554 | */ |
Kojto | 99:dbbf35b96557 | 555 | |
Kojto | 99:dbbf35b96557 | 556 | /** |
Kojto | 99:dbbf35b96557 | 557 | * @} |
Kojto | 99:dbbf35b96557 | 558 | */ |
Kojto | 99:dbbf35b96557 | 559 | |
Kojto | 99:dbbf35b96557 | 560 | /** |
Kojto | 99:dbbf35b96557 | 561 | * @} |
Kojto | 99:dbbf35b96557 | 562 | */ |
Kojto | 99:dbbf35b96557 | 563 | |
Kojto | 99:dbbf35b96557 | 564 | /** |
Kojto | 99:dbbf35b96557 | 565 | * @} |
Kojto | 99:dbbf35b96557 | 566 | */ |
Kojto | 99:dbbf35b96557 | 567 | |
Kojto | 99:dbbf35b96557 | 568 | |
bogdanm | 89:552587b429a1 | 569 | #ifdef __cplusplus |
bogdanm | 89:552587b429a1 | 570 | } |
bogdanm | 89:552587b429a1 | 571 | #endif |
bogdanm | 89:552587b429a1 | 572 | |
bogdanm | 89:552587b429a1 | 573 | #endif /* __STM32F4xx_HAL_SPI_H */ |
bogdanm | 89:552587b429a1 | 574 | |
bogdanm | 89:552587b429a1 | 575 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |