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

 ZG2100 Driver Access Header file to the Hardware abstraction layer.
 Module for Microchip TCP/IP Stack

*******************************************************************************
 FileName:		ZGDriverAccessHal.h
 Dependencies:	TCP/IP Stack header files
 Processor:		PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32
 Compiler:		Microchip C32 v1.10b or higher
				Microchip C30 v3.22 or higher
				Microchip C18 v3.34 or higher
 Company:		Microchip Technology, Inc.

 Software License Agreement

 Copyright (C) 2002-2010 Microchip Technology Inc.  All rights reserved.

 Microchip licenses to you the right to use, modify, copy, and distribute:
 (i)  the Software when embedded on a Microchip microcontroller or digital 
      signal controller product ("Device") which is integrated into 
      Licensee's product; or
 (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h,
      ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device used in 
	  conjunction with a Microchip ethernet controller for the sole purpose 
	  of interfacing with the ethernet controller.

 You should refer to the license agreement accompanying this Software for 
 additional information regarding your rights and obligations.

 THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR ANY INCIDENTAL,
 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST
 OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS BY
 THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS
 FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON
 THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR
 OTHERWISE.


 Author				Date		Comment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Zero G				Sep 2008	Initial version
 KO					31 Oct 2008	Port to PIC24F and PIC32 for TCP/IP stack v4.52
******************************************************************************/
#ifndef _ZGDRIVERACCESSHAL_H_
#define _ZGDRIVERACCESSHAL_H_

#include "TCPIP Stack/ZGAccessHal.h"

/* zgHALSpiInit - used by the ZG Driver to initialize the
 * SPI driver. */
tZGVoidReturn zgHALSpiInit(tZGVoidInput);

/* zgHALSpiTxRx - used by the ZG Driver to initiate/continue an
 * SPI operation Tx or Rx as dictated by the SPI context */
tZGBool zgHALSpiTxRx(tZGVoidInput);

/* zgHALSpiProcess - used by the ZG Driver to allow the SPI
 *  driver to operate in polled mode. If the driver is not
 *  a polled driver then this macro can be left blank. */
#define ZGHAL_SPI_PROCESS()

/* zgHALEintEnable - used by the ZG Driver to enable the external
 * interrupt service from the Zero G device. */
tZGVoidReturn zgHALEintEnable(tZGVoidInput);

/* zgHALEintDisable - used by the ZG Driver to disable the external
 * interrupt service from the Zero G Device. */
tZGVoidReturn zgHALEintDisable(tZGVoidInput);

/* zgHALEintInit - used by the ZG Driver to initialize the the
 * external Interrupt service. */
tZGVoidReturn zgHALEintInit(tZGVoidInput);

/* zgHalIsEinitDisabled - used by the ZG Driver to test for whether */
/* external interrupts are disabled */
tZGBool zgHalIsEintDisabled(tZGVoidInput);

/* zgHalIsEinitPending - used by the ZG Driver to test for whether */
/* external interrupts are pending.  The pending case is not something */
/* that should normally happen.  It says we have the interrupt line */
/* asserted but the ZG_EINT_IF bit is not set, thus, no interrupt generated */
tZGBool zgHalIsEintPending(tZGVoidInput);

/* zgHALEintProcess - used by the ZG Driver to allow the Eint
 *  driver to operate in polled mode.  If the driver is not
 *  a polled driver then this macro can be left blank. */
#define ZGHAL_EINT_PROCESS()



/*****************************************************************************/
/* ZGHAL_SPI_... macros used by the ZG Driver to access the spi driver
 *  context */
/*****************************************************************************/

/* ZGHAL_SPI_CONTEXT_SET_TX_PRE_BUF_PTR - used by the ZG Driver to add a
 * transmit Pre-buffer pointer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGDataPtr ) */
#define ZGHAL_SPI_CONTEXT_SET_TX_PRE_BUF_PTR(pTxPreambleBuffer) SpiSetTxPreBufPtr(pTxPreambleBuffer)

/* ZGHAL_SPI_CONTEXT_SET_TX_PRE_LEN - used by the ZG Driver to specify
 * length of a transmit pre-buffer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGU8 ) */
#define ZGHAL_SPI_CONTEXT_SET_TX_PRE_LEN(txPreambleLength) SpiSetTxPreLen(txPreambleLength)

/* ZGHAL_SPI_CONTEXT_SET_TX_BUF_PTR - used by the ZG Driver to add a
 * transmit main buffer pointer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGDataPtr ) */
#define ZGHAL_SPI_CONTEXT_SET_TX_BUF_PTR(pTxBuffer) SpiSetTxBufPtr(pTxBuffer)

/* ZGHAL_SPI_CONTEXT_SET_TX_ROM_BUF_PTR - used by the ZG Driver to add a
 * ROM transmit main buffer pointer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(ROM tZGDataPtr ) */
#define ZGHAL_SPI_CONTEXT_SET_TX_ROM_BUF_PTR(pTxBuffer) SpiSetTxRomBufPtr(pTxBuffer)

/* ZGHAL_SPI_CONTEXT_SET_TX_LEN - used by the ZG Driver to specify
 * length of a transmit main buffer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGU16 ) */
#define ZGHAL_SPI_CONTEXT_SET_TX_LEN(txLength) SpiSetTxBufLen(txLength)

/* ZGHAL_SPI_CONTEXT_SET_RX_PRE_BUF_PTR - used by the ZG Driver to add a
 * receive pre-buffer pointer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGDataPtr ) */
#define ZGHAL_SPI_CONTEXT_SET_RX_PRE_BUF_PTR(pRxPreambleBuffer) SpiSetRxPreBufPtr(pRxPreambleBuffer)

/* ZGHAL_SPI_CONTEXT_SET_RX_PRE_LEN - used by the ZG Driver to specify
 * how many bytes to read from the SPI to the pre-buffer. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGU8 ) */
#define ZGHAL_SPI_CONTEXT_SET_RX_PRE_LEN(rxPreambleLength) SpiSetRxPreBufLen(rxPreambleLength)

/* ZGHAL_SPI_CONTEXT_SET_RX_BUF_PTR - used by the ZG Driver to add a
 * receive main buffer pointer to the SPI context. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGDataPtr ) */
#define ZGHAL_SPI_CONTEXT_SET_RX_BUF_PTR(pRxBuffer) SpiSetRxBufPtr(pRxBuffer)

/* ZGHAL_SPI_CONTEXT_SET_RX_LEN - used by the ZG Driver to specify
 * how many bytes to read from the SPI to the main buffer. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGU16 ) */
#define ZGHAL_SPI_CONTEXT_SET_RX_LEN(rxLength) SpiSetRxBufLen(rxLength)

/* ZGHAL_SPI_CONTEXT_SET_RX_EXCESS_LEN - used by the ZG Driver to
 * specify the extra length of the rx buffer beyond the
 * desired read length. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGDataPtr ) */
#define ZGHAL_SPI_CONTEXT_SET_RX_EXCESS_LEN(excessRxLength) SpiSetRxExcessLen(excessRxLength)

/* ZGHAL_SPI_CONTEXT_SET_SUPPRESS_DONE_HANDLER_CALL - used by the ZG Driver to set a
 * boolean in the SPI context to direct the SPI driver to suppress the done handler call. */
/* DEFINITION - tZGVoidReturn FunctionName(tZGBool ) */
#define ZGHAL_SPI_CONTEXT_SET_SUPPRESS_DONE_HANDLER_CALL(suppressDoneHandlerCall) SpiSetSuppressDoneHandlerCall(suppressDoneHandlerCall)

/* ZGHAL_ZG100_HW_RESET_CALL - used by the ZG Driver to perform a hardware reset of the ZG2100 device.
 * */
/* DEFINITION - tZGBool FunctionName(tZGVoidInput ) */
#define ZGHAL_ZG100_HW_RESET_CALL() MCHPHardwareResetZG2100()

#endif /*_ZGDRIVERACCESSHAL_H_ */
