HAL PSSI How to Use ¶
- group PSSI_How_To_Use
-
How to use the PSSI HAL module driver ¶
The PSSI HAL driver can be used as follows:
-
Declare a hal_pssi_handle_t handle structure, for example: hal_pssi_handle_t hpssi;
-
Initialize the pssix driver with a PSSI HW instance by calling the HAL_PSSI_Init() . The pssix clock is enabled inside the HAL_PSSI_Init() if USE_HAL_PSSI_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO.
-
Configure the low level hardware (GPIO, CLOCK, NVIC…etc):
-
Enable the pssix interface clock if USE_HAL_PSSI_CLK_ENABLE_MODEL = HAL_CLK_ENABLE_NO
-
PSSI pins configuration
-
Enable the clock for the PSSI GPIOs
-
Configure PSSI pins as alternate function open-drain
-
-
NVIC configuration if you need to use interrupt process
-
Configure the pssix interrupt priority
-
Enable the NVIC PSSI IRQ Channel
-
-
DMA Configuration if you need to use DMA process
-
Declare hal_dma_handle_t handles structure for the transmit and receive
-
Enable the DMAx interface clock
-
Configure the DMA handle parameters
-
Configure the DMA Tx and Rx
-
Associate the initialized DMA handle to the hpssi DMA Tx and Rx handle respectively using HAL_PSSI_SetTxDMA() or HAL_PSSI_SetRxDMA()
-
Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx and Rx
-
-
-
Configure the Communication Bus Width, Control Signals, Input Polarity and Output Polarity by calling HAL_PSSI_SetConfig()
-
When using Ready signal in reception process, there might be a data shift in the user reception buffer as follows:
-
HAL_PSSI_BUS_WIDTH_8LINE : One Byte data shift
-
HAL_PSSI_BUS_WIDTH_16LINE : Two Bytes data shift
-
-
It’s recommended to use Data Enable signal to ensure synchronization between the controller and the target.
-
-
For PSSI IO operations, two operation modes are available within this driver :
-
Polling mode IO operation
-
Transmit an amount of data by byte in blocking mode using HAL_PSSI_Transmit()
-
Receive an amount of data by byte in blocking mode using HAL_PSSI_Receive()
-
-
DMA mode IO operation
-
Transmit an amount of data in non-blocking mode (DMA) using HAL_PSSI_Transmit_DMA()
-
At transmission end of transfer, HAL_PSSI_TxCpltCallback() is executed and user can add his own code by customizing the weak function HAL_PSSI_TxCpltCallback()
-
Receive an amount of data in non-blocking mode (DMA) using HAL_PSSI_Receive_DMA()
-
At reception end of transfer, HAL_PSSI_RxCpltCallback() is executed and user can add his own code by customizing the weak function HAL_PSSI_RxCpltCallback()
-
In case of transfer Error, HAL_PSSI_ErrorCallback() function is executed and user can add his own code by customizing the weak function HAL_PSSI_ErrorCallback()
-
Abort a PSSI process communication with Polling using HAL_PSSI_Abort()
-
Abort a PSSI process communication with Interrupt using HAL_PSSI_Abort_IT()
-
End of abort process, HAL_PSSI_AbortCpltCallback() is executed and user can add his own code by customizing the weak function HAL_PSSI_AbortCpltCallback()
-
-
-
Callback registration
-
When the compilation flag USE_HAL_PSSI_REGISTER_CALLBACKS is set to 1, User is allowed to dynamically configure the driver callbacks by providing function pointers to be used instead of the weak callback functions. Use the following callbacks registration APIs for this purpose:
-
HAL_PSSI_RegisterTxCpltCallback() for transmission end of transfer callback registration.
-
HAL_PSSI_RegisterRxCpltCallback() for reception end of transfer callback registration.
-
HAL_PSSI_RegisterErrorCallback() for error callback registration.
-
HAL_PSSI_RegisterAbortCpltCallback() for abort completion callback registration.
-
-
These functions take as parameters the HAL peripheral handle and a pointer to the user callback function.
-
When the compilation flag is set to 0 or not defined, the callback registration feature is not available and all callbacks are set to the corresponding weak functions.
-
-
Acquire/Release the HAL PSSI handle
-
When the compilation flag USE_HAL_MUTEX is set to 1, a multi-thread user application is allowed to acquire/take the whole PSSI HAL handle in order to execute a transmit or a receive process or a sequence of transmit receive. When the given process or sequence ends the user must release the PSSI HAL handle.
-
The HAL Acquire/Release are based on the HAL OS abstraction layer (stm32_hal_os.c/.h osal) :
-
HAL_PSSI_AcquireBus() Allows to acquire/take the HAL PSSI handle.
-
HAL_PSSI_ReleaseBus() Allows to release the HAL PSSI handle.
-
-
-