VSF Documented
sthal_spi.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2024 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __ST_HAL_SPI_H__
19#define __ST_HAL_SPI_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26
27#include "sthal_def.h"
28
29/*============================ MACROS ========================================*/
30
31#define HAL_SPI_ERROR_NONE (0x00000000U)
32#define HAL_SPI_ERROR_MODF (0x00000001U)
33#define HAL_SPI_ERROR_CRC (0x00000002U)
34#define HAL_SPI_ERROR_OVR (0x00000004U)
35#define HAL_SPI_ERROR_FRE (0x00000008U)
36#define HAL_SPI_ERROR_DMA (0x00000010U)
37#define HAL_SPI_ERROR_FLAG (0x00000020U)
38#define HAL_SPI_ERROR_ABORT (0x00000040U)
39#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
40# define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U)
41#endif
42
43/*============================ MACROFIED FUNCTIONS ===========================*/
44/*============================ TYPES =========================================*/
45
47
48typedef struct {
61
62typedef enum {
72
73typedef struct __SPI_HandleTypeDef {
82 void (*RxISR)(struct __SPI_HandleTypeDef *hspi);
83 void (*TxISR)(struct __SPI_HandleTypeDef *hspi);
89#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
90 void (*TxCpltCallback)(struct __SPI_HandleTypeDef *hspi);
91 void (*RxCpltCallback)(struct __SPI_HandleTypeDef *hspi);
92 void (*TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi);
93 void (*TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi);
94 void (*RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi);
95 void (*TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi);
96 void (*ErrorCallback)(struct __SPI_HandleTypeDef *hspi);
97 void (*AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi);
98 void (*MspInitCallback)(struct __SPI_HandleTypeDef *hspi);
99 void (*MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi);
100
101#endif
103
104#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
105
106typedef enum {
107 HAL_SPI_TX_COMPLETE_CB_ID = 0x00U,
108 HAL_SPI_RX_COMPLETE_CB_ID = 0x01U,
109 HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U,
110 HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U,
111 HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U,
112 HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U,
113 HAL_SPI_ERROR_CB_ID = 0x06U,
114 HAL_SPI_ABORT_CB_ID = 0x07U,
115 HAL_SPI_MSPINIT_CB_ID = 0x08U,
116 HAL_SPI_MSPDEINIT_CB_ID = 0x09U
117
118} HAL_SPI_CallbackIDTypeDef;
119
120typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi);
121
122#endif
123
124/*============================ GLOBAL VARIABLES ==============================*/
125/*============================ PROTOTYPES ====================================*/
126
131
132#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
133HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi,
134 HAL_SPI_CallbackIDTypeDef CallbackID,
135 pSPI_CallbackTypeDef pCallback);
136HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(
137 SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID);
138#endif
139
141 uint16_t Size, uint32_t Timeout);
143 uint16_t Size, uint32_t Timeout);
145 uint8_t *pTxData, uint8_t *pRxData,
146 uint16_t Size, uint32_t Timeout);
148 uint16_t Size);
150 uint16_t Size);
152 uint8_t *pTxData, uint8_t *pRxData,
153 uint16_t Size);
155 uint16_t Size);
157 uint16_t Size);
159 uint8_t *pTxData,
160 uint8_t *pRxData, uint16_t Size);
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
HAL_StatusTypeDef
Definition sthal_def.h:65
HAL_LockTypeDef
Definition sthal_def.h:72
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Definition sthal_spi.c:228
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:325
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:313
HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:285
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:79
HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
Definition sthal_spi.c:278
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:349
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:319
void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:355
HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:360
HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
Definition sthal_spi.c:259
HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:295
HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Definition sthal_spi.c:272
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Definition sthal_spi.c:266
HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:290
HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout)
Definition sthal_spi.c:240
HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:305
uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:365
HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:300
HAL_SPI_StateTypeDef
Definition sthal_spi.h:62
@ HAL_SPI_STATE_BUSY
Definition sthal_spi.h:65
@ HAL_SPI_STATE_ABORT
Definition sthal_spi.h:70
@ HAL_SPI_STATE_ERROR
Definition sthal_spi.h:69
@ HAL_SPI_STATE_BUSY_TX
Definition sthal_spi.h:66
@ HAL_SPI_STATE_BUSY_TX_RX
Definition sthal_spi.h:68
@ HAL_SPI_STATE_READY
Definition sthal_spi.h:64
@ HAL_SPI_STATE_RESET
Definition sthal_spi.h:63
@ HAL_SPI_STATE_BUSY_RX
Definition sthal_spi.h:67
void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:331
HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Definition sthal_spi.c:253
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:34
vsf_spi_t SPI_TypeDef
Definition sthal_spi.h:46
void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:343
struct __SPI_HandleTypeDef SPI_HandleTypeDef
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:85
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:65
void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:337
void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi)
Definition sthal_spi.c:310
HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
Definition sthal_spi.c:247
HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Definition sthal_spi.c:234
Definition sthal_dma.h:103
Definition sthal_spi.h:73
DMA_HandleTypeDef * hdmarx
Definition sthal_spi.h:85
volatile HAL_SPI_StateTypeDef State
Definition sthal_spi.h:87
volatile uint32_t ErrorCode
Definition sthal_spi.h:88
void(* TxISR)(struct __SPI_HandleTypeDef *hspi)
Definition sthal_spi.h:83
SPI_InitTypeDef Init
Definition sthal_spi.h:75
volatile uint16_t TxXferCount
Definition sthal_spi.h:78
uint16_t TxXferSize
Definition sthal_spi.h:77
void(* RxISR)(struct __SPI_HandleTypeDef *hspi)
Definition sthal_spi.h:82
volatile uint16_t RxXferCount
Definition sthal_spi.h:81
SPI_TypeDef * Instance
Definition sthal_spi.h:74
HAL_LockTypeDef Lock
Definition sthal_spi.h:86
DMA_HandleTypeDef * hdmatx
Definition sthal_spi.h:84
uint8_t * pRxBuffPtr
Definition sthal_spi.h:79
uint16_t RxXferSize
Definition sthal_spi.h:80
uint8_t * pTxBuffPtr
Definition sthal_spi.h:76
Definition sthal_spi.h:48
uint32_t BaudRatePrescaler
Definition sthal_spi.h:55
uint32_t DataSize
Definition sthal_spi.h:51
uint32_t CRCCalculation
Definition sthal_spi.h:58
uint32_t Mode
Definition sthal_spi.h:49
uint32_t TIMode
Definition sthal_spi.h:57
uint32_t FirstBit
Definition sthal_spi.h:56
uint32_t CLKPolarity
Definition sthal_spi.h:52
uint32_t CLKPhase
Definition sthal_spi.h:53
uint32_t CRCPolynomial
Definition sthal_spi.h:59
uint32_t Direction
Definition sthal_spi.h:50
uint32_t NSS
Definition sthal_spi.h:54
Definition vsf_template_spi.h:541
struct @750 Size