class::hal::DeviceSignal

class hal::DeviceSignal
  : public sys::Signal

This class allows you to configure physical events to trigger signals. For example, a rising edge on a pin can cause the system to send a signal to a thread. Here is an example:

#include <sapi/sys.hpp>
#include <sapi/hal.hpp>

volatile bool my_var;
void my_handler(int a){
   //this executes on the rising edge of EINT0
   my_var = true;
   //you shouldn't use any non re-entrant functions here (such as printf() and malloc())

}

int main(int argc, char * argv[]){
   Eint eint(0);

   DeviceSignal dev_signal(true, Signal::USR1);  //send SIGUSR1 to this thread on every rising edge
   SignalHandler handler(my_handler);

   eint.init(0);
   event.set_handler(handler);

   //this configures the hardware to send the signal to this thread (my_handler() will execute)
   //dev_signal MUST exist as long as this action is set
   eint.set_action( dev_signal.create_action(EINT_ACTION_EVENT_RISING) );

   while(my_var == false){
      Timer::wait_sec(1);
   }

   return 0;
}

Members

DeviceSignal(

const arg::IsPersistent persistent,
enum sys::Signal::signal_number signo,
const arg::SignalValueInteger sigvalue,
const arg::SignalCode sigcode
)

DeviceSignal(

const arg::IsPersistent persistent,
enum sys::Signal::signal_number signo,
const arg::SignalValuePointer sigvalue,
const arg::SignalCode sigcode
)

DeviceSignal(

const devfs_signal_callback_t & context
)

mcu_action_t create_action(

const arg::Events event,
const arg::Channel channel,
const arg::InterruptPriority prio
) const

Details

DeviceSignal(

const arg::IsPersistent persistent,
enum sys::Signal::signal_number signo,
const arg::SignalValueInteger sigvalue,
const arg::SignalCode sigcode
)

Constructs a signal event based on a hardware device action.

Parameters

  • persistent If false, the signal will be sent only on the first hardware event

  • signo The signal number

  • sigcode The signal code

  • sigvalue The signal value


DeviceSignal(

const arg::IsPersistent persistent,
enum sys::Signal::signal_number signo,
const arg::SignalValuePointer sigvalue,
const arg::SignalCode sigcode
)

Constructs a signal event based on a hardware device action.

Parameters

  • persistent If false, the signal will be sent only on the first hardware event

  • signo The signal number

  • sigcode The signal code

  • sigptr The signal value as a pointer


DeviceSignal(

const devfs_signal_callback_t & context
)

Constructs a signal event based on a hardware device action using a signal_callback_t data structure.

Parameters

  • context A copy of the signal_callback_t data to use to handle the event.

mcu_action_t create_action(

const arg::Events event,
const arg::Channel channel,
const arg::InterruptPriority prio
) const

This returns a mcu_action_t data structure that can be used to set the action associated with a hardware event.

Parameters

  • event The hardware event

  • channel The hardware channel

Returns

a copy of a mcu_action_t data structure


X

Thanks for Coming!

Subscribe to news and updates