Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Servo mbed-rtos mbed
clock.cpp
- Committer:
- mariob
- Date:
- 2015-08-31
- Revision:
- 1:79b1ee0f97ef
- Child:
- 2:7dfc8dd6aab3
File content as of revision 1:79b1ee0f97ef:
#include "car_config.hpp"
#include "mbed.h"
#include "rtos.h"
extern can_cmd_time_t can_cmd_time;
void init_clock()
{
set_time(0);
}
void thread_clock (void const *args)
{
while(1) {
//printf("CLOCK\r\n");
if (can_cmd_time.flag == CAN_FLAG_RECEIVED) {
set_time(can_cmd_time.payload.msg.time);
time_t seconds = time(NULL);
printf("time: %s\r\n", ctime(&seconds));
can_cmd_time.flag = CAN_FLAG_EMPTY;
}
Thread::wait(CLOCK_THREAD_PERIOD);
}
}