Duncan Haldane
/
mbed_AS5047P_driver
driver
main.cpp@0:00c56a9c6dee, 2016-03-05 (annotated)
- Committer:
- dhaldane
- Date:
- Sat Mar 05 00:09:45 2016 +0000
- Revision:
- 0:00c56a9c6dee
Driver codes;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dhaldane | 0:00c56a9c6dee | 1 | #include "mbed.h" |
dhaldane | 0:00c56a9c6dee | 2 | #include "enc.h" |
dhaldane | 0:00c56a9c6dee | 3 | |
dhaldane | 0:00c56a9c6dee | 4 | Ticker RTI; |
dhaldane | 0:00c56a9c6dee | 5 | DigitalOut myled(LED1); |
dhaldane | 0:00c56a9c6dee | 6 | Serial pc(USBTX, USBRX); // tx, rx |
dhaldane | 0:00c56a9c6dee | 7 | enc crankPos(p5,p6,p7,p8); |
dhaldane | 0:00c56a9c6dee | 8 | |
dhaldane | 0:00c56a9c6dee | 9 | |
dhaldane | 0:00c56a9c6dee | 10 | void get_state(){ |
dhaldane | 0:00c56a9c6dee | 11 | crankPos.update_pos(); |
dhaldane | 0:00c56a9c6dee | 12 | } |
dhaldane | 0:00c56a9c6dee | 13 | |
dhaldane | 0:00c56a9c6dee | 14 | int main() { |
dhaldane | 0:00c56a9c6dee | 15 | RTI.attach(&get_state, 0.01); |
dhaldane | 0:00c56a9c6dee | 16 | while(1) { |
dhaldane | 0:00c56a9c6dee | 17 | myled = 1; |
dhaldane | 0:00c56a9c6dee | 18 | wait(0.05); |
dhaldane | 0:00c56a9c6dee | 19 | pc.printf("Encoder: %u \r\n", crankPos.cal_state()); |
dhaldane | 0:00c56a9c6dee | 20 | myled = 0; |
dhaldane | 0:00c56a9c6dee | 21 | wait(0.05); |
dhaldane | 0:00c56a9c6dee | 22 | } |
dhaldane | 0:00c56a9c6dee | 23 | } |