car chassis
Dependencies: Servo mbed-rtos mbed
clock.cpp@1:79b1ee0f97ef, 2015-08-31 (annotated)
- Committer:
- mariob
- Date:
- Mon Aug 31 22:25:57 2015 +0000
- Revision:
- 1:79b1ee0f97ef
- Child:
- 2:7dfc8dd6aab3
first commit with the following features: CAN driver (it works), eeprom (it works but it is not used)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mariob | 1:79b1ee0f97ef | 1 | #include "car_config.hpp" |
mariob | 1:79b1ee0f97ef | 2 | #include "mbed.h" |
mariob | 1:79b1ee0f97ef | 3 | #include "rtos.h" |
mariob | 1:79b1ee0f97ef | 4 | |
mariob | 1:79b1ee0f97ef | 5 | extern can_cmd_time_t can_cmd_time; |
mariob | 1:79b1ee0f97ef | 6 | |
mariob | 1:79b1ee0f97ef | 7 | void init_clock() |
mariob | 1:79b1ee0f97ef | 8 | { |
mariob | 1:79b1ee0f97ef | 9 | set_time(0); |
mariob | 1:79b1ee0f97ef | 10 | } |
mariob | 1:79b1ee0f97ef | 11 | |
mariob | 1:79b1ee0f97ef | 12 | void thread_clock (void const *args) |
mariob | 1:79b1ee0f97ef | 13 | { |
mariob | 1:79b1ee0f97ef | 14 | while(1) { |
mariob | 1:79b1ee0f97ef | 15 | //printf("CLOCK\r\n"); |
mariob | 1:79b1ee0f97ef | 16 | if (can_cmd_time.flag == CAN_FLAG_RECEIVED) { |
mariob | 1:79b1ee0f97ef | 17 | set_time(can_cmd_time.payload.msg.time); |
mariob | 1:79b1ee0f97ef | 18 | time_t seconds = time(NULL); |
mariob | 1:79b1ee0f97ef | 19 | printf("time: %s\r\n", ctime(&seconds)); |
mariob | 1:79b1ee0f97ef | 20 | can_cmd_time.flag = CAN_FLAG_EMPTY; |
mariob | 1:79b1ee0f97ef | 21 | } |
mariob | 1:79b1ee0f97ef | 22 | Thread::wait(CLOCK_THREAD_PERIOD); |
mariob | 1:79b1ee0f97ef | 23 | } |
mariob | 1:79b1ee0f97ef | 24 | } |