Bayley Wang
/
analoghalls
potato
Fork of analoghalls by
main.cpp@2:b5c19d4eddcc, 2015-02-23 (annotated)
- Committer:
- bwang
- Date:
- Mon Feb 23 19:42:50 2015 +0000
- Revision:
- 2:b5c19d4eddcc
- Parent:
- 1:70eed554399b
- Child:
- 3:86ccde39f61b
stuff
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nki | 0:9753f3c2e5ca | 1 | #include "mbed.h" |
bwang | 2:b5c19d4eddcc | 2 | |
bwang | 2:b5c19d4eddcc | 3 | |
nki | 0:9753f3c2e5ca | 4 | #include "constants.h" |
nki | 0:9753f3c2e5ca | 5 | #include "shared.h" |
nki | 0:9753f3c2e5ca | 6 | #include "util.h" |
nki | 0:9753f3c2e5ca | 7 | #include "math.h" |
bwang | 1:70eed554399b | 8 | #include "isr.h" |
nki | 0:9753f3c2e5ca | 9 | |
nki | 0:9753f3c2e5ca | 10 | Serial pc(SERIAL_TX, SERIAL_RX); |
nki | 0:9753f3c2e5ca | 11 | |
nki | 0:9753f3c2e5ca | 12 | PwmOut pha(_PH_A); |
nki | 0:9753f3c2e5ca | 13 | PwmOut phb(_PH_B); |
nki | 0:9753f3c2e5ca | 14 | PwmOut phc(_PH_C); |
nki | 0:9753f3c2e5ca | 15 | |
nki | 0:9753f3c2e5ca | 16 | DigitalOut en(_EN); |
nki | 0:9753f3c2e5ca | 17 | |
bwang | 2:b5c19d4eddcc | 18 | DigitalIn dummy(D5); |
bwang | 2:b5c19d4eddcc | 19 | |
nki | 0:9753f3c2e5ca | 20 | AnalogIn throttle(_THROTTLE); |
nki | 0:9753f3c2e5ca | 21 | AnalogIn analoga(_ANALOGA); |
nki | 0:9753f3c2e5ca | 22 | AnalogIn analogb(_ANALOGB); |
nki | 0:9753f3c2e5ca | 23 | |
nki | 0:9753f3c2e5ca | 24 | Motor* motor; |
nki | 0:9753f3c2e5ca | 25 | |
bwang | 2:b5c19d4eddcc | 26 | #ifdef __USE_THROTTLE |
bwang | 2:b5c19d4eddcc | 27 | Ticker dtc_upd_ticker; |
bwang | 2:b5c19d4eddcc | 28 | Ticker throttle_upd_ticker; |
bwang | 2:b5c19d4eddcc | 29 | #endif |
nki | 0:9753f3c2e5ca | 30 | |
bwang | 1:70eed554399b | 31 | float throttle_read; |
nki | 0:9753f3c2e5ca | 32 | |
bwang | 2:b5c19d4eddcc | 33 | int main() { |
nki | 0:9753f3c2e5ca | 34 | en = 1; |
nki | 0:9753f3c2e5ca | 35 | |
nki | 0:9753f3c2e5ca | 36 | initTimers(); |
nki | 0:9753f3c2e5ca | 37 | initPins(); |
nki | 0:9753f3c2e5ca | 38 | initData(); |
nki | 0:9753f3c2e5ca | 39 | |
nki | 0:9753f3c2e5ca | 40 | while(1) { |
bwang | 2:b5c19d4eddcc | 41 | #ifdef __USE_THROTTLE |
bwang | 1:70eed554399b | 42 | throttle_read = throttle; |
bwang | 2:b5c19d4eddcc | 43 | #endif |
bwang | 1:70eed554399b | 44 | pos_update(); |
bwang | 2:b5c19d4eddcc | 45 | #ifndef __USE_THROTTLE |
bwang | 2:b5c19d4eddcc | 46 | dtc_update(); |
bwang | 2:b5c19d4eddcc | 47 | #endif |
nki | 0:9753f3c2e5ca | 48 | } |
nki | 0:9753f3c2e5ca | 49 | } |