// ----------------------------------------------------------------------------------------
//
//  avr/device/int_helpers.cpp
//    
//  Bob Cook Development, Robotics Library
//  http://www.bobcookdev.com/rl/
//    
//  This file provides support routines for dealing with interrupts.
//
//  Copyright (C) 2008 Bob Cook
//
//      This program is free software; you can redistribute it and/or modify it
//      under the terms of the GNU General Public License as published by the
//      Free Software Foundation; either version 2 of the License, or (at your
//      option) any later version.
//    
//      This program is distributed in the hope that it will be useful, but 
//      WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
//      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
//      for more details.
//    
//      You should have received a copy of the GNU General Public License along
//      with this program; if not, write to the Free Software Foundation, Inc., 
//      51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// ----------------------------------------------------------------------------------------


#include "int_helpers.h"

#include "project_defs.h"


// ----------------------------------------------------------------------------------------
  
void interrupts_clear_all()
{

#if defined( __AVR_ATmega8__ )

    TIMSK = 0;
    GICR &= ~( ( 1 << INT1 ) | ( 1 << INT0 ) );

#elif defined( __AVR_ATmega16__ )

    TMSK = 0;
    GICR &= ~( ( 1 << INT1 ) | ( 1 << INT0 ) | ( 1 << INT2 ) );

#elif defined( __AVR_ATmega88__ ) || defined( __AVR_ATmega168__ )

    TIMSK0 = 0;
    TIMSK1 = 0;
    TIMSK2 = 0;

    EIMSK = 0;

    PCICR  = 0;
    PCMSK0 = 0;
    PCMSK1 = 0;
    PCMSK2 = 0;

#elif defined( __AVR_ATmega128__ )

    TIMSK  = 0;
    ETIMSK = 0;

#else
#error Unsupported Hardware
#endif

}


// ----------------------------------------------------------------------------------------
//  end of int_helpers.cpp
// ----------------------------------------------------------------------------------------

