~ubuntu-branches/ubuntu/quantal/zaptel/quantal

« back to all changes in this revision

Viewing changes to oct612x/octdeviceapi/oct6100api/oct6100_apimi/oct6100_mask_interrupts.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2006-10-24 22:41:01 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20061024224101-464p4n2jk16n1jrh
Tags: 1:1.2.10.dfsg-2
* bristuff-0.3.0-PRE-1v
* Remove redundant GPL LICENCE text

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
 
2
 
 
3
File:  oct6100_mask_interrupts.c
 
4
 
 
5
    Copyright (c) 2001-2006 Octasic Inc.
 
6
    
 
7
Description: 
 
8
 
 
9
        This file contains the mask interrupts function.
 
10
 
 
11
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
 
12
free software; you can redistribute it and/or modify it under the terms of 
 
13
the GNU General Public License as published by the Free Software Foundation; 
 
14
either version 2 of the License, or (at your option) any later version.
 
15
 
 
16
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
 
17
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 
18
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 
19
for more details. 
 
20
 
 
21
You should have received a copy of the GNU General Public License 
 
22
along with the OCT6100 GPL API; if not, write to the Free Software 
 
23
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
24
 
 
25
$Octasic_Release: OCT612xAPI-01.00-PR43 $
 
26
 
 
27
$Octasic_Revision: 7 $
 
28
 
 
29
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
 
30
 
 
31
 
 
32
/*****************************  INCLUDE FILES  *******************************/
 
33
 
 
34
#include "oct6100api/oct6100_apimi.h"
 
35
#include "oct6100api/oct6100_apiud.h"
 
36
#include "oct6100api/oct6100_errors.h"
 
37
#include "oct6100api/oct6100_defines.h"
 
38
 
 
39
 
 
40
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
 
41
 
 
42
Function:               Oct6100InterruptMask
 
43
 
 
44
Description:    The function is used to mask out the interrupt pin of the chip.  
 
45
                                This function is used when a deferred procedure call treats the 
 
46
                                interrupt (new interrupts must not be generated until the 
 
47
                                signaled interrupt is treated).  Which chip is to have its 
 
48
                                interrupts masked is determined by the mask structure, 
 
49
                                f_pInterruptMask.
 
50
 
 
51
-------------------------------------------------------------------------------
 
52
|       Argument                |       Description
 
53
-------------------------------------------------------------------------------
 
54
f_pInterruptMask                Pointer to the interrupt masking structure.
 
55
 
 
56
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
 
57
UINT32 Oct6100InterruptMaskDef(
 
58
                                OUT             tPOCT6100_INTERRUPT_MASK f_pInterruptMask )
 
59
{
 
60
        f_pInterruptMask->ulUserChipIndex = cOCT6100_INVALID_VALUE;
 
61
        f_pInterruptMask->pProcessContext = NULL;
 
62
 
 
63
 
 
64
        return cOCT6100_ERR_OK;
 
65
}
 
66
 
 
67
UINT32 Oct6100InterruptMask(
 
68
                                IN              tPOCT6100_INTERRUPT_MASK f_pInterruptMask )
 
69
{
 
70
        tOCT6100_WRITE_PARAMS   WriteParams;
 
71
        tOCT6100_READ_PARAMS    ReadParams;
 
72
        UINT32  result;
 
73
        UINT16  usReadData;
 
74
 
 
75
        /* Determine if the chip's interrupt pin is active.*/
 
76
        ReadParams.ulReadAddress = 0x210;
 
77
        ReadParams.pusReadData = &usReadData;
 
78
        ReadParams.pProcessContext = f_pInterruptMask->pProcessContext;
 
79
 
 
80
        ReadParams.ulUserChipId = f_pInterruptMask->ulUserChipIndex;
 
81
        
 
82
        result = Oct6100UserDriverReadOs( &ReadParams );
 
83
        if ( result != cOCT6100_ERR_OK ) 
 
84
                return cOCT6100_ERR_INTRPTS_RW_ERROR;
 
85
 
 
86
        if ( (usReadData & 0xFFFF) != 0 )
 
87
        {
 
88
                /* Chip's interrupt pin is active, so mask interrupt pin. */
 
89
                ReadParams.ulReadAddress = 0x214;
 
90
                result = Oct6100UserDriverReadOs( &ReadParams );
 
91
                if ( result != cOCT6100_ERR_OK ) 
 
92
                        return cOCT6100_ERR_INTRPTS_RW_ERROR;
 
93
 
 
94
                /* Determine if the chip's interrupt pin is active. */
 
95
                WriteParams.pProcessContext = f_pInterruptMask->pProcessContext;
 
96
 
 
97
                WriteParams.ulUserChipId = f_pInterruptMask->ulUserChipIndex;
 
98
                WriteParams.ulWriteAddress = 0x214;
 
99
                WriteParams.usWriteData = (UINT16)( (usReadData & 0xC000) | 0x3FFF );
 
100
        
 
101
                result = Oct6100UserDriverWriteOs( &WriteParams );
 
102
                if ( result != cOCT6100_ERR_OK ) 
 
103
                        return cOCT6100_ERR_INTRPTS_RW_ERROR;
 
104
 
 
105
                WriteParams.ulWriteAddress = 0x212;
 
106
                WriteParams.usWriteData = 0x8000;
 
107
        
 
108
                result = Oct6100UserDriverWriteOs( &WriteParams );
 
109
                if ( result != cOCT6100_ERR_OK ) 
 
110
                        return cOCT6100_ERR_INTRPTS_RW_ERROR;
 
111
                
 
112
                return cOCT6100_ERR_OK;
 
113
        }
 
114
        
 
115
        return cOCT6100_ERR_INTRPTS_NOT_ACTIVE;
 
116
}