car chassis
Dependencies: Servo mbed-rtos mbed
clock.cpp
- Committer:
- mariob
- Date:
- 2015-10-13
- Revision:
- 4:7fa7f78cbb92
- Parent:
- 2:7dfc8dd6aab3
File content as of revision 4:7fa7f78cbb92:
#include "car_config.hpp"
#include "net.hpp"
#include "can.hpp"
#include "mbed.h"
#include "rtos.h"
void init_clock()
{
set_time(0);
}
void thread_clock (void const *args)
{
while(1) {
//if a time update has been received
if (can_cmd_time.flag == CAN_FLAG_RECEIVED) {
//update time
set_time(can_cmd_time.payload.msg.time);
// time_t seconds = time(NULL);
// printf("time: %s\r\n", ctime(&seconds));
//set the message as read
can_cmd_time.flag = CAN_FLAG_EMPTY;
}
Thread::wait(CLOCK_THREAD_PERIOD);
}
}
Mario Bambagini