this is testing

Committer:
pmallick
Date:
Thu Jan 14 19:12:57 2021 +0530
Revision:
0:e8a1ba50c46b
this is testing

Who changed what in which revision?

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