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: USBDevice mbed motor
Zlatan-mbed/definitions.h@2:17457e177f52, 2017-01-04 (annotated)
- Committer:
- adamsonk
- Date:
- Wed Jan 04 10:32:52 2017 +0000
- Revision:
- 2:17457e177f52
- Parent:
- 1:110cb8bdfb71
Mainboardi kood viki jaoks
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| adamsonk | 0:4d372883a5b4 | 1 | #ifndef DEFINITIONS_H_ |
| adamsonk | 0:4d372883a5b4 | 2 | #define DEFINITIONS_H_ value |
| adamsonk | 0:4d372883a5b4 | 3 | |
| adamsonk | 0:4d372883a5b4 | 4 | #define NUMBER_OF_MOTORS 3 |
| adamsonk | 0:4d372883a5b4 | 5 | |
| adamsonk | 0:4d372883a5b4 | 6 | #define MOTOR_PWM(n) MOTOR ## n ## _PWM |
| adamsonk | 0:4d372883a5b4 | 7 | #define MOTOR_DIR1(n) MOTOR ## n ## _DIR1 |
| adamsonk | 0:4d372883a5b4 | 8 | #define MOTOR_DIR2(n) MOTOR ## n ## _DIR2 |
| adamsonk | 0:4d372883a5b4 | 9 | #define MOTOR_FAULT(n) MOTOR ## n ## _FAULT |
| adamsonk | 0:4d372883a5b4 | 10 | #define MOTOR_ENCA(n) MOTOR ## n ## _ENCA |
| adamsonk | 0:4d372883a5b4 | 11 | #define MOTOR_ENCB(n) MOTOR ## n ## _ENCB |
| adamsonk | 0:4d372883a5b4 | 12 | |
| adamsonk | 0:4d372883a5b4 | 13 | #define MOTOR_ENC_TICK(i) void motor ## i ## EncTick() { \ |
| adamsonk | 0:4d372883a5b4 | 14 | uint8_t enc_dir; \ |
| adamsonk | 0:4d372883a5b4 | 15 | motorEncNow[i] = MotorEncA[i]->read() | (MotorEncB[i]->read() << 1); \ |
| adamsonk | 0:4d372883a5b4 | 16 | enc_dir = (motorEncLast[i] & 1) ^ ((motorEncNow[i] & 2) >> 1); \ |
| adamsonk | 0:4d372883a5b4 | 17 | motorEncLast[i] = motorEncNow[i]; \ |
| adamsonk | 0:4d372883a5b4 | 18 | \ |
| adamsonk | 0:4d372883a5b4 | 19 | if (enc_dir & 1) motorTicks[i]++; \ |
| adamsonk | 0:4d372883a5b4 | 20 | else motorTicks[i]--; \ |
| adamsonk | 0:4d372883a5b4 | 21 | } |
| adamsonk | 0:4d372883a5b4 | 22 | |
| adamsonk | 0:4d372883a5b4 | 23 | #define MOTOR_PID_TICK(i) void motor ## i ## PidTick() { \ |
| adamsonk | 0:4d372883a5b4 | 24 | motors[i].pid2(motorTicks[i]); \ |
| adamsonk | 0:4d372883a5b4 | 25 | motorTicks[i] = 0; \ |
| adamsonk | 0:4d372883a5b4 | 26 | } |
| adamsonk | 0:4d372883a5b4 | 27 | #endif |