OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [firmware/] [bsp/] [HAL/] [src/] [alt_iic.c] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 alfik
/******************************************************************************
2
*                                                                             *
3
* License Agreement                                                           *
4
*                                                                             *
5
* Copyright (c) 2009 Altera Corporation, San Jose, California, USA.           *
6
* All rights reserved.                                                        *
7
*                                                                             *
8
* Permission is hereby granted, free of charge, to any person obtaining a     *
9
* copy of this software and associated documentation files (the "Software"),  *
10
* to deal in the Software without restriction, including without limitation   *
11
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
12
* and/or sell copies of the Software, and to permit persons to whom the       *
13
* Software is furnished to do so, subject to the following conditions:        *
14
*                                                                             *
15
* The above copyright notice and this permission notice shall be included in  *
16
* all copies or substantial portions of the Software.                         *
17
*                                                                             *
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
22
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
23
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
24
* DEALINGS IN THE SOFTWARE.                                                   *
25
*                                                                             *
26
* This agreement shall be governed in all respects by the laws of the State   *
27
* of California and by the laws of the United States of America.              *
28
*                                                                             *
29
******************************************************************************/
30
#include "system.h"
31
 
32
/*
33
 * This file implements the HAL Enhanced interrupt API for Nios II processors
34
 * with an internal interrupt controller (IIC). For most routines, this serves
35
 * as a wrapper layer over the legacy interrupt API (which must be used with
36
 * the IIC only).
37
 *
38
 * Use of the enhanced API is recommended so that application and device
39
 * drivers are compatible with a Nios II system configured with an external
40
 * interrupt controller (EIC), or IIC. This will afford maximum portability.
41
 *
42
 * If an EIC is present, the EIC device driver must provide these routines,
43
 * because their operation will be specific to that EIC type.
44
 */
45
#ifndef NIOS2_EIC_PRESENT
46
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
47
 
48
#include "sys/alt_irq.h"
49
#include "priv/alt_iic_isr_register.h"
50
#include "priv/alt_legacy_irq.h"
51
 
52
/** @Function Description:  This function registers an interrupt handler.
53
  * If the function is succesful, then the requested interrupt will be enabled upon
54
  * return. Registering a NULL handler will disable the interrupt.
55
  * @API Type:              External
56
  * @param ic_id            Ignored.
57
  * @param irq              IRQ number
58
  * @return                 0 if successful, else error (-1)
59
  */
60
int alt_ic_isr_register(alt_u32 ic_id, alt_u32 irq, alt_isr_func isr,
61
  void *isr_context, void *flags)
62
{
63
    return alt_iic_isr_register(ic_id, irq, isr, isr_context, flags);
64
}
65
 
66
/** @Function Description:  This function enables a single interrupt.
67
  * @API Type:              External
68
  * @param ic_id            Ignored.
69
  * @param irq              IRQ number
70
  * @return                 0 if successful, else error (-1)
71
  */
72
int alt_ic_irq_enable (alt_u32 ic_id, alt_u32 irq)
73
{
74
    return alt_irq_enable(irq);
75
}
76
 
77
/** @Function Description:  This function disables a single interrupt.
78
  * @API Type:              External
79
  * @param ic_id            Ignored.
80
  * @param irq              IRQ number
81
  * @return                 0 if successful, else error (-1)
82
  */
83
int alt_ic_irq_disable(alt_u32 ic_id, alt_u32 irq)
84
{
85
    return alt_irq_disable(irq);
86
}
87
 
88
/** @Function Description:  This function to determine if corresponding
89
  *                         interrupt is enabled.
90
  * @API Type:              External
91
  * @param ic_id            Ignored.
92
  * @param irq              IRQ number
93
  * @return                 Zero if corresponding interrupt is disabled and
94
  *                         non-zero otherwise.
95
  */
96
alt_u32 alt_ic_irq_enabled(alt_u32 ic_id, alt_u32 irq)
97
{
98
    alt_u32 irq_enabled;
99
 
100
    NIOS2_READ_IENABLE(irq_enabled);
101
 
102
    return (irq_enabled & (1 << irq)) ? 1: 0;
103
}
104
 
105
#endif /* ALT_ENHANCED_INTERRUPT_API_PRESENT */
106
#endif /* NIOS2_EIC_PRESENT */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.