fsl_flexcomm.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_FLEXCOMM_H_
  35. #define _FSL_FLEXCOMM_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup flexcomm_driver
  39. * @{
  40. */
  41. /*! @name Driver version */
  42. /*@{*/
  43. /*! @brief FlexCOMM driver version 2.0.0. */
  44. #define FSL_FLEXCOMM_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
  45. /*@}*/
  46. /*! @brief FLEXCOMM peripheral modes. */
  47. typedef enum
  48. {
  49. FLEXCOMM_PERIPH_NONE, /*!< No peripheral */
  50. FLEXCOMM_PERIPH_USART, /*!< USART peripheral */
  51. FLEXCOMM_PERIPH_SPI, /*!< SPI Peripheral */
  52. FLEXCOMM_PERIPH_I2C, /*!< I2C Peripheral */
  53. FLEXCOMM_PERIPH_I2S_TX, /*!< I2S TX Peripheral */
  54. FLEXCOMM_PERIPH_I2S_RX, /*!< I2S RX Peripheral */
  55. } FLEXCOMM_PERIPH_T;
  56. /*! @brief Typedef for interrupt handler. */
  57. typedef void (*flexcomm_irq_handler_t)(void *base, void *handle);
  58. /*! @brief Array with IRQ number for each FLEXCOMM module. */
  59. extern IRQn_Type const kFlexcommIrqs[];
  60. /*! @brief Returns instance number for FLEXCOMM module with given base address. */
  61. uint32_t FLEXCOMM_GetInstance(void *base);
  62. /*! @brief Initializes FLEXCOMM and selects peripheral mode according to the second parameter. */
  63. status_t FLEXCOMM_Init(void *base, FLEXCOMM_PERIPH_T periph);
  64. /*! @brief Sets IRQ handler for given FLEXCOMM module. It is used by drivers register IRQ handler according to FLEXCOMM
  65. * mode */
  66. void FLEXCOMM_SetIRQHandler(void *base, flexcomm_irq_handler_t handler, void *handle);
  67. /*@}*/
  68. #endif /* _FSL_FLEXCOMM_H_*/