Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:00

0001 /*
0002  * Copyright (c) 2015, Freescale Semiconductor, Inc.
0003  * Copyright 2016-2022 NXP
0004  * All rights reserved.
0005  *
0006  * SPDX-License-Identifier: BSD-3-Clause
0007  */
0008 #ifndef __FSL_LPSPI_FREERTOS_H__
0009 #define __FSL_LPSPI_FREERTOS_H__
0010 
0011 #include "FreeRTOS.h"
0012 #include "portable.h"
0013 #include "semphr.h"
0014 
0015 #include "fsl_lpspi.h"
0016 
0017 /*!
0018  * @addtogroup lpspi_freertos_driver LPSPI FreeRTOS Driver
0019  * @{
0020  */
0021 
0022 /**********************************************************************************************************************
0023  * Definitions
0024  *********************************************************************************************************************/
0025 
0026 /*! @name Driver version */
0027 /*@{*/
0028 /*! @brief LPSPI FreeRTOS driver version 2.3.1. */
0029 #define FSL_LPSPI_FREERTOS_DRIVER_VERSION (MAKE_VERSION(2, 3, 1))
0030 /*@}*/
0031 
0032 /*!
0033  * @cond RTOS_PRIVATE
0034  * @brief LPSPI FreeRTOS handle
0035  */
0036 typedef struct _lpspi_rtos_handle
0037 {
0038     LPSPI_Type *base;                 /*!< LPSPI base address */
0039     lpspi_master_handle_t drv_handle; /*!< Handle of the underlying driver, treated as opaque by the RTOS layer */
0040     status_t async_status;
0041     SemaphoreHandle_t mutex; /*!< Mutex to lock the handle during a trasfer */
0042     SemaphoreHandle_t event; /*!< Semaphore to notify and unblock task when transfer ends */
0043 } lpspi_rtos_handle_t;
0044 /*! \endcond */
0045 
0046 /**********************************************************************************************************************
0047  * API
0048  *********************************************************************************************************************/
0049 
0050 #if defined(__cplusplus)
0051 extern "C" {
0052 #endif
0053 
0054 /*!
0055  * @name LPSPI RTOS Operation
0056  * @{
0057  */
0058 
0059 /*!
0060  * @brief Initializes LPSPI.
0061  *
0062  * This function initializes the LPSPI module and related RTOS context.
0063  *
0064  * @param handle The RTOS LPSPI handle, the pointer to an allocated space for RTOS context.
0065  * @param base The pointer base address of the LPSPI instance to initialize.
0066  * @param masterConfig Configuration structure to set-up LPSPI in master mode.
0067  * @param srcClock_Hz Frequency of input clock of the LPSPI module.
0068  * @return status of the operation.
0069  */
0070 status_t LPSPI_RTOS_Init(lpspi_rtos_handle_t *handle,
0071                          LPSPI_Type *base,
0072                          const lpspi_master_config_t *masterConfig,
0073                          uint32_t srcClock_Hz);
0074 
0075 /*!
0076  * @brief Deinitializes the LPSPI.
0077  *
0078  * This function deinitializes the LPSPI module and related RTOS context.
0079  *
0080  * @param handle The RTOS LPSPI handle.
0081  */
0082 status_t LPSPI_RTOS_Deinit(lpspi_rtos_handle_t *handle);
0083 
0084 /*!
0085  * @brief Performs SPI transfer.
0086  *
0087  * This function performs an SPI transfer according to data given in the transfer structure.
0088  *
0089  * @param handle The RTOS LPSPI handle.
0090  * @param transfer Structure specifying the transfer parameters.
0091  * @return status of the operation.
0092  */
0093 status_t LPSPI_RTOS_Transfer(lpspi_rtos_handle_t *handle, lpspi_transfer_t *transfer);
0094 
0095 /*!
0096  * @}
0097  */
0098 
0099 #if defined(__cplusplus)
0100 }
0101 #endif
0102 
0103 /*!
0104  * @}
0105  */
0106 
0107 #endif /* __FSL_LPSPI_FREERTOS_H__ */