Bayley Wang
/
flash_configuration
flash based config testing
main.cpp@0:941e150e78b6, 2017-03-01 (annotated)
- Committer:
- bwang
- Date:
- Wed Mar 01 00:52:47 2017 +0000
- Revision:
- 0:941e150e78b6
- Child:
- 1:df6bbacb7bb9
first commit, reading/writing of config arrays works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 0:941e150e78b6 | 1 | #include "mbed.h" |
bwang | 0:941e150e78b6 | 2 | #include "config.h" |
bwang | 0:941e150e78b6 | 3 | #include "config_driving.h" |
bwang | 0:941e150e78b6 | 4 | #include "config_inverter.h" |
bwang | 0:941e150e78b6 | 5 | #include "config_logging.h" |
bwang | 0:941e150e78b6 | 6 | #include "config_loop.h" |
bwang | 0:941e150e78b6 | 7 | #include "config_motor.h" |
bwang | 0:941e150e78b6 | 8 | #include "config_pins.h" |
bwang | 0:941e150e78b6 | 9 | #include "config_table.h" |
bwang | 0:941e150e78b6 | 10 | #include "PreferenceWriter.h" |
bwang | 0:941e150e78b6 | 11 | #include "FlashWriter.h" |
bwang | 0:941e150e78b6 | 12 | |
bwang | 0:941e150e78b6 | 13 | Serial pc(USBTX, USBRX); |
bwang | 0:941e150e78b6 | 14 | PreferenceWriter pref(6); |
bwang | 0:941e150e78b6 | 15 | |
bwang | 0:941e150e78b6 | 16 | int main() { |
bwang | 0:941e150e78b6 | 17 | pc.baud(115200); |
bwang | 0:941e150e78b6 | 18 | pc.printf("%s\n", "Serial Configuration Test"); |
bwang | 0:941e150e78b6 | 19 | |
bwang | 0:941e150e78b6 | 20 | /* |
bwang | 0:941e150e78b6 | 21 | DEFAULT(TORQUE_MODE); |
bwang | 0:941e150e78b6 | 22 | DEFAULT(MAX_TQPCT_PLUS); |
bwang | 0:941e150e78b6 | 23 | DEFAULT(MAX_TQPCT_MINUS); |
bwang | 0:941e150e78b6 | 24 | DEFAULT(TORQUE_MAX); |
bwang | 0:941e150e78b6 | 25 | DEFAULT(W_MAX); |
bwang | 0:941e150e78b6 | 26 | DEFAULT(BUS_VOLTAGE); |
bwang | 0:941e150e78b6 | 27 | DEFAULT(F_SW); |
bwang | 0:941e150e78b6 | 28 | DEFAULT(K_LOOP_D); |
bwang | 0:941e150e78b6 | 29 | DEFAULT(KI_BASE_D); |
bwang | 0:941e150e78b6 | 30 | DEFAULT(K_LOOP_Q); |
bwang | 0:941e150e78b6 | 31 | DEFAULT(KI_BASE_Q); |
bwang | 0:941e150e78b6 | 32 | DEFAULT(F_SLOW_LOOP); |
bwang | 0:941e150e78b6 | 33 | DEFAULT(INTEGRAL_MAX); |
bwang | 0:941e150e78b6 | 34 | DEFAULT(W_FILTER_STRENGTH); |
bwang | 0:941e150e78b6 | 35 | DEFAULT(DQ_FILTER_STRENGTH); |
bwang | 0:941e150e78b6 | 36 | DEFAULT(THROTTLE_FILTER_STRENGTH); |
bwang | 0:941e150e78b6 | 37 | DEFAULT(KP_D); |
bwang | 0:941e150e78b6 | 38 | DEFAULT(KI_D); |
bwang | 0:941e150e78b6 | 39 | DEFAULT(KP_Q); |
bwang | 0:941e150e78b6 | 40 | DEFAULT(KI_Q); |
bwang | 0:941e150e78b6 | 41 | DEFAULT(SLOW_LOOP_COUNTER); |
bwang | 0:941e150e78b6 | 42 | DEFAULT(POLE_PAIRS); |
bwang | 0:941e150e78b6 | 43 | DEFAULT(POS_OFFSET); |
bwang | 0:941e150e78b6 | 44 | DEFAULT(RESOLVER_LOBES); |
bwang | 0:941e150e78b6 | 45 | DEFAULT(CPR); |
bwang | 0:941e150e78b6 | 46 | DEFAULT(Ld); |
bwang | 0:941e150e78b6 | 47 | DEFAULT(Lq); |
bwang | 0:941e150e78b6 | 48 | DEFAULT(FLUX_LINKAGE); |
bwang | 0:941e150e78b6 | 49 | DEFAULT(Rs); |
bwang | 0:941e150e78b6 | 50 | DEFAULT(KT); |
bwang | 0:941e150e78b6 | 51 | DEFAULT(W_SAFE); |
bwang | 0:941e150e78b6 | 52 | DEFAULT(W_CRAZY); |
bwang | 0:941e150e78b6 | 53 | DEFAULT(TH_LIMIT_LOW); |
bwang | 0:941e150e78b6 | 54 | DEFAULT(TH_LIMIT_HIGH); |
bwang | 0:941e150e78b6 | 55 | DEFAULT(TH_LIMIT_CRAZY); |
bwang | 0:941e150e78b6 | 56 | DEFAULT(ROWS); |
bwang | 0:941e150e78b6 | 57 | DEFAULT(COLUMNS); |
bwang | 0:941e150e78b6 | 58 | DEFAULT(W_STEP); |
bwang | 0:941e150e78b6 | 59 | |
bwang | 0:941e150e78b6 | 60 | pref.open(); |
bwang | 0:941e150e78b6 | 61 | pref.flush(); |
bwang | 0:941e150e78b6 | 62 | pref.close(); |
bwang | 0:941e150e78b6 | 63 | |
bwang | 0:941e150e78b6 | 64 | int offs; |
bwang | 0:941e150e78b6 | 65 | for (offs = 0; offs < 64; offs++) { |
bwang | 0:941e150e78b6 | 66 | __float_reg[offs] = 0.0f; |
bwang | 0:941e150e78b6 | 67 | __int_reg[offs] = 0; |
bwang | 0:941e150e78b6 | 68 | } |
bwang | 0:941e150e78b6 | 69 | */ |
bwang | 0:941e150e78b6 | 70 | |
bwang | 0:941e150e78b6 | 71 | pref.load(); |
bwang | 0:941e150e78b6 | 72 | |
bwang | 0:941e150e78b6 | 73 | DPRINT(TORQUE_MODE); |
bwang | 0:941e150e78b6 | 74 | FPRINT(MAX_TQPCT_PLUS); |
bwang | 0:941e150e78b6 | 75 | FPRINT(MAX_TQPCT_MINUS); |
bwang | 0:941e150e78b6 | 76 | FPRINT(TORQUE_MAX); |
bwang | 0:941e150e78b6 | 77 | FPRINT(W_MAX); |
bwang | 0:941e150e78b6 | 78 | FPRINT(BUS_VOLTAGE); |
bwang | 0:941e150e78b6 | 79 | FPRINT(F_SW); |
bwang | 0:941e150e78b6 | 80 | FPRINT(K_LOOP_D); |
bwang | 0:941e150e78b6 | 81 | FPRINT(KI_BASE_D); |
bwang | 0:941e150e78b6 | 82 | FPRINT(K_LOOP_Q); |
bwang | 0:941e150e78b6 | 83 | FPRINT(KI_BASE_Q); |
bwang | 0:941e150e78b6 | 84 | FPRINT(F_SLOW_LOOP); |
bwang | 0:941e150e78b6 | 85 | FPRINT(INTEGRAL_MAX); |
bwang | 0:941e150e78b6 | 86 | FPRINT(W_FILTER_STRENGTH); |
bwang | 0:941e150e78b6 | 87 | FPRINT(DQ_FILTER_STRENGTH); |
bwang | 0:941e150e78b6 | 88 | FPRINT(THROTTLE_FILTER_STRENGTH); |
bwang | 0:941e150e78b6 | 89 | FPRINT(KP_D); |
bwang | 0:941e150e78b6 | 90 | FPRINT(KI_D); |
bwang | 0:941e150e78b6 | 91 | FPRINT(KP_Q); |
bwang | 0:941e150e78b6 | 92 | FPRINT(KI_Q); |
bwang | 0:941e150e78b6 | 93 | FPRINT(SLOW_LOOP_COUNTER); |
bwang | 0:941e150e78b6 | 94 | FPRINT(POLE_PAIRS); |
bwang | 0:941e150e78b6 | 95 | FPRINT(POS_OFFSET); |
bwang | 0:941e150e78b6 | 96 | FPRINT(RESOLVER_LOBES); |
bwang | 0:941e150e78b6 | 97 | DPRINT(CPR); |
bwang | 0:941e150e78b6 | 98 | FPRINT(Ld); |
bwang | 0:941e150e78b6 | 99 | FPRINT(Lq); |
bwang | 0:941e150e78b6 | 100 | FPRINT(FLUX_LINKAGE); |
bwang | 0:941e150e78b6 | 101 | FPRINT(Rs); |
bwang | 0:941e150e78b6 | 102 | FPRINT(KT); |
bwang | 0:941e150e78b6 | 103 | FPRINT(W_SAFE); |
bwang | 0:941e150e78b6 | 104 | FPRINT(W_CRAZY); |
bwang | 0:941e150e78b6 | 105 | DPRINT(TH_LIMIT_LOW); |
bwang | 0:941e150e78b6 | 106 | DPRINT(TH_LIMIT_HIGH); |
bwang | 0:941e150e78b6 | 107 | DPRINT(TH_LIMIT_CRAZY); |
bwang | 0:941e150e78b6 | 108 | DPRINT(ROWS); |
bwang | 0:941e150e78b6 | 109 | DPRINT(COLUMNS); |
bwang | 0:941e150e78b6 | 110 | FPRINT(W_STEP); |
bwang | 0:941e150e78b6 | 111 | |
bwang | 0:941e150e78b6 | 112 | for(;;) { |
bwang | 0:941e150e78b6 | 113 | } |
bwang | 0:941e150e78b6 | 114 | } |