1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
/**
******************************************************************************
* @file stm32h7xx_hal_pssi.h
* @author MCD Application Team
* @brief Header file of PSSI HAL module.
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32H7xx_HAL_PSSI_H
#define STM32H7xx_HAL_PSSI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal_def.h"
/** @addtogroup STM32H7xx_HAL_Driver
* @{
*/
#if defined(PSSI)
/** @addtogroup PSSI PSSI
* @brief PSSI HAL module driver
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup PSSI_Exported_Types PSSI Exported Types
* @{
*/
/**
* @brief PSSI Init structure definition
*/
typedef struct
{
uint32_t DataWidth; /* !< Configures the parallel bus width 8 lines or 16 lines */
uint32_t BusWidth; /* !< Configures the parallel bus width 8 lines or 16 lines */
uint32_t ControlSignal; /* !< Configures Data enable and Data ready */
uint32_t ClockPolarity; /* !< Configures the PSSI Input Clock polarity */
uint32_t DataEnablePolarity; /* !< Configures the PSSI Data Enable polarity */
uint32_t ReadyPolarity; /* !< Configures the PSSI Ready polarity */
} PSSI_InitTypeDef;
/**
* @brief HAL PSSI State structures definition
*/
typedef enum
{
HAL_PSSI_STATE_RESET = 0x00U, /* !< PSSI not yet initialized or disabled */
HAL_PSSI_STATE_READY = 0x01U, /* !< Peripheral initialized and ready for use */
HAL_PSSI_STATE_BUSY = 0x02U, /* !< An internal process is ongoing */
HAL_PSSI_STATE_BUSY_TX = 0x03U, /* !< Transmit process is ongoing */
HAL_PSSI_STATE_BUSY_RX = 0x04U, /* !< Receive process is ongoing */
HAL_PSSI_STATE_TIMEOUT = 0x05U, /* !< Timeout state */
HAL_PSSI_STATE_ERROR = 0x06U, /* !< PSSI state error */
HAL_PSSI_STATE_ABORT = 0x07U, /* !< PSSI process is aborted */
} HAL_PSSI_StateTypeDef;
/**
* @brief PSSI handle Structure definition
*/
typedef struct __PSSI_HandleTypeDef
{
PSSI_TypeDef *Instance; /*!< PSSI register base address. */
PSSI_InitTypeDef Init; /*!< PSSI Initialization Structure. */
uint32_t *pBuffPtr; /*!< PSSI Data buffer. */
uint32_t XferCount; /*!< PSSI transfer count */
uint32_t XferSize; /*!< PSSI transfer size */
DMA_HandleTypeDef *hdmatx; /*!< PSSI Tx DMA Handle parameters */
DMA_HandleTypeDef *hdmarx; /*!< PSSI Rx DMA Handle parameters */
void (* TxCpltCallback)(struct __PSSI_HandleTypeDef *hpssi); /*!< PSSI transfer complete callback. */
void (* RxCpltCallback)(struct __PSSI_HandleTypeDef *hpssi); /*!< PSSI transfer complete callback. */
void (* ErrorCallback)(struct __PSSI_HandleTypeDef *hpssi); /*!< PSSI transfer complete callback. */
void (* AbortCpltCallback)(struct __PSSI_HandleTypeDef *hpssi); /*!< PSSI transfer error callback. */
void (* MspInitCallback)(struct __PSSI_HandleTypeDef *hpssi); /*!< PSSI Msp Init callback. */
void (* MspDeInitCallback)(struct __PSSI_HandleTypeDef *hpssi); /*!< PSSI Msp DeInit callback. */
HAL_LockTypeDef Lock; /*!< PSSI lock. */
__IO HAL_PSSI_StateTypeDef State; /*!< PSSI transfer state. */
__IO uint32_t ErrorCode; /*!< PSSI error code. */
} PSSI_HandleTypeDef;
/**
* @brief HAL PSSI Callback pointer definition
*/
typedef void (*pPSSI_CallbackTypeDef)(PSSI_HandleTypeDef *hpssi); /*!< Pointer to a PSSI common callback function */
/**
* @brief HAL PSSI Callback ID enumeration definition
*/
typedef enum
{
HAL_PSSI_TX_COMPLETE_CB_ID = 0x00U, /*!< PSSI Tx Transfer completed callback ID */
HAL_PSSI_RX_COMPLETE_CB_ID = 0x01U, /*!< PSSI Rx Transfer completed callback ID */
HAL_PSSI_ERROR_CB_ID = 0x03U, /*!< PSSI Error callback ID */
HAL_PSSI_ABORT_CB_ID = 0x04U, /*!< PSSI Abort callback ID */
HAL_PSSI_MSPINIT_CB_ID = 0x05U, /*!< PSSI Msp Init callback ID */
HAL_PSSI_MSPDEINIT_CB_ID = 0x06U /*!< PSSI Msp DeInit callback ID */
} HAL_PSSI_CallbackIDTypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup PSSI_Exported_Constants PSSI Exported Constants
* @{
*/
/** @defgroup PSSI_Error_Code PSSI Error Code
* @{
*/
#define HAL_PSSI_ERROR_NONE 0x00000000U /*!< No error */
#define HAL_PSSI_ERROR_NOT_SUPPORTED 0x00000001U /*!< Not supported operation */
#define HAL_PSSI_ERROR_UNDER_RUN 0x00000002U /*!< FIFO Under-run error */
#define HAL_PSSI_ERROR_OVER_RUN 0x00000004U /*!< FIFO Over-run error */
#define HAL_PSSI_ERROR_DMA 0x00000008U /*!< Dma error */
#define HAL_PSSI_ERROR_TIMEOUT 0x00000010U /*!< Timeout error */
#define HAL_PSSI_ERROR_INVALID_CALLBACK 0x00000020U /*!< Invalid callback error */
/**
* @}
*/
/** @defgroup PSSI_DATA_WIDTH PSSI Data Width
* @{
*/
#define HAL_PSSI_8BITS 0x00000000U /*!< 8 Bits */
#define HAL_PSSI_16BITS 0x00000001U /*!< 16 Bits */
#define HAL_PSSI_32BITS 0x00000002U /*!< 32 Bits */
/**
* @}
*/
/** @defgroup PSSI_BUS_WIDTH PSSI Bus Width
* @{
*/
#define HAL_PSSI_8LINES 0x00000000U /*!< 8 data lines */
#define HAL_PSSI_16LINES PSSI_CR_EDM /*!< 16 data lines */
/**
* @}
*/
/** @defgroup PSSI_MODE PSSI mode
* @{
*/
#define HAL_PSSI_UNIDIRECTIONAL 0x00000000U /*!< Uni-directional mode */
#define HAL_PSSI_BIDIRECTIONAL 0x00000001U /*!< Bi-directional mode */
/**
* @}
*/
/** @defgroup ControlSignal_Configuration ControlSignal Configuration
* @{
*/
#define HAL_PSSI_DE_RDY_DISABLE (0x0U << PSSI_CR_DERDYCFG_Pos) /*!< Neither DE nor RDY are enabled */
#define HAL_PSSI_RDY_ENABLE (0x1U << PSSI_CR_DERDYCFG_Pos) /*!< Only RDY enabled */
#define HAL_PSSI_DE_ENABLE (0x2U << PSSI_CR_DERDYCFG_Pos) /*!< Only DE enabled */
#define HAL_PSSI_DE_RDY_ALT_ENABLE (0x3U << PSSI_CR_DERDYCFG_Pos) /*!< Both RDY and DE alternate functions enabled */
#define HAL_PSSI_MAP_RDY_BIDIR_ENABLE (0x4U << PSSI_CR_DERDYCFG_Pos) /*!< Bi-directional on RDY pin */
#define HAL_PSSI_RDY_MAP_ENABLE (0x5U << PSSI_CR_DERDYCFG_Pos) /*!< Only RDY enabled, mapped to DE pin */
#define HAL_PSSI_DE_MAP_ENABLE (0x6U << PSSI_CR_DERDYCFG_Pos) /*!< Only DE enabled, mapped to RDY pin */
#define HAL_PSSI_MAP_DE_BIDIR_ENABLE (0x7U << PSSI_CR_DERDYCFG_Pos) /*!< Bi-directional on DE pin */
/**
* @}
*/
/** @defgroup Data_Enable_Polarity Data Enable Polarity
* @{
*/
#define HAL_PSSI_DEPOL_ACTIVE_LOW 0x0U /*!< Active Low */
#define HAL_PSSI_DEPOL_ACTIVE_HIGH PSSI_CR_DEPOL /*!< Active High */
/**
* @}
*/
/** @defgroup Reday_Polarity Reday Polarity
* @{
*/
#define HAL_PSSI_RDYPOL_ACTIVE_LOW 0x0U /*!< Active Low */
#define HAL_PSSI_RDYPOL_ACTIVE_HIGH PSSI_CR_RDYPOL /*!< Active High */
/**
* @}
*/
/** @defgroup Clock_Polarity Clock Polarity
* @{
*/
#define HAL_PSSI_FALLING_EDGE 0x0U /*!< Fallling Edge */
#define HAL_PSSI_RISING_EDGE 0x1U /*!< Rising Edge */
/**
* @}
*/
/** @defgroup PSSI_DEFINITION PSSI definitions
* @{
*/
#define PSSI_MAX_NBYTE_SIZE 0x10000U /* 64 KB */
#define PSSI_TIMEOUT_TRANSMIT 0x0000FFFFU /*!< Timeout Value */
#define PSSI_CR_OUTEN_INPUT 0x00000000U /*!< Input Mode */
#define PSSI_CR_OUTEN_OUTPUT PSSI_CR_OUTEN /*!< Output Mode */
#define PSSI_CR_DMA_ENABLE PSSI_CR_DMAEN /*!< DMA Mode Enable */
#define PSSI_CR_DMA_DISABLE (~PSSI_CR_DMAEN) /*!< DMA Mode Disable*/
#define PSSI_CR_16BITS PSSI_CR_EDM /*!< 16 Lines Mode */
#define PSSI_CR_8BITS (~PSSI_CR_EDM) /*!< 8 Lines Mode */
#define PSSI_FLAG_RTT1B PSSI_SR_RTT1B /*!< 1 Byte Fifo Flag*/
#define PSSI_FLAG_RTT4B PSSI_SR_RTT4B /*!< 4 Bytes Fifo Flag*/
/**
* @}
*/
/** @defgroup PSSI_Interrupts PSSI Interrupts
* @{
*/
#define PSSI_FLAG_OVR_RIS PSSI_RIS_OVR_RIS /*!< Overrun, Underrun errors flag */
#define PSSI_FLAG_MASK PSSI_RIS_OVR_RIS_Msk /*!< Overrun, Underrun errors Mask */
#define PSSI_FLAG_OVR_MIS PSSI_MIS_OVR_MIS /*!< Overrun, Underrun masked errors flag */
/**
* @}
*/
/**
* @}
*/
/* Exported macros ------------------------------------------------------------*/
/** @defgroup PSSI_Exported_Macros PSSI Exported Macros
* @{
*/
/** @brief Reset PSSI handle state
* @param __HANDLE__ specifies the PSSI handle.
* @retval None
*/
#define HAL_PSSI_RESET_HANDLE_STATE(__HANDLE__) do{ \
(__HANDLE__)->State = HAL_PSSI_STATE_RESET;\
(__HANDLE__)->MspInitCallback = NULL; \
(__HANDLE__)->MspDeInitCallback = NULL; \
}while(0)
/**
* @brief Enable the PSSI.
* @param __HANDLE__ PSSI handle
* @retval None.
*/
#define HAL_PSSI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= PSSI_CR_ENABLE)
/**
* @brief Disable the PSSI.
* @param __HANDLE__ PSSI handle
* @retval None.
*/
#define HAL_PSSI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= (~PSSI_CR_ENABLE))
/* PSSI pripheral STATUS */
/**
* @brief Get the PSSI pending flags.
* @param __HANDLE__ PSSI handle
* @param __FLAG__ flag to check.
* This parameter can be any combination of the following values:
* @arg PSSI_FLAG_RTT1B: FIFO is ready to transfer one byte
* @arg PSSI_FLAG_RTT4B: FIFO is ready to transfer four bytes
* @retval The state of FLAG.
*/
#define HAL_PSSI_GET_STATUS(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR & (__FLAG__))
/* Interrupt & Flag management */
/**
* @brief Get the PSSI pending flags.
* @param __HANDLE__ PSSI handle
* @param __FLAG__ flag to check.
* This parameter can be any combination of the following values:
* @arg PSSI_FLAG_OVR_RIS: Data Buffer overrun/underrun error flag
* @retval The state of FLAG.
*/
#define HAL_PSSI_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->RIS & (__FLAG__))
/**
* @brief Clear the PSSI pending flags.
* @param __HANDLE__ PSSI handle
* @param __FLAG__ specifies the flag to clear.
* This parameter can be any combination of the following values:
* @arg PSSI_FLAG_OVR_RIS: Data Buffer overrun/underrun error flag
* @retval None
*/
#define HAL_PSSI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
/**
* @brief Enable the specified PSSI interrupts.
* @param __HANDLE__ PSSI handle
* @param __INTERRUPT__ specifies the PSSI interrupt sources to be enabled.
* This parameter can be any combination of the following values:
* @arg PSSI_FLAG_OVR_RIS: Configuration error mask
* @retval None
*/
#define HAL_PSSI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
/**
* @brief Disable the specified PSSI interrupts.
* @param __HANDLE__ PSSI handle
* @param __INTERRUPT__ specifies the PSSI interrupt sources to be disabled.
* This parameter can be any combination of the following values:
* @arg PSSI_IT_OVR_IE: Configuration error mask
* @retval None
*/
#define HAL_PSSI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__))
/**
* @brief Check whether the specified PSSI interrupt source is enabled or not.
* @param __HANDLE__ PSSI handle
* @param __INTERRUPT__ specifies the PSSI interrupt source to check.
* This parameter can be one of the following values:
* @arg PSSI_IT_OVR_IE: Data Buffer overrun/underrun error interrupt mask
* @retval The state of INTERRUPT source.
*/
#define HAL_PSSI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER & (__INTERRUPT__))
/**
* @brief Check whether the PSSI Control signal is valid.
* @param __CONTROL__ Control signals configuration
* @retval Valid or not.
*/
#define IS_PSSI_CONTROL_SIGNAL(__CONTROL__) (((__CONTROL__) == HAL_PSSI_DE_RDY_DISABLE ) || \
((__CONTROL__) == HAL_PSSI_RDY_ENABLE ) || \
((__CONTROL__) == HAL_PSSI_DE_ENABLE ) || \
((__CONTROL__) == HAL_PSSI_DE_RDY_ALT_ENABLE ) || \
((__CONTROL__) == HAL_PSSI_MAP_RDY_BIDIR_ENABLE ) || \
((__CONTROL__) == HAL_PSSI_RDY_MAP_ENABLE ) || \
((__CONTROL__) == HAL_PSSI_DE_MAP_ENABLE ) || \
((__CONTROL__) == HAL_PSSI_MAP_DE_BIDIR_ENABLE ))
/**
* @brief Check whether the PSSI Bus Width is valid.
* @param __BUSWIDTH__ PSSI Bush width
* @retval Valid or not.
*/
#define IS_PSSI_BUSWIDTH(__BUSWIDTH__) (((__BUSWIDTH__) == HAL_PSSI_8LINES ) || \
((__BUSWIDTH__) == HAL_PSSI_16LINES ))
/**
* @brief Check whether the PSSI Clock Polarity is valid.
* @param __CLOCKPOL__ PSSI Clock Polarity
* @retval Valid or not.
*/
#define IS_PSSI_CLOCK_POLARITY(__CLOCKPOL__) (((__CLOCKPOL__) == HAL_PSSI_FALLING_EDGE ) || \
((__CLOCKPOL__) == HAL_PSSI_RISING_EDGE ))
/**
* @brief Check whether the PSSI Data Enable Polarity is valid.
* @param __DEPOL__ PSSI DE Polarity
* @retval Valid or not.
*/
#define IS_PSSI_DE_POLARITY(__DEPOL__) (((__DEPOL__) == HAL_PSSI_DEPOL_ACTIVE_LOW ) || \
((__DEPOL__) == HAL_PSSI_DEPOL_ACTIVE_HIGH ))
/**
* @brief Check whether the PSSI Ready Polarity is valid.
* @param __RDYPOL__ PSSI RDY Polarity
* @retval Valid or not.
*/
#define IS_PSSI_RDY_POLARITY(__RDYPOL__) (((__RDYPOL__) == HAL_PSSI_RDYPOL_ACTIVE_LOW ) || \
((__RDYPOL__) == HAL_PSSI_RDYPOL_ACTIVE_HIGH ))
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup PSSI_Exported_Functions PSSI Exported Functions
* @{
*/
/** @addtogroup PSSI_Exported_Functions_Group1 Initialization and de-initialization functions
* @{
*/
/* Initialization and de-initialization functions *******************************/
HAL_StatusTypeDef HAL_PSSI_Init(PSSI_HandleTypeDef *hpssi);
HAL_StatusTypeDef HAL_PSSI_DeInit(PSSI_HandleTypeDef *hpssi);
void HAL_PSSI_MspInit(PSSI_HandleTypeDef *hpssi);
void HAL_PSSI_MspDeInit(PSSI_HandleTypeDef *hpssi);
/* Callbacks Register/UnRegister functions ***********************************/
HAL_StatusTypeDef HAL_PSSI_RegisterCallback(PSSI_HandleTypeDef *hpssi, HAL_PSSI_CallbackIDTypeDef CallbackID,
pPSSI_CallbackTypeDef pCallback);
HAL_StatusTypeDef HAL_PSSI_UnRegisterCallback(PSSI_HandleTypeDef *hpssi, HAL_PSSI_CallbackIDTypeDef CallbackID);
/**
* @}
*/
/** @addtogroup PSSI_Exported_Functions_Group2 Input and Output operation functions
* @{
*/
/* IO operation functions *******************************************************/
HAL_StatusTypeDef HAL_PSSI_Transmit(PSSI_HandleTypeDef *hpssi, uint8_t *pData, uint32_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_PSSI_Receive(PSSI_HandleTypeDef *hpssi, uint8_t *pData, uint32_t Size, uint32_t Timeout);
HAL_StatusTypeDef HAL_PSSI_Transmit_DMA(PSSI_HandleTypeDef *hpssi, uint32_t *pData, uint32_t Size);
HAL_StatusTypeDef HAL_PSSI_Receive_DMA(PSSI_HandleTypeDef *hpssi, uint32_t *pData, uint32_t Size);
HAL_StatusTypeDef HAL_PSSI_Abort_DMA(PSSI_HandleTypeDef *hpssi);
/**
* @}
*/
/** @addtogroup PSSI_Exported_Functions_Group3 Peripheral State and Error functions
* @{
*/
/* Peripheral State functions ***************************************************/
HAL_PSSI_StateTypeDef HAL_PSSI_GetState(PSSI_HandleTypeDef *hpssi);
uint32_t HAL_PSSI_GetError(PSSI_HandleTypeDef *hpssi);
/**
* @}
*/
/** @addtogroup PSSI_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
* @{
*/
void HAL_PSSI_IRQHandler(PSSI_HandleTypeDef *hpssi);
void HAL_PSSI_TxCpltCallback(PSSI_HandleTypeDef *hpssi);
void HAL_PSSI_RxCpltCallback(PSSI_HandleTypeDef *hpssi);
void HAL_PSSI_ErrorCallback(PSSI_HandleTypeDef *hpssi);
void HAL_PSSI_AbortCpltCallback(PSSI_HandleTypeDef *hpssi);
/**
* @}
*/
/**
* @}
*/
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/**
* @}
*/
#endif /* PSSI */
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H7xx_HAL_PSSI_H */
|