UVic Assistive Technology Lab / Mbed 2 deprecated DSLR_Camera_Gimbal

Dependencies:   mbed ros_lib_kinetic

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers interrupts.cpp Source File

interrupts.cpp

00001 #include "mbed.h"
00002 #include <definitions.h>
00003 
00004 //Stall Checking Interrupt
00005 void hallInterrupt(){
00006     if(prevPosition == currentPosition){
00007         stallcount++;
00008     }
00009     else if(liftSpeed.read() > 0){
00010         prevPosition = currentPosition;
00011         stallcount = 0;          
00012     }
00013 }
00014 
00015 //E-Stop Interrupt
00016 void eStopOn(){
00017     eStopFlag = 1;
00018     hallInt.detach();
00019 }
00020 void eStopOff(){
00021     eStopFlag = 0;
00022     hallInt.attach(&hallInterrupt, 0.03);
00023 }
00024 
00025 //External Interrupt Counter
00026 class Hall_Counter_1 {
00027 public:
00028     Hall_Counter_1(PinName pin) : _interrupt(pin) {        // create the InterruptIn on the pin specified to Counter
00029         _interrupt.rise(this, &Hall_Counter_1::increment); // attach increment function of this counter instance
00030     }
00031     void increment() {
00032         if(filter_hall1.read_ms() > 5){
00033             if(liftDirection.read() == LIFTUP){
00034                 currentPosition++;
00035             }
00036             else{
00037                 currentPosition--;
00038             }
00039             filter_hall1.reset();
00040         }
00041     }
00042  
00043 private:
00044     InterruptIn _interrupt;
00045 };
00046 
00047 Hall_Counter_1 hall_Counter_1(PC_7);