/*

 *            Copyright (c) 1998-2004 by NETsilicon Inc.

 *

 *  This software is copyrighted by and is the sole property of

 *  NETsilicon.  All rights, title, ownership, or other interests

 *  in the software remain the property of NETsilicon.  This

 *  software may only be used in accordance with the corresponding

 *  license agreement.  Any unauthorized use, duplication, transmission,

 *  distribution, or disclosure of this software is expressly forbidden.

 *

 *  This Copyright notice may not be removed or modified without prior

 *  written consent of NETsilicon.

 *

 *  NETsilicon, reserves the right to modify this software

 *  without notice.

 *

 *  NETsilicon

 *  411 Waverley Oaks Road                  USA 781.647.1234

 *  Suite 227                               http://www.netsilicon.com

 *  Waltham, MA 02452                       AmericaSales@netsilicon.com

 *

 */



#include <string.h>

#include <stdlib.h>

#include <errno.h>

#include <tx_port.h>

#include <semaphore.h>

#include <ddi.h>

#include <netosIo.h>

#include <reg_def.h>



#include <serParam.h>



#include "netos_spi.h"

#include <NA_ISR.h>

#include <Dma_def.h>

#include <sysClock.h>

#include <reg_def.h>

#include <bool.h>

#include <tx_api.h>

#include <ncc_init.h>

#include "spi_mod.h"



/**********************************************************************************

 **********************************************************************************

 ***                                                                            ***

 *** Function Name:  onspiISRforSel()                                           ***

 ***                                                                            ***

 *** Called by:                                                                 ***

 *** Function Calls: None                                                       ***

 ***                                                                            ***

 *** Comments: This routine handles  interrupts from SEL* signal .              ***

 **********************************************************************************

 **********************************************************************************/

void onspiISRforSel(ONSPI_CHAN * pChan)

{

    WORD32 reg;



    /*

     * We need to write 1 to the pChan->ISRbit, do not write 1 to the bits

     * Designated for the special functions and do not change the rest of bits

     */



    

    reg =  (*NARM_PORTC_ADDR) >> 24; /* Move special function to the right bits */

    reg = ~reg | pChan->ISRbit;    /* Mask out all special function bits and set ISRbit*/

    *NARM_PORTC_ADDR &= reg;



    if (pChan->IOinProgress)

    {

    	/* Release semaphore so WaitForCompletion could continue */

	    tx_semaphore_put (&((pChan->spi_int_sem)->sem));

    }

}

