Mario Bambagini / Mbed 2 deprecated car_chassis

Dependencies:   Servo mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers clock.cpp Source File

clock.cpp

00001 #include "car_config.hpp"
00002 #include "net.hpp"
00003 #include "can.hpp"
00004 #include "mbed.h"
00005 #include "rtos.h"
00006 
00007 void init_clock()
00008 {
00009   set_time(0);
00010 }
00011 
00012 void thread_clock (void const *args)
00013 {
00014   while(1) {
00015     //if a time update has been received
00016     if (can_cmd_time.flag == CAN_FLAG_RECEIVED) {
00017       //update time
00018       set_time(can_cmd_time.payload.msg.time);
00019 //      time_t seconds = time(NULL);
00020 //      printf("time: %s\r\n", ctime(&seconds));
00021       //set the message as read
00022       can_cmd_time.flag = CAN_FLAG_EMPTY;
00023     }
00024     Thread::wait(CLOCK_THREAD_PERIOD);
00025   }
00026 }