/*
 * handlers.c
 *
 *  Created on: Dec 27, 2011
 *      Author: RomanM
 */

#include "stm32f10x.h"

#include "drivers/RTC/RTC.h"
#include "drivers/Mfrc530/Mfrc530.h"
#include "drivers/Periph/UART/UART.h"
#include "drivers/Periph/ADC/ADC.h"
#include "uIP/app/uip-app.h"

/*
 * MFRC530 interrupt handler
 */
void EXTI0_IRQHandler(void) {
	if (EXTI_GetITStatus(EXTI_Line0) != RESET) {
		Mfrc530_InterruptHandler();
		EXTI_ClearITPendingBit(EXTI_Line0);
	}
}

/*
 * ENC424J600 interrupt handler
 */
void EXTI3_IRQHandler(void) {
	if (EXTI_GetITStatus(EXTI_Line3) != RESET) {
		EXTI_ClearITPendingBit(EXTI_Line3);
	}
}

/*
 * RTC interrupt handler (1s)
 */
void RTC_IRQHandler(void) {
	if (RTC_GetITStatus(RTC_IT_SEC) != RESET) {
		RTC_InterruptHandler();
		RTC_ClearITPendingBit(RTC_IT_SEC);
	}
}

/*
 * USART interrupt handler
 */
void USART1_IRQHandler(void) {
	if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) {
		UART_InHandler();
		USART_ClearITPendingBit(USART1, USART_IT_RXNE);
	}
}

/*
 * ADC interrupt handler
 */
void ADC1_IRQHandler(void) {
	if (ADC_GetITStatus(ADC1, ADC_IT_EOC) != RESET) {
		ADC1_InterruptHandler();
		ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
	}
}

/*
 * SysTick interrupt handler
 */
void SysTick_Handler(void) {
	clock_handler();
}
