Program to control an accelerometer, motors and a rangefinder using the ScmRTOS ported to mbed. (Work in progress and buggy)
processes.h
00001 #pragma once 00002 00003 #ifndef PROCESSES_H 00004 #define PROCESSES_H 00005 #include <event_flags.h> 00006 //#include <Servo_Control.h> 00007 00008 // Process types 00009 // 00010 00011 /* 00012 typedef OS::process<OS::pr0, 1400> PING_PROC; 00013 typedef OS::process<OS::pr1, 1000> TProc2; 00014 typedef OS::process<OS::pr2, 3000> Accelo_proc; 00015 typedef OS::process<OS::pr3, 1000> Servo_control; 00016 typedef OS::process<OS::pr4, 3000> Command_handler; 00017 typedef OS::process<OS::pr5, 1000> Motor_controller; 00018 typedef OS::process<OS::pr6, 4000> Serial_Out; 00019 */ 00020 00021 typedef OS::process<OS::pr0, 2000> PING_PROC; 00022 typedef OS::process<OS::pr1, 1400> TProc2; 00023 typedef OS::process<OS::pr2, 3000> Accelo_proc; 00024 typedef OS::process<OS::pr3, 2000> Servo_control; 00025 typedef OS::process<OS::pr4, 3000> Command_handler; 00026 typedef OS::process<OS::pr5, 2000> Motor_controller; 00027 typedef OS::process<OS::pr6, 4000> Serial_Out; 00028 00029 //typedef OS::process<OS::pr3, 300> TProc4; 00030 00031 //--------------------------------------------------------------------------- 00032 // 00033 // Process objects 00034 // 00035 PING_PROC PING_PROCESS; 00036 TProc2 Proc2; 00037 Accelo_proc Accelerometer_process; 00038 Servo_control Servo_process; 00039 Command_handler Com_Handler; 00040 Serial_Out Serial_Out_Proc; 00041 Motor_controller M_cont_process; 00042 00043 //--------------------------------------------------------------------------- 00044 00045 00046 00047 // IO Pins 00048 // 00049 //DigitalOut led1(LED1); 00050 //DigitalOut led2(LED2); 00051 00052 00053 //--------------------------------------------------------------------------- 00054 00055 00056 //--------------------------------------------------------------------------- 00057 //extra declarations 00058 00059 00060 00061 00062 00063 00064 00065 00066 BusOut leds(LED1, LED2, LED3, LED4); 00067 00068 00069 //--------------------------------------------------------------------------- 00070 template<> OS_PROCESS void TProc2::Exec() 00071 { 00072 for(;;) 00073 { 00074 Sleep(500); //suspend process 00075 //printf("e\n"); 00076 //led1 = !led1; 00077 //leds = 0x1; 00078 } 00079 } 00080 00081 //--------------------------------------------------------------------------- 00082 00083 00084 00085 void OS::SystemTimerUserHook() 00086 { 00087 static int cnt=0; 00088 if (++cnt == 2000) 00089 { 00090 cnt = 0; 00091 //led2.write(1); 00092 timerEvent.SignalISR(); 00093 } 00094 } 00095 00096 //--------------------------------------------------------------------------- 00097 void OS::IdleProcessUserHook() 00098 { 00099 __WFI(); //sleep the ucontroller and wait for interrupt 00100 } 00101 //----------------------------------------------------------------------------- 00102 00103 #endif 00104 00105
Generated on Wed Jul 13 2022 05:20:16 by 1.7.2