fsl_lpspi_freertos.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2019 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef __FSL_LPSPI_FREERTOS_H__
  9. #define __FSL_LPSPI_FREERTOS_H__
  10. #include "FreeRTOS.h"
  11. #include "portable.h"
  12. #include "semphr.h"
  13. #include "fsl_lpspi.h"
  14. /*!
  15. * @addtogroup lpspi_freertos_driver LPSPI FreeRTOS Driver
  16. * @{
  17. */
  18. /**********************************************************************************************************************
  19. * Definitions
  20. *********************************************************************************************************************/
  21. /*! @name Driver version */
  22. /*@{*/
  23. /*! @brief LPSPI FreeRTOS driver version 2.0.5. */
  24. #define FSL_LPSPI_FREERTOS_DRIVER_VERSION (MAKE_VERSION(2, 0, 5))
  25. /*@}*/
  26. /*!
  27. * @cond RTOS_PRIVATE
  28. * @brief LPSPI FreeRTOS handle
  29. */
  30. typedef struct _lpspi_rtos_handle
  31. {
  32. LPSPI_Type *base; /*!< LPSPI base address */
  33. lpspi_master_handle_t drv_handle; /*!< Handle of the underlying driver, treated as opaque by the RTOS layer */
  34. status_t async_status;
  35. SemaphoreHandle_t mutex; /*!< Mutex to lock the handle during a trasfer */
  36. SemaphoreHandle_t event; /*!< Semaphore to notify and unblock task when transfer ends */
  37. } lpspi_rtos_handle_t;
  38. /*! \endcond */
  39. /**********************************************************************************************************************
  40. * API
  41. *********************************************************************************************************************/
  42. #if defined(__cplusplus)
  43. extern "C" {
  44. #endif
  45. /*!
  46. * @name LPSPI RTOS Operation
  47. * @{
  48. */
  49. /*!
  50. * @brief Initializes LPSPI.
  51. *
  52. * This function initializes the LPSPI module and related RTOS context.
  53. *
  54. * @param handle The RTOS LPSPI handle, the pointer to an allocated space for RTOS context.
  55. * @param base The pointer base address of the LPSPI instance to initialize.
  56. * @param masterConfig Configuration structure to set-up LPSPI in master mode.
  57. * @param srcClock_Hz Frequency of input clock of the LPSPI module.
  58. * @return status of the operation.
  59. */
  60. status_t LPSPI_RTOS_Init(lpspi_rtos_handle_t *handle,
  61. LPSPI_Type *base,
  62. const lpspi_master_config_t *masterConfig,
  63. uint32_t srcClock_Hz);
  64. /*!
  65. * @brief Deinitializes the LPSPI.
  66. *
  67. * This function deinitializes the LPSPI module and related RTOS context.
  68. *
  69. * @param handle The RTOS LPSPI handle.
  70. */
  71. status_t LPSPI_RTOS_Deinit(lpspi_rtos_handle_t *handle);
  72. /*!
  73. * @brief Performs SPI transfer.
  74. *
  75. * This function performs an SPI transfer according to data given in the transfer structure.
  76. *
  77. * @param handle The RTOS LPSPI handle.
  78. * @param transfer Structure specifying the transfer parameters.
  79. * @return status of the operation.
  80. */
  81. status_t LPSPI_RTOS_Transfer(lpspi_rtos_handle_t *handle, lpspi_transfer_t *transfer);
  82. /*!
  83. * @}
  84. */
  85. #if defined(__cplusplus)
  86. }
  87. #endif
  88. /*!
  89. * @}
  90. */
  91. #endif /* __FSL_LPSPI_FREERTOS_H__ */