quentin godbert
/
t2-stm32-lift
interrupt géré compil ok sans isr
Fork of T2_STM32 by
Diff: lift.h
- Revision:
- 8:dcaa5c9d8706
- Parent:
- 7:62407850a97d
- Child:
- 9:d3dcad0c7d57
diff -r 62407850a97d -r dcaa5c9d8706 lift.h --- a/lift.h Mon Feb 05 16:17:45 2018 +0000 +++ b/lift.h Tue Feb 06 09:27:06 2018 +0000 @@ -12,14 +12,22 @@ motiondir , motionsensor ; -DigitalOut led1(LED1); +DigitalOut RED(D6); +DigitalOut GRN(D5); +DigitalOut AMB(D4); +DigitalOut myled(LED1); +Ticker timer; + +PwmOut Step(motionspin); +AnalogIn Step2(motionsensor); +DigitalOut Dir2(motiondir); class Lift { public: - Lift(PinName, PinName, PinName); + Lift(PinName); Lift(); ~Lift(); @@ -30,11 +38,11 @@ void GoDown(); private: - InterruptIn _interrupt; - unsigned char *trye - EventQueue queue(32); + + unsigned char *trye; +// EventQueue queue(32); Thread t; - +InterruptIn _interrupt; bool InMotion; char sTargetPos, @@ -48,26 +56,7 @@ tempDirPin; }; - PwmOut Step(motionspin); - AnalogIn Step2(motionsensor); - DigitalOut Dir2(motiondir); - -Lift::Lift(PinName motionspin,PinName motiondir,PinName motionsensor): _interrupt(motionsensor){ - //t.start(callback(&queue, &EventQueue::dispatch_forever)); - printf("Starting in context %p\r\n", Thread::gettid()); - // The 'rise' handler will execute in IRQ context - _interrupt.rise(Step2, *Lift::Stopping); - // The 'fall' handler will execute in the context of thread 't' - //_interrupt.fall(queue.event(fall_handler)); -} -Lift::Lift(){ - Lift(PinName(motionspin) ,PinName(motiondir),PinName(motionsensor)); -} -Lift::~Lift() -{ - -} void Lift::Starting(){ int i; @@ -96,3 +85,17 @@ Starting(); } + + +Lift::Lift(PinName motionsensor): _interrupt(motionsensor){ + //t.start(callback(&queue, &EventQueue::dispatch_forever)); + printf("Starting in context %p\r\n", Thread::gettid()); + _interrupt.mode(PullUp); + // The 'rise' handler will execute in IRQ context + _interrupt.rise(callback(this, &Lift::Stopping)); + // The 'fall' handler will execute in the context of thread 't' + //_interrupt.fall(queue.event(fall_handler)); + while(1){ + sleep(); //Sleep to save power, Interrupted by Ticker and Pulse events + } +}