Mario Bambagini / Mbed 2 deprecated car_chassis

Dependencies:   Servo mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //this project implements the body/engine devices
00002 
00003 #include "mbed.h"
00004 #include "car_config.hpp"
00005 #include "rtos.h"
00006 
00007 #include "can.hpp"
00008 #include "led.hpp"
00009 #include "body.hpp"
00010 #include "engine.hpp"
00011 #include "diag.hpp"
00012 #include "clock.hpp"
00013 
00014 //initialize the system:
00015 //- single components: body, clock, diagnosis, engine
00016 //- hardware: leds, can
00017 //- threads
00018 int init();
00019 
00020 int main()
00021 {
00022   //system setup
00023   init();
00024 
00025   //main loop
00026   while(1) {};
00027 }
00028 
00029 Thread *th_body;
00030 Thread *th_can;
00031 Thread *th_engine;
00032 Thread *th_diag;
00033 Thread *th_clock;
00034 
00035 void init_threads ()
00036 {
00037   th_body = new Thread(thread_body);
00038   th_engine = new Thread(thread_engine);
00039   th_can = new Thread(thread_can);
00040   th_diag = new Thread(thread_diag);
00041   th_clock = new Thread(thread_clock);
00042 }
00043 
00044 int init ()
00045 {
00046   init_body();
00047   init_clock();
00048   init_diag();
00049   init_engine();
00050 
00051   //printf("INIT LED\r\n");
00052   init_led();
00053 
00054   //printf("INIT CAN\r\n");
00055   init_can();
00056 
00057   //printf("INIT THREAD\r\n");
00058   init_threads();
00059 
00060   return true;
00061 }