upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
A110X Class Reference

API for the A110X Hall Effect sensors. More...

Detailed Description

UPM module for the A110X (A1101, A1102, A1103, A1104, and A1106) Hall Effect sensors. It outputs a digital signal indicating whether it is detecting a magnetic field with south polarity perpendicular to the sensor element.


An example showing a simple test for the presence of a field

// Instantiate an A110X sensor on digital pin D2
upm::A110X* hall = new upm::A110X(2);
// check every second for the presence of a magnetic field (south
// polarity)
while (shouldRun)
bool val = hall->magnetDetected();
if (val)
cout << "Magnet (south polarity) detected." << endl;
cout << "No magnet detected." << endl;

An example demonstrating the use of an interrupt handler to count pulses

// Instantiate an A110X sensor on digital pin D2
upm::A110X* hall = new upm::A110X(2);
// This example uses a user-supplied interrupt handler to count
// pulses that occur when a magnetic field of the correct polarity
// is detected. This could be used to measure the rotations per
// minute (RPM) of a rotor for example.
hall->installISR(hallISR, NULL);
while (shouldRun)
cout << "Pulses detected: " << counter << endl;

Public Member Functions

 A110X (int pin)
 ~A110X ()
bool magnetDetected ()
void installISR (void(*isr)(void *), void *arg)
void uninstallISR ()

Constructor & Destructor Documentation

A110X ( int  pin)

A110x digital sensor constructor

pinDigital pin to use
~A110X ( )

A110X destructor

Member Function Documentation

bool magnetDetected ( )

Determines whether a magnetic field of south polarity has been detected

True if magnetic field detected
void installISR ( void(*)(void *)  isr,
void *  arg 

Installs an interrupt service routine (ISR) to be called when the appropriate magnetic field is detected

isrPointer to a function to be called on interrupt
argPointer to an object to be supplied as an argument to the ISR.
void uninstallISR ( )

Uninstalls the previously installed ISR

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