potato

Dependencies:   mbed

Fork of analoghalls by N K

Committer:
bwang
Date:
Wed Feb 25 04:44:05 2015 +0000
Revision:
3:86ccde39f61b
Parent:
2:b5c19d4eddcc
Child:
4:f18f6bc5e1fd
such debug wow

Who changed what in which revision?

UserRevisionLine numberNew 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 3:86ccde39f61b 26 #ifdef __DEBUG
bwang 3:86ccde39f61b 27 float *fbuffer;
bwang 3:86ccde39f61b 28 int bufidx = 0;
bwang 3:86ccde39f61b 29 #endif
bwang 2:b5c19d4eddcc 30 #ifdef __USE_THROTTLE
bwang 2:b5c19d4eddcc 31 Ticker dtc_upd_ticker;
bwang 2:b5c19d4eddcc 32 Ticker throttle_upd_ticker;
bwang 2:b5c19d4eddcc 33 #endif
nki 0:9753f3c2e5ca 34
bwang 1:70eed554399b 35 float throttle_read;
nki 0:9753f3c2e5ca 36
bwang 2:b5c19d4eddcc 37 int main() {
nki 0:9753f3c2e5ca 38 en = 1;
bwang 3:86ccde39f61b 39 #ifdef __DEBUG
bwang 3:86ccde39f61b 40 fbuffer = (float*)malloc(10000*sizeof(float));
bwang 3:86ccde39f61b 41 #endif
nki 0:9753f3c2e5ca 42 initTimers();
nki 0:9753f3c2e5ca 43 initPins();
nki 0:9753f3c2e5ca 44 initData();
nki 0:9753f3c2e5ca 45
nki 0:9753f3c2e5ca 46 while(1) {
bwang 2:b5c19d4eddcc 47 #ifdef __USE_THROTTLE
bwang 1:70eed554399b 48 throttle_read = throttle;
bwang 2:b5c19d4eddcc 49 #endif
bwang 1:70eed554399b 50 pos_update();
bwang 2:b5c19d4eddcc 51 #ifndef __USE_THROTTLE
bwang 2:b5c19d4eddcc 52 dtc_update();
bwang 2:b5c19d4eddcc 53 #endif
bwang 3:86ccde39f61b 54 #ifdef __DEBUG
bwang 3:86ccde39f61b 55 if (motor->debug_stop) break;
bwang 3:86ccde39f61b 56 #endif
nki 0:9753f3c2e5ca 57 }
bwang 3:86ccde39f61b 58 #ifdef __DEBUG
bwang 3:86ccde39f61b 59 for (int i = 0; i < 10000; i++) {
bwang 3:86ccde39f61b 60 pc.printf("%f,", fbuffer[i]);
bwang 3:86ccde39f61b 61 }
bwang 3:86ccde39f61b 62 #endif
nki 0:9753f3c2e5ca 63 }