2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2012-12-12 17:39:53 -04:00
|
|
|
#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2)
|
2012-08-27 15:45:42 -03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <avr/interrupt.h>
|
|
|
|
|
|
|
|
#include "ISRRegistry.h"
|
|
|
|
|
|
|
|
using namespace AP_HAL_AVR;
|
|
|
|
|
2012-09-07 15:42:51 -03:00
|
|
|
AP_HAL::Proc ISRRegistry::_registry[ISR_REGISTRY_NUM_SLOTS] = {NULL};
|
2012-08-27 15:45:42 -03:00
|
|
|
|
2012-09-07 15:42:51 -03:00
|
|
|
int ISRRegistry::register_signal(int signal, AP_HAL::Proc proc)
|
2012-08-27 15:45:42 -03:00
|
|
|
{
|
|
|
|
if (signal >= 0 && signal < ISR_REGISTRY_NUM_SLOTS) {
|
|
|
|
_registry[signal] = proc;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ISRRegistry::unregister_signal(int signal)
|
|
|
|
{
|
|
|
|
if (signal >= 0 && signal < ISR_REGISTRY_NUM_SLOTS) {
|
|
|
|
_registry[signal] = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========== ISR IMPLEMENTATIONS ========== */
|
|
|
|
|
|
|
|
extern "C" ISR(TIMER2_OVF_vect) {
|
|
|
|
if ( ISRRegistry::_registry[ISR_REGISTRY_TIMER2_OVF] != NULL)
|
|
|
|
ISRRegistry::_registry[ISR_REGISTRY_TIMER2_OVF]();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" ISR(TIMER4_CAPT_vect) {
|
|
|
|
if ( ISRRegistry::_registry[ISR_REGISTRY_TIMER4_CAPT] != NULL)
|
|
|
|
ISRRegistry::_registry[ISR_REGISTRY_TIMER4_CAPT]();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" ISR(TIMER5_CAPT_vect) {
|
|
|
|
if ( ISRRegistry::_registry[ISR_REGISTRY_TIMER5_CAPT] != NULL)
|
|
|
|
ISRRegistry::_registry[ISR_REGISTRY_TIMER5_CAPT]();
|
|
|
|
}
|
|
|
|
|
2012-12-12 17:39:53 -04:00
|
|
|
#endif
|