/**************************************************************************************************
---------------------------------------------------------------------------------------------------
	Copyright (c) 2007, Jonathan Bagg
	All rights reserved.

	 Redistribution and use in source and binary forms, with or without modification, are permitted 
	 provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of 
	  conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of 
	  conditions and the following disclaimer in the documentation and/or other materials provided 
	  with the distribution.
    * Neither the name of Jonathan Bagg nor the names of its contributors may be used to 
	  endorse or promote products derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------------------------------
   Project name : Infidigm AVR Drivers
   Processor	: ATMega64, ATMega128
   File name    : debounce.h
---------------------------------------------------------------------------------------------------
   Modifications: 

   Revision 1.0  2007/05/19 	Bagg
   - Cleaned up for release
   

---------------------------------------------------------------------------------------------------
   Created      : 12 May 2007     	           Author(s) : Jonathan Bagg
---------------------------------------------------------------------------------------------------
   Input Debounce Filter
---------------------------------------------------------------------------------------------------
**************************************************************************************************/

/**************************************************************************************************
*   List of ports to Scan to Debounce / filter
**************************************************************************************************/
enum {
	//IN_PINA,
	IN_PINB,
	//IN_PINC,
	IN_PIND,
	//IN_PINE,
	//IN_PINF,
	//IN_PING,
	IN_SIZE
};

/**************************************************************************************************
*
*   Function          : setup_debounce
*
*   Description       : Sets up the debounce filter. See "Input Debounce variable set" for detail 
*						about how to control the filter.  As a minimum, a pointer to the port to 
*						read must be assigned if it is uncommented in the enum list above.
*
*   Parameters        : None
*
*   Functions Called  : None
*
*   Returns           : None
*
**************************************************************************************************/
void setup_debounce(void);

/**************************************************************************************************
*
*   Function          : update_debounce
*
*   Description       : Services / Runs the debounce filter. Call as often as possible.
*
*   Parameters        : None
*
*   Functions Called  : read_systimer()
*
*   Returns           : None
*
**************************************************************************************************/
void update_debounce(void);

/**************************************************************************************************
*
*   Function          : read_debounce
*
*   Description       : Reads the output of the debounce filter.  Use a Port ID that is listed in
*						the above enum port list.
*
*   Parameters        : Port ID, pin number
*
*   Functions Called  : None
*
*   Returns           : Logic level of the Port pin
*
*	Example				if (read_debounce(IN_PORTB, PB7);
*
**************************************************************************************************/
unsigned char read_debounce(unsigned char id, unsigned char pin);
