Platform drivers for Mbed.

Dependents:   EVAL-CN0535-FMCZ EVAL-CN0535-FMCZ EVAL-AD568x-AD569x EVAL-AD7606 ... more

Committer:
mahphalke
Date:
Fri Mar 19 12:10:16 2021 +0530
Revision:
16:61ad39564f45
Parent:
11:a2dcf0ebb5b5
Added uart changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mahesh Phalke 11:a2dcf0ebb5b5 1 /***************************************************************************//**
Mahesh Phalke 11:a2dcf0ebb5b5 2 * @file irq.h
Mahesh Phalke 11:a2dcf0ebb5b5 3 * @brief Header file of IRQ interface.
Mahesh Phalke 11:a2dcf0ebb5b5 4 * @author Cristian Pop (cristian.pop@analog.com)
Mahesh Phalke 11:a2dcf0ebb5b5 5 ********************************************************************************
Mahesh Phalke 11:a2dcf0ebb5b5 6 * Copyright 2019(c) Analog Devices, Inc.
Mahesh Phalke 11:a2dcf0ebb5b5 7 *
Mahesh Phalke 11:a2dcf0ebb5b5 8 * All rights reserved.
Mahesh Phalke 11:a2dcf0ebb5b5 9 *
Mahesh Phalke 11:a2dcf0ebb5b5 10 * Redistribution and use in source and binary forms, with or without
Mahesh Phalke 11:a2dcf0ebb5b5 11 * modification, are permitted provided that the following conditions are met:
Mahesh Phalke 11:a2dcf0ebb5b5 12 * - Redistributions of source code must retain the above copyright
Mahesh Phalke 11:a2dcf0ebb5b5 13 * notice, this list of conditions and the following disclaimer.
Mahesh Phalke 11:a2dcf0ebb5b5 14 * - Redistributions in binary form must reproduce the above copyright
Mahesh Phalke 11:a2dcf0ebb5b5 15 * notice, this list of conditions and the following disclaimer in
Mahesh Phalke 11:a2dcf0ebb5b5 16 * the documentation and/or other materials provided with the
Mahesh Phalke 11:a2dcf0ebb5b5 17 * distribution.
Mahesh Phalke 11:a2dcf0ebb5b5 18 * - Neither the name of Analog Devices, Inc. nor the names of its
Mahesh Phalke 11:a2dcf0ebb5b5 19 * contributors may be used to endorse or promote products derived
Mahesh Phalke 11:a2dcf0ebb5b5 20 * from this software without specific prior written permission.
Mahesh Phalke 11:a2dcf0ebb5b5 21 * - The use of this software may or may not infringe the patent rights
Mahesh Phalke 11:a2dcf0ebb5b5 22 * of one or more patent holders. This license does not release you
Mahesh Phalke 11:a2dcf0ebb5b5 23 * from the requirement that you obtain separate licenses from these
Mahesh Phalke 11:a2dcf0ebb5b5 24 * patent holders to use this software.
Mahesh Phalke 11:a2dcf0ebb5b5 25 * - Use of the software either in source or binary form, must be run
Mahesh Phalke 11:a2dcf0ebb5b5 26 * on or directly connected to an Analog Devices Inc. component.
Mahesh Phalke 11:a2dcf0ebb5b5 27 *
Mahesh Phalke 11:a2dcf0ebb5b5 28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
Mahesh Phalke 11:a2dcf0ebb5b5 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
Mahesh Phalke 11:a2dcf0ebb5b5 30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Mahesh Phalke 11:a2dcf0ebb5b5 31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
Mahesh Phalke 11:a2dcf0ebb5b5 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Mahesh Phalke 11:a2dcf0ebb5b5 33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
Mahesh Phalke 11:a2dcf0ebb5b5 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Mahesh Phalke 11:a2dcf0ebb5b5 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Mahesh Phalke 11:a2dcf0ebb5b5 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Mahesh Phalke 11:a2dcf0ebb5b5 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Mahesh Phalke 11:a2dcf0ebb5b5 38 *******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 39
Mahesh Phalke 11:a2dcf0ebb5b5 40 #ifndef IRQ_H_
Mahesh Phalke 11:a2dcf0ebb5b5 41 #define IRQ_H_
Mahesh Phalke 11:a2dcf0ebb5b5 42
Mahesh Phalke 11:a2dcf0ebb5b5 43 /******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 44 /***************************** Include Files **********************************/
Mahesh Phalke 11:a2dcf0ebb5b5 45 /******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 46
Mahesh Phalke 11:a2dcf0ebb5b5 47 #include <stdint.h>
Mahesh Phalke 11:a2dcf0ebb5b5 48
Mahesh Phalke 11:a2dcf0ebb5b5 49 /******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 50 /*************************** Types Declarations *******************************/
Mahesh Phalke 11:a2dcf0ebb5b5 51 /******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 52
Mahesh Phalke 11:a2dcf0ebb5b5 53 /**
Mahesh Phalke 11:a2dcf0ebb5b5 54 * @enum irq_uart_event_e
Mahesh Phalke 11:a2dcf0ebb5b5 55 * @brief Possible events for uart interrupt
Mahesh Phalke 11:a2dcf0ebb5b5 56 */
Mahesh Phalke 11:a2dcf0ebb5b5 57 enum irq_uart_event_e {
Mahesh Phalke 11:a2dcf0ebb5b5 58 /** Write operation finalized */
Mahesh Phalke 11:a2dcf0ebb5b5 59 WRITE_DONE,
Mahesh Phalke 11:a2dcf0ebb5b5 60 /** Read operation finalized */
Mahesh Phalke 11:a2dcf0ebb5b5 61 READ_DONE,
Mahesh Phalke 11:a2dcf0ebb5b5 62 /** An error occurred */
Mahesh Phalke 11:a2dcf0ebb5b5 63 ERROR_RW
Mahesh Phalke 11:a2dcf0ebb5b5 64 };
Mahesh Phalke 11:a2dcf0ebb5b5 65
Mahesh Phalke 11:a2dcf0ebb5b5 66 /**
Mahesh Phalke 11:a2dcf0ebb5b5 67 * @struct irq_init_param
Mahesh Phalke 11:a2dcf0ebb5b5 68 * @brief Structure holding the initial parameters for Interrupt Request.
Mahesh Phalke 11:a2dcf0ebb5b5 69 */
Mahesh Phalke 11:a2dcf0ebb5b5 70 struct irq_init_param {
Mahesh Phalke 11:a2dcf0ebb5b5 71 /** Interrupt request controller ID. */
Mahesh Phalke 11:a2dcf0ebb5b5 72 uint32_t irq_ctrl_id;
Mahesh Phalke 11:a2dcf0ebb5b5 73 /** IRQ extra parameters (device specific) */
Mahesh Phalke 11:a2dcf0ebb5b5 74 void *extra;
Mahesh Phalke 11:a2dcf0ebb5b5 75 };
Mahesh Phalke 11:a2dcf0ebb5b5 76
Mahesh Phalke 11:a2dcf0ebb5b5 77 /**
Mahesh Phalke 11:a2dcf0ebb5b5 78 * @struct irq_desc
Mahesh Phalke 11:a2dcf0ebb5b5 79 * @brief Structure for Interrupt Request descriptor.
Mahesh Phalke 11:a2dcf0ebb5b5 80 */
Mahesh Phalke 11:a2dcf0ebb5b5 81 struct irq_ctrl_desc {
Mahesh Phalke 11:a2dcf0ebb5b5 82 /** Interrupt request controller ID. */
Mahesh Phalke 11:a2dcf0ebb5b5 83 uint32_t irq_ctrl_id;
Mahesh Phalke 11:a2dcf0ebb5b5 84 /** IRQ extra parameters (device specific) */
Mahesh Phalke 11:a2dcf0ebb5b5 85 void *extra;
Mahesh Phalke 11:a2dcf0ebb5b5 86 };
Mahesh Phalke 11:a2dcf0ebb5b5 87
Mahesh Phalke 11:a2dcf0ebb5b5 88 /**
Mahesh Phalke 11:a2dcf0ebb5b5 89 * @struct callback_desc
Mahesh Phalke 11:a2dcf0ebb5b5 90 * @brief Structure describing a callback to be registered
Mahesh Phalke 11:a2dcf0ebb5b5 91 */
Mahesh Phalke 11:a2dcf0ebb5b5 92 struct callback_desc {
Mahesh Phalke 11:a2dcf0ebb5b5 93 /**
Mahesh Phalke 11:a2dcf0ebb5b5 94 * Callback to be called when the event an event occurs
Mahesh Phalke 11:a2dcf0ebb5b5 95 */
Mahesh Phalke 11:a2dcf0ebb5b5 96 void(*callback)(void);
Mahesh Phalke 11:a2dcf0ebb5b5 97 /** Parameter to be passed when the callback is called */
Mahesh Phalke 11:a2dcf0ebb5b5 98 void *ctx;
Mahesh Phalke 11:a2dcf0ebb5b5 99 /** Platform specific configuration for a callback */
Mahesh Phalke 11:a2dcf0ebb5b5 100 void *config;
Mahesh Phalke 11:a2dcf0ebb5b5 101 };
Mahesh Phalke 11:a2dcf0ebb5b5 102
Mahesh Phalke 11:a2dcf0ebb5b5 103 /******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 104 /************************ Functions Declarations ******************************/
Mahesh Phalke 11:a2dcf0ebb5b5 105 /******************************************************************************/
Mahesh Phalke 11:a2dcf0ebb5b5 106
Mahesh Phalke 11:a2dcf0ebb5b5 107 /* Initialize a interrupt controller peripheral. */
Mahesh Phalke 11:a2dcf0ebb5b5 108 int32_t irq_ctrl_init(struct irq_ctrl_desc **desc,
Mahesh Phalke 11:a2dcf0ebb5b5 109 const struct irq_init_param *param);
Mahesh Phalke 11:a2dcf0ebb5b5 110
Mahesh Phalke 11:a2dcf0ebb5b5 111 /* Free the resources allocated by irq_ctrl_init(). */
Mahesh Phalke 11:a2dcf0ebb5b5 112 int32_t irq_ctrl_remove(struct irq_ctrl_desc *desc);
Mahesh Phalke 11:a2dcf0ebb5b5 113
Mahesh Phalke 11:a2dcf0ebb5b5 114 /* Register a callback to handle the irq events */
Mahesh Phalke 11:a2dcf0ebb5b5 115 int32_t irq_register_callback(struct irq_ctrl_desc *desc,
Mahesh Phalke 11:a2dcf0ebb5b5 116 uint32_t irq_id,
Mahesh Phalke 11:a2dcf0ebb5b5 117 struct callback_desc *callback_desc);
Mahesh Phalke 11:a2dcf0ebb5b5 118
Mahesh Phalke 11:a2dcf0ebb5b5 119 /* Unregisters a generic IRQ handling function */
Mahesh Phalke 11:a2dcf0ebb5b5 120 int32_t irq_unregister(struct irq_ctrl_desc *desc, uint32_t irq_id);
Mahesh Phalke 11:a2dcf0ebb5b5 121
Mahesh Phalke 11:a2dcf0ebb5b5 122 /* Global interrupt enable */
Mahesh Phalke 11:a2dcf0ebb5b5 123 int32_t irq_global_enable(struct irq_ctrl_desc *desc);
Mahesh Phalke 11:a2dcf0ebb5b5 124
Mahesh Phalke 11:a2dcf0ebb5b5 125 /* Global interrupt disable */
Mahesh Phalke 11:a2dcf0ebb5b5 126 int32_t irq_global_disable(struct irq_ctrl_desc *desc);
Mahesh Phalke 11:a2dcf0ebb5b5 127
Mahesh Phalke 11:a2dcf0ebb5b5 128 /* Enable specific interrupt */
Mahesh Phalke 11:a2dcf0ebb5b5 129 int32_t irq_enable(struct irq_ctrl_desc *desc, uint32_t irq_id);
Mahesh Phalke 11:a2dcf0ebb5b5 130
Mahesh Phalke 11:a2dcf0ebb5b5 131 /* Disable specific interrupt */
Mahesh Phalke 11:a2dcf0ebb5b5 132 int32_t irq_disable(struct irq_ctrl_desc *desc, uint32_t irq_id);
Mahesh Phalke 11:a2dcf0ebb5b5 133
Mahesh Phalke 11:a2dcf0ebb5b5 134 #endif // IRQ_H_