1
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3
File: oct6100_mask_interrupts.c
5
Copyright (c) 2001-2006 Octasic Inc.
9
This file contains the mask interrupts function.
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.
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
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.
25
$Octasic_Release: OCT612xAPI-01.00-PR43 $
27
$Octasic_Revision: 7 $
29
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
32
/***************************** INCLUDE FILES *******************************/
34
#include "oct6100api/oct6100_apimi.h"
35
#include "oct6100api/oct6100_apiud.h"
36
#include "oct6100api/oct6100_errors.h"
37
#include "oct6100api/oct6100_defines.h"
40
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
42
Function: Oct6100InterruptMask
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,
51
-------------------------------------------------------------------------------
52
| Argument | Description
53
-------------------------------------------------------------------------------
54
f_pInterruptMask Pointer to the interrupt masking structure.
56
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
57
UINT32 Oct6100InterruptMaskDef(
58
OUT tPOCT6100_INTERRUPT_MASK f_pInterruptMask )
60
f_pInterruptMask->ulUserChipIndex = cOCT6100_INVALID_VALUE;
61
f_pInterruptMask->pProcessContext = NULL;
64
return cOCT6100_ERR_OK;
67
UINT32 Oct6100InterruptMask(
68
IN tPOCT6100_INTERRUPT_MASK f_pInterruptMask )
70
tOCT6100_WRITE_PARAMS WriteParams;
71
tOCT6100_READ_PARAMS ReadParams;
75
/* Determine if the chip's interrupt pin is active.*/
76
ReadParams.ulReadAddress = 0x210;
77
ReadParams.pusReadData = &usReadData;
78
ReadParams.pProcessContext = f_pInterruptMask->pProcessContext;
80
ReadParams.ulUserChipId = f_pInterruptMask->ulUserChipIndex;
82
result = Oct6100UserDriverReadOs( &ReadParams );
83
if ( result != cOCT6100_ERR_OK )
84
return cOCT6100_ERR_INTRPTS_RW_ERROR;
86
if ( (usReadData & 0xFFFF) != 0 )
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;
94
/* Determine if the chip's interrupt pin is active. */
95
WriteParams.pProcessContext = f_pInterruptMask->pProcessContext;
97
WriteParams.ulUserChipId = f_pInterruptMask->ulUserChipIndex;
98
WriteParams.ulWriteAddress = 0x214;
99
WriteParams.usWriteData = (UINT16)( (usReadData & 0xC000) | 0x3FFF );
101
result = Oct6100UserDriverWriteOs( &WriteParams );
102
if ( result != cOCT6100_ERR_OK )
103
return cOCT6100_ERR_INTRPTS_RW_ERROR;
105
WriteParams.ulWriteAddress = 0x212;
106
WriteParams.usWriteData = 0x8000;
108
result = Oct6100UserDriverWriteOs( &WriteParams );
109
if ( result != cOCT6100_ERR_OK )
110
return cOCT6100_ERR_INTRPTS_RW_ERROR;
112
return cOCT6100_ERR_OK;
115
return cOCT6100_ERR_INTRPTS_NOT_ACTIVE;