complete motor
Dependencies: BufferedSerial motor_sn7544
Diff: main.cpp
- Revision:
- 1:1d18a2e8ce45
- Parent:
- 0:dde6e4d8c301
- Child:
- 2:a04440f0d001
diff -r dde6e4d8c301 -r 1d18a2e8ce45 main.cpp --- a/main.cpp Thu May 09 11:27:32 2019 +0000 +++ b/main.cpp Thu May 23 08:53:48 2019 +0000 @@ -1,30 +1,27 @@ #include "mbed.h" +#include "motor.h" +MotorCtl motor1(D3,D12,D4,D5); +InterruptIn tachoINT1(D4); +InterruptIn tachoINT2(D5); Serial pc(USBTX,USBRX,115200); -DigitalOut led(LED2); - -void rx_cn(void){ - while(true){ - char ch; - ch =pc.getc(); - pc.putc(ch); - - if(ch ==0x0D){ - pc.putc(0x0A); - } - - } +void update_current(void){ + motor1.UpdateCurrentPosition(); + // pc.printf("Update Position\r\n"); +} + +int main(){ + tachoINT1.fall(&update_current); + tachoINT1.rise(&update_current); + tachoINT2.fall(&update_current); + tachoINT2.rise(&update_current); + + while(1){ + } + } -int main(){ - pc.attach(&rx_cn); - while(1){ - wait(1); - led = !led; - - } -} \ No newline at end of file