1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2019 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 #ifndef _FSL_FLEXCOMM_H_
9 #define _FSL_FLEXCOMM_H_
10 
11 #include "fsl_common.h"
12 
13 /*!
14  * @addtogroup flexcomm_driver
15  * @{
16  */
17 
18 /*! @name Driver version */
19 /*@{*/
20 /*! @brief FlexCOMM driver version 2.0.2. */
21 #define FSL_FLEXCOMM_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
22 /*@}*/
23 
24 /*! @brief FLEXCOMM peripheral modes. */
25 typedef enum
26 {
27     FLEXCOMM_PERIPH_NONE,   /*!< No peripheral */
28     FLEXCOMM_PERIPH_USART,  /*!< USART peripheral */
29     FLEXCOMM_PERIPH_SPI,    /*!< SPI Peripheral */
30     FLEXCOMM_PERIPH_I2C,    /*!< I2C Peripheral */
31     FLEXCOMM_PERIPH_I2S_TX, /*!< I2S TX Peripheral */
32     FLEXCOMM_PERIPH_I2S_RX, /*!< I2S RX Peripheral */
33 } FLEXCOMM_PERIPH_T;
34 
35 /*! @brief Typedef for interrupt handler. */
36 typedef void (*flexcomm_irq_handler_t)(void *base, void *handle);
37 
38 /*! @brief Array with IRQ number for each FLEXCOMM module. */
39 extern IRQn_Type const kFlexcommIrqs[];
40 
41 /*******************************************************************************
42  * API
43  ******************************************************************************/
44 #if defined(__cplusplus)
45 extern "C" {
46 #endif
47 
48 /*! @brief Returns instance number for FLEXCOMM module with given base address. */
49 uint32_t FLEXCOMM_GetInstance(void *base);
50 
51 /*! @brief Initializes FLEXCOMM and selects peripheral mode according to the second parameter. */
52 status_t FLEXCOMM_Init(void *base, FLEXCOMM_PERIPH_T periph);
53 
54 /*! @brief Sets IRQ handler for given FLEXCOMM module. It is used by drivers register IRQ handler according to FLEXCOMM
55  * mode */
56 void FLEXCOMM_SetIRQHandler(void *base, flexcomm_irq_handler_t handler, void *flexcommHandle);
57 
58 #if defined(__cplusplus)
59 }
60 #endif
61 
62 /*@}*/
63 
64 #endif /* _FSL_FLEXCOMM_H_*/
65