Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
interrupts.cpp
- Committer:
- MikeGray92
- Date:
- 2018-02-08
- Revision:
- 2:0537a8007a39
- Parent:
- 1:1ac7d472cfa2
- Child:
- 4:89ebfa37663b
File content as of revision 2:0537a8007a39:
#include "mbed.h"
#include <definitions.h>
//Stall Check Interrupt
void hallInterrupt(){
if(prevPosition == currentPosition){
stall = true;
}
else{
prevPosition = currentPosition;
stall = false;
}
}
//External Interrupt Counter
class Hall_Counter_1 {
public:
Hall_Counter_1(PinName pin) : _interrupt(pin) { // create the InterruptIn on the pin specified to Counter
_interrupt.rise(this, &Hall_Counter_1::increment); // attach increment function of this counter instance
}
void increment() {
if(filter_hall1.read_ms() > 5){
if(liftDirection.read() == LIFTUP){
currentPosition++;
}
else{
currentPosition--;
}
filter_hall1.reset();
}
}
private:
InterruptIn _interrupt;
};
Hall_Counter_1 hall_Counter_1(PC_7);