Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

112 lignes
3.1 KiB

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