upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables 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.

a110x.jpg

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;
else
cout << "No magnet detected." << endl;
sleep(1);
}

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;
sleep(1);
}

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

Parameters
pinDigital pin to use
~A110X ( )

A110X destructor

Member Function Documentation

bool magnetDetected ( )

Determines whether a magnetic field of south polarity has been detected

Returns
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

Parameters
fptrPointer 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: