1
Dependencies: mcp2515 mbed-dev-f303
MODE/mode.cpp@8:2250c7f70748, 2022-06-24 (annotated)
- Committer:
- yezhong
- Date:
- Fri Jun 24 01:24:33 2022 +0000
- Revision:
- 8:2250c7f70748
- Parent:
- 4:2503c88a564f
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
panzhan | 0:d80c66cb1b3a | 1 | #include "mode.h" |
panzhan | 0:d80c66cb1b3a | 2 | #include "CAN.h" |
panzhan | 0:d80c66cb1b3a | 3 | |
panzhan | 0:d80c66cb1b3a | 4 | |
panzhan | 0:d80c66cb1b3a | 5 | |
panzhan | 0:d80c66cb1b3a | 6 | // |
panzhan | 0:d80c66cb1b3a | 7 | void Zero(CANMessage * msg){ |
panzhan | 0:d80c66cb1b3a | 8 | msg->data[0] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 9 | msg->data[1] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 10 | msg->data[2] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 11 | msg->data[3] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 12 | msg->data[4] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 13 | msg->data[5] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 14 | msg->data[6] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 15 | msg->data[7] = 0xFE; |
panzhan | 0:d80c66cb1b3a | 16 | WriteAll(); |
panzhan | 0:d80c66cb1b3a | 17 | } |
panzhan | 0:d80c66cb1b3a | 18 | |
panzhan | 0:d80c66cb1b3a | 19 | |
panzhan | 0:d80c66cb1b3a | 20 | // 进入电机模式 |
panzhan | 0:d80c66cb1b3a | 21 | void EnterMotorMode(CANMessage * msg){ |
panzhan | 0:d80c66cb1b3a | 22 | msg->data[0] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 23 | msg->data[1] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 24 | msg->data[2] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 25 | msg->data[3] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 26 | msg->data[4] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 27 | msg->data[5] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 28 | msg->data[6] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 29 | msg->data[7] = 0xFC; |
panzhan | 0:d80c66cb1b3a | 30 | WriteAll(); |
panzhan | 0:d80c66cb1b3a | 31 | } |
panzhan | 0:d80c66cb1b3a | 32 | |
panzhan | 0:d80c66cb1b3a | 33 | |
panzhan | 0:d80c66cb1b3a | 34 | // 退出电机模式 |
panzhan | 0:d80c66cb1b3a | 35 | void ExitMotorMode(CANMessage * msg){ |
panzhan | 0:d80c66cb1b3a | 36 | msg->data[0] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 37 | msg->data[1] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 38 | msg->data[2] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 39 | msg->data[3] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 40 | msg->data[4] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 41 | msg->data[5] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 42 | msg->data[6] = 0xFF; |
panzhan | 0:d80c66cb1b3a | 43 | msg->data[7] = 0xFD; |
panzhan | 0:d80c66cb1b3a | 44 | WriteAll(); |
panzhan | 0:d80c66cb1b3a | 45 | } |
yezhong | 4:2503c88a564f | 46 | // 进入速度模式 |
yezhong | 4:2503c88a564f | 47 | void EnterSPEEDMode(CANMessage * msg){ |
yezhong | 4:2503c88a564f | 48 | msg->data[0] = 0xFF; |
yezhong | 4:2503c88a564f | 49 | msg->data[1] = 0xFF; |
yezhong | 4:2503c88a564f | 50 | msg->data[2] = 0xFF; |
yezhong | 4:2503c88a564f | 51 | msg->data[3] = 0xFF; |
yezhong | 4:2503c88a564f | 52 | msg->data[4] = 0xFF; |
yezhong | 4:2503c88a564f | 53 | msg->data[5] = 0xFF; |
yezhong | 4:2503c88a564f | 54 | msg->data[6] = 0xFF; |
yezhong | 4:2503c88a564f | 55 | msg->data[7] = 0xFA; |
yezhong | 4:2503c88a564f | 56 | WriteAll(); |
yezhong | 4:2503c88a564f | 57 | } |
yezhong | 4:2503c88a564f | 58 | // 进入位置模式 |
yezhong | 4:2503c88a564f | 59 | void EnterPositionMode(CANMessage * msg){ |
yezhong | 4:2503c88a564f | 60 | msg->data[0] = 0xFF; |
yezhong | 4:2503c88a564f | 61 | msg->data[1] = 0xFF; |
yezhong | 4:2503c88a564f | 62 | msg->data[2] = 0xFF; |
yezhong | 4:2503c88a564f | 63 | msg->data[3] = 0xFF; |
yezhong | 4:2503c88a564f | 64 | msg->data[4] = 0xFF; |
yezhong | 4:2503c88a564f | 65 | msg->data[5] = 0xFF; |
yezhong | 4:2503c88a564f | 66 | msg->data[6] = 0xFF; |
yezhong | 4:2503c88a564f | 67 | msg->data[7] = 0xFB; |
yezhong | 4:2503c88a564f | 68 | WriteAll(); |
yezhong | 4:2503c88a564f | 69 | } |