#include "interrupt.h"

unsigned char IntHandler::IRQ = 5;
RTKSemaphore  IntHandler::sem = 0;

IntHandler::IntHandler( unsigned char IRQ , RTKSemaphore &sem) {
	this->IRQ = IRQ;
	this->sem = sem;
	RTKSetIRQHandler(IRQ, IntHandler::handleInt);
	RTKEnableIRQ(IRQ);
}

IntHandler::~IntHandler() {
	RTKDisableIRQ(IRQ);
}

void RTKAPI IntHandler::handleInt(void) {
	RTKEnableInterrupts();
	RTKSignal( sem );
	RTKIRQEnd( IRQ );
}