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: driver.cpp
- Revision:
- 1:79b1ee0f97ef
- Child:
- 2:7dfc8dd6aab3
diff -r ce6055872f4e -r 79b1ee0f97ef driver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/driver.cpp Mon Aug 31 22:25:57 2015 +0000 @@ -0,0 +1,35 @@ +#include "car_config.hpp" +#include "mbed.h" +#include "rtos.h" + +extern can_cmd_driver_t can_cmd_driver; +extern can_sts_driver_t can_sts_driver; + +void init_driver () +{ +} + + +void thread_driver (void const *args) +{ + while(1) { + //printf("DRIVER\r\n"); + if (can_cmd_driver.flag == CAN_FLAG_RECEIVED) { + uint16 cmd = can_cmd_driver.payload.msg.cmd; + //uint16 opt = can_cmd_driver.payload.msg.opt; + uint32 data = can_cmd_driver.payload.msg.data; + switch(cmd) { + case CMD_ECHO: + can_sts_driver.payload.msg.data = data; + can_sts_driver.flag = CAN_FLAG_SEND; + printf("ECHO %d\r\n", can_cmd_driver.payload.msg.data); + break; + default: + //ignore it + break; + } + can_cmd_driver.flag = CAN_FLAG_EMPTY; + } + Thread::wait(DRIVER_THREAD_PERIOD); + } +}