removed interrupt class
This commit is contained in:
parent
6911f91744
commit
f604d621e8
@ -1,86 +0,0 @@
|
|||||||
#include "Interrupt.h"
|
|
||||||
extern "C" {
|
|
||||||
#include <bsp_flp/hw_timer/hw_timer.h>
|
|
||||||
#include <bsp_flp/hw_uart/hw_uart.h>
|
|
||||||
}
|
|
||||||
#include "RtemsBasic.h"
|
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t Interrupt::enableInterrupt(InterruptNumber_t interruptNumber) {
|
|
||||||
volatile uint32_t* irqMask = hw_irq_mask;
|
|
||||||
uint32_t expectedValue = *irqMask | (1 << interruptNumber);
|
|
||||||
*irqMask = expectedValue;
|
|
||||||
uint32_t tempValue = *irqMask;
|
|
||||||
if (tempValue == expectedValue) {
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
} else {
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Interrupt::setInterruptServiceRoutine(IsrHandler_t handler,
|
|
||||||
InterruptNumber_t interrupt, IsrHandler_t* oldHandler) {
|
|
||||||
IsrHandler_t oldHandler_local;
|
|
||||||
if (oldHandler == NULL) {
|
|
||||||
oldHandler = &oldHandler_local;
|
|
||||||
}
|
|
||||||
//+ 0x10 comes because of trap type assignment to IRQs in UT699 processor
|
|
||||||
rtems_status_code status = rtems_interrupt_catch(handler, interrupt + 0x10,
|
|
||||||
oldHandler);
|
|
||||||
switch(status){
|
|
||||||
case RTEMS_SUCCESSFUL:
|
|
||||||
//ISR established successfully
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
case RTEMS_INVALID_NUMBER:
|
|
||||||
//illegal vector number
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
case RTEMS_INVALID_ADDRESS:
|
|
||||||
//illegal ISR entry point or invalid old_isr_handler
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
default:
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Interrupt::disableInterrupt(InterruptNumber_t interruptNumber) {
|
|
||||||
//TODO Not implemented
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
//SHOULDDO: Make default values (edge, polarity) settable?
|
|
||||||
ReturnValue_t Interrupt::enableGpioInterrupt(InterruptNumber_t interrupt) {
|
|
||||||
volatile uint32_t* irqMask = hw_irq_mask;
|
|
||||||
uint32_t expectedValue = *irqMask | (1 << interrupt);
|
|
||||||
*irqMask = expectedValue;
|
|
||||||
uint32_t tempValue = *irqMask;
|
|
||||||
if (tempValue == expectedValue) {
|
|
||||||
volatile hw_gpio_port_t* ioPorts = hw_gpio_port;
|
|
||||||
ioPorts->direction &= ~(1 << interrupt); //Direction In
|
|
||||||
ioPorts->interrupt_edge |= 1 << interrupt; //Edge triggered
|
|
||||||
ioPorts->interrupt_polarity |= 1 << interrupt; //Trigger on rising edge
|
|
||||||
ioPorts->interrupt_mask |= 1 << interrupt; //Enable
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
} else {
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Interrupt::disableGpioInterrupt(InterruptNumber_t interrupt) {
|
|
||||||
volatile uint32_t* irqMask = hw_irq_mask;
|
|
||||||
uint32_t expectedValue = *irqMask & ~(1 << interrupt);
|
|
||||||
*irqMask = expectedValue;
|
|
||||||
uint32_t tempValue = *irqMask;
|
|
||||||
if (tempValue == expectedValue) {
|
|
||||||
//Disable gpio IRQ
|
|
||||||
volatile hw_gpio_port_t* ioPorts = hw_gpio_port;
|
|
||||||
ioPorts->interrupt_mask &= ~(1 << interrupt);
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
} else {
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Interrupt::isInterruptInProgress() {
|
|
||||||
return rtems_interrupt_is_in_progress();
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
#ifndef OS_RTEMS_INTERRUPT_H_
|
|
||||||
#define OS_RTEMS_INTERRUPT_H_
|
|
||||||
|
|
||||||
#include "../../returnvalues/HasReturnvaluesIF.h"
|
|
||||||
#include <cstring>
|
|
||||||
#include <rtems.h>
|
|
||||||
|
|
||||||
typedef rtems_isr_entry IsrHandler_t;
|
|
||||||
typedef rtems_isr IsrReturn_t;
|
|
||||||
typedef rtems_vector_number InterruptNumber_t;
|
|
||||||
|
|
||||||
class Interrupt {
|
|
||||||
public:
|
|
||||||
virtual ~Interrupt(){};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Establishes a new interrupt service routine.
|
|
||||||
* @param handler The service routine to establish
|
|
||||||
* @param interrupt The interrupt (NOT trap type) the routine shall react to.
|
|
||||||
* @return RETURN_OK on success. Otherwise, the OS failure code is returned.
|
|
||||||
*/
|
|
||||||
static ReturnValue_t setInterruptServiceRoutine(IsrHandler_t handler,
|
|
||||||
InterruptNumber_t interrupt, IsrHandler_t *oldHandler = NULL);
|
|
||||||
static ReturnValue_t enableInterrupt(InterruptNumber_t interruptNumber);
|
|
||||||
static ReturnValue_t disableInterrupt(InterruptNumber_t interruptNumber);
|
|
||||||
/**
|
|
||||||
* Enables the interrupt given.
|
|
||||||
* The function tests, if the InterruptMask register was written successfully.
|
|
||||||
* @param interrupt The interrupt to enable.
|
|
||||||
* @return RETURN_OK if the interrupt was set successfully. RETURN_FAILED else.
|
|
||||||
*/
|
|
||||||
static ReturnValue_t enableGpioInterrupt(InterruptNumber_t interrupt);
|
|
||||||
/**
|
|
||||||
* Disables the interrupt given.
|
|
||||||
* @param interrupt The interrupt to disable.
|
|
||||||
* @return RETURN_OK if the interrupt was set successfully. RETURN_FAILED else.
|
|
||||||
*/
|
|
||||||
static ReturnValue_t disableGpioInterrupt(InterruptNumber_t interrupt);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the current executing context is an ISR.
|
|
||||||
* @return true if handling an interrupt, false else.
|
|
||||||
*/
|
|
||||||
static bool isInterruptInProgress();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* OS_RTEMS_INTERRUPT_H_ */
|
|
Loading…
Reference in New Issue
Block a user