K22 processor

Committer:
bosko001
Date:
Sun Mar 21 18:20:15 2021 +0100
Revision:
7:4aa3dac73b66
novi pocetak

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bosko001 7:4aa3dac73b66 1 #ifndef THREAD_CLASS_H
bosko001 7:4aa3dac73b66 2 #define THREAD_CLASS_H
bosko001 7:4aa3dac73b66 3
bosko001 7:4aa3dac73b66 4 #include "mbed.h"
bosko001 7:4aa3dac73b66 5
bosko001 7:4aa3dac73b66 6 class C_fun
bosko001 7:4aa3dac73b66 7 {
bosko001 7:4aa3dac73b66 8 Thread *t;
bosko001 7:4aa3dac73b66 9
bosko001 7:4aa3dac73b66 10 virtual void thread_fun( void ) { while( true) {} }
bosko001 7:4aa3dac73b66 11 public:
bosko001 7:4aa3dac73b66 12 C_fun();// { t.start( [this]() { thread_fun(); } ); }
bosko001 7:4aa3dac73b66 13 C_fun( void(*pfun)(void) );// { t.start(pfun); }
bosko001 7:4aa3dac73b66 14 } ;
bosko001 7:4aa3dac73b66 15
bosko001 7:4aa3dac73b66 16
bosko001 7:4aa3dac73b66 17 C_fun::C_fun()
bosko001 7:4aa3dac73b66 18 {
bosko001 7:4aa3dac73b66 19 Thread *t = new Thread( osPriorityNormal, 1000);
bosko001 7:4aa3dac73b66 20 t->start( [this]() { thread_fun(); } );
bosko001 7:4aa3dac73b66 21 }
bosko001 7:4aa3dac73b66 22
bosko001 7:4aa3dac73b66 23 C_fun::C_fun( void(*pfun)(void) )
bosko001 7:4aa3dac73b66 24 {
bosko001 7:4aa3dac73b66 25 Thread *t = new Thread( osPriorityNormal, 1000);
bosko001 7:4aa3dac73b66 26 t->start(pfun);
bosko001 7:4aa3dac73b66 27 }
bosko001 7:4aa3dac73b66 28
bosko001 7:4aa3dac73b66 29
bosko001 7:4aa3dac73b66 30
bosko001 7:4aa3dac73b66 31 // class C_fun1: C_fun
bosko001 7:4aa3dac73b66 32 // {
bosko001 7:4aa3dac73b66 33 // void thread_fun( void ) override
bosko001 7:4aa3dac73b66 34 // { while( true) {led3 = 0; wait_us(5000); led3 = 1; ThisThread::sleep_for(4s);} }
bosko001 7:4aa3dac73b66 35
bosko001 7:4aa3dac73b66 36 // public:
bosko001 7:4aa3dac73b66 37 // C_fun1( void ){}
bosko001 7:4aa3dac73b66 38 // C_fun1( pfv fun): C_fun( fun){}
bosko001 7:4aa3dac73b66 39 // } c_f1(t1fun), c_f2;
bosko001 7:4aa3dac73b66 40
bosko001 7:4aa3dac73b66 41
bosko001 7:4aa3dac73b66 42 #endif