1
MODE/mode.cpp@3:ac1062c23c49, 2022-02-22 (annotated)
- Committer:
- yezhong
- Date:
- Tue Feb 22 14:31:06 2022 +0000
- Revision:
- 3:ac1062c23c49
- Parent:
- 2:e85ebf401989
11
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 | 2:e85ebf401989 | 46 | // 进入速度模式 |
yezhong | 2:e85ebf401989 | 47 | void EnterSPEEDMode(CANMessage * msg){ |
yezhong | 2:e85ebf401989 | 48 | msg->data[0] = 0xFF; |
yezhong | 2:e85ebf401989 | 49 | msg->data[1] = 0xFF; |
yezhong | 2:e85ebf401989 | 50 | msg->data[2] = 0xFF; |
yezhong | 2:e85ebf401989 | 51 | msg->data[3] = 0xFF; |
yezhong | 2:e85ebf401989 | 52 | msg->data[4] = 0xFF; |
yezhong | 2:e85ebf401989 | 53 | msg->data[5] = 0xFF; |
yezhong | 2:e85ebf401989 | 54 | msg->data[6] = 0xFF; |
yezhong | 2:e85ebf401989 | 55 | msg->data[7] = 0xFA; |
yezhong | 2:e85ebf401989 | 56 | WriteAll(); |
yezhong | 2:e85ebf401989 | 57 | } |
yezhong | 2:e85ebf401989 | 58 | // 进入位置模式 |
yezhong | 2:e85ebf401989 | 59 | void EnterPositionMode(CANMessage * msg){ |
yezhong | 2:e85ebf401989 | 60 | msg->data[0] = 0xFF; |
yezhong | 2:e85ebf401989 | 61 | msg->data[1] = 0xFF; |
yezhong | 2:e85ebf401989 | 62 | msg->data[2] = 0xFF; |
yezhong | 2:e85ebf401989 | 63 | msg->data[3] = 0xFF; |
yezhong | 2:e85ebf401989 | 64 | msg->data[4] = 0xFF; |
yezhong | 2:e85ebf401989 | 65 | msg->data[5] = 0xFF; |
yezhong | 2:e85ebf401989 | 66 | msg->data[6] = 0xFF; |
yezhong | 2:e85ebf401989 | 67 | msg->data[7] = 0xFB; |
yezhong | 2:e85ebf401989 | 68 | WriteAll(); |
yezhong | 2:e85ebf401989 | 69 | } |