Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
tcUioIrq Class Reference

#include <UioIrq.h>

Collaboration diagram for tcUioIrq:

Public Member Functions

 tcUioIrq (std::string acName, std::string acUioPath=std::string())
 
virtual ~tcUioIrq ()
 
bool initialize ()
 
void close_fd ()
 
bool opened () const
 
std::string name ()
 
std::string path ()
 
int write_enable_irq ()
 
int waitForInterrupt (std::chrono::microseconds anTimeout)
 tcUioIrq::waitForInterrupt Wait for the Uio device to generate an interrupt More...
 
void set_irq_handler (std::function< void(int)> apIrqHandler)
 
bool enable_irq_monitor (bool abEnable)
 

Constructor & Destructor Documentation

◆ tcUioIrq()

tcUioIrq::tcUioIrq ( std::string  acName,
std::string  acUioPath = std::string() 
)

uio,irq helper class. Handles watching for interrupts Example device tree entry: pwm0: pwm@ff211000 { compatible = "uio,irq"; interrupts = <0 26 4>; }; // acName would be pwm // fpga interrupt would be 26

WARNING: The ram steamer uio node is currently controlled by PollingInterruptThread and is hardcoded to /dev/uio0. So its entry in the device tree needs to be first

Parameters
acName- Name of uio node. Will search /sys/class/uio/uio#/name for appropriate node if acUioPath is empty Note: Can be empty to allow class to be instantiated without parameters but will fail in initialize()
acUioPath- Optional, sets a fixed path to /dev/uio#

◆ ~tcUioIrq()

tcUioIrq::~tcUioIrq ( )
virtual

Member Function Documentation

◆ close_fd()

void tcUioIrq::close_fd ( )

Close file descriptor

◆ enable_irq_monitor()

bool tcUioIrq::enable_irq_monitor ( bool  abEnable)

Start thread to monitor for interrupts and call mpIrqHandler(int) when they occur When disabling thread, call will block until thread stops mpIrqHandler(int rv) - return value from waitForInterrupt()

Note: mpIrqHandler will be called from a seperate thread Note: set_irq_handler() must be called before enabling monitor thread

Parameters
abEnableStart or stop monitor thread
Returns
true if successful

◆ initialize()

bool tcUioIrq::initialize ( )

Initialize the uio file descriptor

Returns
true if successful

◆ name()

std::string tcUioIrq::name ( )
inline

◆ opened()

bool tcUioIrq::opened ( ) const

Return if file fd is open

Returns
true if opened

◆ path()

std::string tcUioIrq::path ( )
inline

◆ set_irq_handler()

void tcUioIrq::set_irq_handler ( std::function< void(int)>  apIrqHandler)
inline

◆ waitForInterrupt()

int tcUioIrq::waitForInterrupt ( std::chrono::microseconds  anTimeout)

tcUioIrq::waitForInterrupt Wait for the Uio device to generate an interrupt

Parameters
anTimeoutNumber of Microseconds to wait (0 = wait forever)
Returns
-1 on error (no UIO found), 0 on timeout, or number of pending interrupts since last check

◆ write_enable_irq()

int tcUioIrq::write_enable_irq ( )

Writes 1 to uio dev to enable irq

From uio-howto.html: For some hardware that has more than one interrupt source internally, but not separate IRQ mask and status registers, there might be situations where userspace cannot determine what the interrupt source was if the kernel handler disables them by writing to the chip’s IRQ register. In such a case, the kernel has to disable the IRQ completely to leave the chip’s register untouched. Now the userspace part can determine the cause of the interrupt, but it cannot re-enable interrupts. Another cornercase is chips where re-enabling interrupts is a read-modify-write operation to a combined IRQ status/acknowledge register. This would be racy if a new interrupt occurred simultaneously.

To address these problems, UIO also implements a write() function. It is normally not used and can be ignored for hardware that has only a single interrupt source or has separate IRQ mask and status registers. If you need it, however, a write to /dev/uioX will call the irqcontrol() function implemented by the driver. You have to write a 32-bit value that is usually either 0 or 1 to disable or enable interrupts. If a driver does not implement irqcontrol(), write() will return with -ENOSYS.

Returns
4 if success, -ENOSYS if not implemented

The documentation for this class was generated from the following files: