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
Diff: clock.cpp
- Revision:
- 2:7dfc8dd6aab3
- Parent:
- 1:79b1ee0f97ef
--- a/clock.cpp Mon Aug 31 22:25:57 2015 +0000
+++ b/clock.cpp Thu Oct 08 13:36:17 2015 +0000
@@ -1,24 +1,26 @@
#include "car_config.hpp"
+#include "net.hpp"
+#include "can.hpp"
#include "mbed.h"
#include "rtos.h"
-extern can_cmd_time_t can_cmd_time;
-
void init_clock()
{
- set_time(0);
+ 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);
+ 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);
+ }
}