complete motor
Dependencies: BufferedSerial motor_sn7544
main.cpp@1:1d18a2e8ce45, 2019-05-23 (annotated)
- Committer:
- kangmingyo
- Date:
- Thu May 23 08:53:48 2019 +0000
- Revision:
- 1:1d18a2e8ce45
- Parent:
- 0:dde6e4d8c301
- Child:
- 2:a04440f0d001
2019/05/28;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kangmingyo | 0:dde6e4d8c301 | 1 | #include "mbed.h" |
kangmingyo | 1:1d18a2e8ce45 | 2 | #include "motor.h" |
kangmingyo | 0:dde6e4d8c301 | 3 | |
kangmingyo | 1:1d18a2e8ce45 | 4 | MotorCtl motor1(D3,D12,D4,D5); |
kangmingyo | 1:1d18a2e8ce45 | 5 | InterruptIn tachoINT1(D4); |
kangmingyo | 1:1d18a2e8ce45 | 6 | InterruptIn tachoINT2(D5); |
kangmingyo | 0:dde6e4d8c301 | 7 | Serial pc(USBTX,USBRX,115200); |
kangmingyo | 0:dde6e4d8c301 | 8 | |
kangmingyo | 1:1d18a2e8ce45 | 9 | void update_current(void){ |
kangmingyo | 1:1d18a2e8ce45 | 10 | motor1.UpdateCurrentPosition(); |
kangmingyo | 1:1d18a2e8ce45 | 11 | // pc.printf("Update Position\r\n"); |
kangmingyo | 1:1d18a2e8ce45 | 12 | } |
kangmingyo | 1:1d18a2e8ce45 | 13 | |
kangmingyo | 0:dde6e4d8c301 | 14 | |
kangmingyo | 1:1d18a2e8ce45 | 15 | int main(){ |
kangmingyo | 1:1d18a2e8ce45 | 16 | tachoINT1.fall(&update_current); |
kangmingyo | 1:1d18a2e8ce45 | 17 | tachoINT1.rise(&update_current); |
kangmingyo | 1:1d18a2e8ce45 | 18 | tachoINT2.fall(&update_current); |
kangmingyo | 1:1d18a2e8ce45 | 19 | tachoINT2.rise(&update_current); |
kangmingyo | 1:1d18a2e8ce45 | 20 | |
kangmingyo | 1:1d18a2e8ce45 | 21 | while(1){ |
kangmingyo | 1:1d18a2e8ce45 | 22 | } |
kangmingyo | 1:1d18a2e8ce45 | 23 | |
kangmingyo | 0:dde6e4d8c301 | 24 | } |
kangmingyo | 0:dde6e4d8c301 | 25 | |
kangmingyo | 0:dde6e4d8c301 | 26 | |
kangmingyo | 0:dde6e4d8c301 | 27 |