PDEC Config Persistent #398
@ -164,13 +164,8 @@ ReturnValue_t PdecHandler::polledOperation() {
|
|||||||
|
|
||||||
// See https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html for more information.
|
// See https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html for more information.
|
||||||
ReturnValue_t PdecHandler::irqOperation() {
|
ReturnValue_t PdecHandler::irqOperation() {
|
||||||
int fd = open(uioNames.irq, O_RDWR);
|
ReturnValue_t result = returnvalue::OK;
|
||||||
if (fd < 0) {
|
int fd = -1;
|
||||||
sif::error << "PdecHandler::irqOperation: Opening UIO IRQ file" << uioNames.irq << " failed"
|
|
||||||
<< std::endl;
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to unmask IRQ
|
// Used to unmask IRQ
|
||||||
uint32_t info = 1;
|
uint32_t info = 1;
|
||||||
|
|
||||||
@ -186,11 +181,14 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
readCommandQueue();
|
readCommandQueue();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case State::INIT: {
|
case State::INIT: {
|
||||||
handleInitState();
|
result = handleInitState();
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
openIrqFile(&fd);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case State::PDEC_RESET: {
|
case State::PDEC_RESET: {
|
||||||
ReturnValue_t result = pdecToReset();
|
result = pdecToReset();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
triggerEvent(PDEC_RESET_FAILED);
|
triggerEvent(PDEC_RESET_FAILED);
|
||||||
}
|
}
|
||||||
@ -217,7 +215,7 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdecHandler::handleInitState() {
|
ReturnValue_t PdecHandler::handleInitState() {
|
||||||
ReturnValue_t result = firstLoop();
|
ReturnValue_t result = firstLoop();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
if (result == LocalParameterHandler::SD_NOT_READY) {
|
if (result == LocalParameterHandler::SD_NOT_READY) {
|
||||||
@ -227,15 +225,26 @@ void PdecHandler::handleInitState() {
|
|||||||
"becomes ready"
|
"becomes ready"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
state = State::WAIT_FOR_RECOVERY;
|
state = State::WAIT_FOR_RECOVERY;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
state = State::INIT;
|
state = State::INIT;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
state = State::WAIT_FOR_RECOVERY;
|
state = State::WAIT_FOR_RECOVERY;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
state = State::RUNNING;
|
state = State::RUNNING;
|
||||||
|
return returnvalue::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PdecHandler::openIrqFile(int* fd) {
|
||||||
|
*fd = open(uioNames.irq, O_RDWR);
|
||||||
|
if (*fd < 0) {
|
||||||
|
sif::error << "PdecHandler::irqOperation: Opening UIO IRQ file" << uioNames.irq << " failed"
|
||||||
|
<< std::endl;
|
||||||
|
triggerEvent(OPEN_IRQ_FILE_FAILED);
|
||||||
|
state = State::WAIT_FOR_RECOVERY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) {
|
ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) {
|
||||||
|
@ -101,9 +101,12 @@ class PdecHandler : public SystemObject,
|
|||||||
static constexpr Event POLL_SYSCALL_ERROR_PDEC =
|
static constexpr Event POLL_SYSCALL_ERROR_PDEC =
|
||||||
event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
||||||
static constexpr Event WRITE_SYSCALL_ERROR_PDEC =
|
static constexpr Event WRITE_SYSCALL_ERROR_PDEC =
|
||||||
event::makeEvent(SUBSYSTEM_ID, 9, severity::MEDIUM);
|
event::makeEvent(SUBSYSTEM_ID, 9, severity::HIGH);
|
||||||
//! [EXPORT] : [COMMENT] Failed to pull PDEC reset to low
|
//! [EXPORT] : [COMMENT] Failed to pull PDEC reset to low
|
||||||
static constexpr Event PDEC_RESET_FAILED = event::makeEvent(SUBSYSTEM_ID, 10, severity::HIGH);
|
static constexpr Event PDEC_RESET_FAILED = event::makeEvent(SUBSYSTEM_ID, 10, severity::HIGH);
|
||||||
|
//! [EXPORT] : [COMMENT] Failed to open the IRQ uio file
|
||||||
|
static constexpr Event OPEN_IRQ_FILE_FAILED =
|
||||||
|
event::makeEvent(SUBSYSTEM_ID, 11, severity::HIGH);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
||||||
@ -279,7 +282,8 @@ class PdecHandler : public SystemObject,
|
|||||||
|
|
||||||
ReturnValue_t polledOperation();
|
ReturnValue_t polledOperation();
|
||||||
ReturnValue_t irqOperation();
|
ReturnValue_t irqOperation();
|
||||||
void handleInitState();
|
ReturnValue_t handleInitState();
|
||||||
|
void openIrqFile(int* fd);
|
||||||
ReturnValue_t checkAndHandleIrqs(int fd, uint32_t& info);
|
ReturnValue_t checkAndHandleIrqs(int fd, uint32_t& info);
|
||||||
|
|
||||||
uint32_t readFar();
|
uint32_t readFar();
|
||||||
|
Loading…
Reference in New Issue
Block a user