elixys periphreal system firmware library
Dependencies: MAX31855 MCP23S18 MCP3202 MCP3208 MCP482x ShiftRegister1
Fork of elixys by
elixys.cpp@1:b0f7c49b67f8, 2013-12-15 (annotated)
- Committer:
- henryeherman
- Date:
- Sun Dec 15 02:43:07 2013 +0000
- Revision:
- 1:b0f7c49b67f8
- Parent:
- 0:542583a6f6bb
- Child:
- 3:1b20a56e4457
Working elixys interface library with unit tests
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
henryeherman | 0:542583a6f6bb | 1 | #include "elixys.h" |
henryeherman | 0:542583a6f6bb | 2 | namespace Elixys { |
henryeherman | 0:542583a6f6bb | 3 | |
henryeherman | 1:b0f7c49b67f8 | 4 | // SPI Communication Bus |
henryeherman | 0:542583a6f6bb | 5 | SPI spibus(P0_9,P0_8,P0_7); |
henryeherman | 1:b0f7c49b67f8 | 6 | |
henryeherman | 1:b0f7c49b67f8 | 7 | // Fan Subsystem |
henryeherman | 1:b0f7c49b67f8 | 8 | PwmOut fan1(P2_4); |
henryeherman | 1:b0f7c49b67f8 | 9 | PwmOut fan2(P2_5); |
henryeherman | 1:b0f7c49b67f8 | 10 | DigitalOut fan0(P2_8); |
henryeherman | 1:b0f7c49b67f8 | 11 | DigitalOut misc0(P0_19); |
henryeherman | 1:b0f7c49b67f8 | 12 | |
henryeherman | 1:b0f7c49b67f8 | 13 | // Heater Subsystem |
henryeherman | 1:b0f7c49b67f8 | 14 | unsigned int heater_state; |
henryeherman | 1:b0f7c49b67f8 | 15 | mcp23s18 htriomux(spibus, selectheater, unselect); |
henryeherman | 1:b0f7c49b67f8 | 16 | |
henryeherman | 1:b0f7c49b67f8 | 17 | void setup_heater() { |
henryeherman | 1:b0f7c49b67f8 | 18 | htriomux.initialize(); |
henryeherman | 1:b0f7c49b67f8 | 19 | htriomux.set_all_output(); |
henryeherman | 1:b0f7c49b67f8 | 20 | heater_state = ALLHEATERSOFF; |
henryeherman | 1:b0f7c49b67f8 | 21 | } |
henryeherman | 1:b0f7c49b67f8 | 22 | |
henryeherman | 1:b0f7c49b67f8 | 23 | void turn_on_heater(unsigned int pins) { |
henryeherman | 1:b0f7c49b67f8 | 24 | heater_state &= ~(pins); |
henryeherman | 1:b0f7c49b67f8 | 25 | htriomux.write_port(heater_state); |
henryeherman | 1:b0f7c49b67f8 | 26 | } |
henryeherman | 1:b0f7c49b67f8 | 27 | |
henryeherman | 1:b0f7c49b67f8 | 28 | void turn_off_heater(unsigned int pins) { |
henryeherman | 1:b0f7c49b67f8 | 29 | heater_state |= (pins); |
henryeherman | 1:b0f7c49b67f8 | 30 | htriomux.write_port(heater_state); |
henryeherman | 1:b0f7c49b67f8 | 31 | } |
henryeherman | 1:b0f7c49b67f8 | 32 | |
henryeherman | 1:b0f7c49b67f8 | 33 | // Mixer Subsystem |
henryeherman | 1:b0f7c49b67f8 | 34 | PwmOut mtr0(P2_0); |
henryeherman | 1:b0f7c49b67f8 | 35 | PwmOut mtr1(P2_1); |
henryeherman | 1:b0f7c49b67f8 | 36 | PwmOut mtr2(P2_2); |
henryeherman | 1:b0f7c49b67f8 | 37 | PwmOut mtr3(P2_3); |
henryeherman | 1:b0f7c49b67f8 | 38 | |
henryeherman | 1:b0f7c49b67f8 | 39 | // SMCInteface Subsystem |
henryeherman | 1:b0f7c49b67f8 | 40 | MCP3202 smcadc(spibus, selectsmcadc, unselect); |
henryeherman | 1:b0f7c49b67f8 | 41 | MCP482X smcdac(spibus, selectsmcdac, unselect); |
henryeherman | 1:b0f7c49b67f8 | 42 | |
henryeherman | 1:b0f7c49b67f8 | 43 | // Thermocouple Interface |
henryeherman | 1:b0f7c49b67f8 | 44 | max31855 tcintf0(spibus, selecttc0, unselect); |
henryeherman | 1:b0f7c49b67f8 | 45 | max31855 tcintf1(spibus, selecttc1, unselect); |
henryeherman | 1:b0f7c49b67f8 | 46 | max31855 tcintf2(spibus, selecttc2, unselect); |
henryeherman | 1:b0f7c49b67f8 | 47 | max31855 tcintf3(spibus, selecttc3, unselect); |
henryeherman | 1:b0f7c49b67f8 | 48 | max31855 tcintf4(spibus, selecttc4, unselect); |
henryeherman | 1:b0f7c49b67f8 | 49 | max31855 tcintf5(spibus, selecttc5, unselect); |
henryeherman | 1:b0f7c49b67f8 | 50 | max31855 tcintf6(spibus, selecttc6, unselect); |
henryeherman | 1:b0f7c49b67f8 | 51 | max31855 tcintf7(spibus, selecttc7, unselect); |
henryeherman | 1:b0f7c49b67f8 | 52 | max31855 tcintf8(spibus, selecttc8, unselect); |
henryeherman | 1:b0f7c49b67f8 | 53 | |
henryeherman | 1:b0f7c49b67f8 | 54 | |
henryeherman | 1:b0f7c49b67f8 | 55 | // Valve Subsystem |
henryeherman | 1:b0f7c49b67f8 | 56 | DigitalOut valvrst(P2_7); |
henryeherman | 1:b0f7c49b67f8 | 57 | |
henryeherman | 1:b0f7c49b67f8 | 58 | mcp23s18 val0iomux(spibus, selectvalve0, unselect); |
henryeherman | 1:b0f7c49b67f8 | 59 | mcp23s18 val1iomux(spibus, selectvalve1, unselect); |
henryeherman | 1:b0f7c49b67f8 | 60 | mcp23s18 val2iomux(spibus, selectvalve2, unselect); |
henryeherman | 1:b0f7c49b67f8 | 61 | |
henryeherman | 1:b0f7c49b67f8 | 62 | void setup_valves() { |
henryeherman | 1:b0f7c49b67f8 | 63 | valvrst = 0; |
henryeherman | 1:b0f7c49b67f8 | 64 | valvrst = 1; |
henryeherman | 1:b0f7c49b67f8 | 65 | val0iomux.initialize(); |
henryeherman | 1:b0f7c49b67f8 | 66 | val1iomux.initialize(); |
henryeherman | 1:b0f7c49b67f8 | 67 | val2iomux.initialize(); |
henryeherman | 1:b0f7c49b67f8 | 68 | |
henryeherman | 1:b0f7c49b67f8 | 69 | val0iomux.set_all_output(); |
henryeherman | 1:b0f7c49b67f8 | 70 | val1iomux.set_all_output(); |
henryeherman | 1:b0f7c49b67f8 | 71 | val2iomux.set_all_output(); |
henryeherman | 1:b0f7c49b67f8 | 72 | |
henryeherman | 1:b0f7c49b67f8 | 73 | val0iomux.write_port(0); |
henryeherman | 1:b0f7c49b67f8 | 74 | val1iomux.write_port(0); |
henryeherman | 1:b0f7c49b67f8 | 75 | val2iomux.write_port(0); |
henryeherman | 1:b0f7c49b67f8 | 76 | } |
henryeherman | 1:b0f7c49b67f8 | 77 | |
henryeherman | 1:b0f7c49b67f8 | 78 | void set_valves(int id, int value) { |
henryeherman | 1:b0f7c49b67f8 | 79 | if(id == 0) { |
henryeherman | 1:b0f7c49b67f8 | 80 | val0iomux.write_port(value); |
henryeherman | 1:b0f7c49b67f8 | 81 | } else if(id == 1) { |
henryeherman | 1:b0f7c49b67f8 | 82 | val1iomux.write_port(value); |
henryeherman | 1:b0f7c49b67f8 | 83 | } else if(id == 2) { |
henryeherman | 1:b0f7c49b67f8 | 84 | val2iomux.write_port(value); |
henryeherman | 1:b0f7c49b67f8 | 85 | } |
henryeherman | 1:b0f7c49b67f8 | 86 | } |
henryeherman | 1:b0f7c49b67f8 | 87 | |
henryeherman | 1:b0f7c49b67f8 | 88 | |
henryeherman | 1:b0f7c49b67f8 | 89 | // Position Sensors Subsystem |
henryeherman | 1:b0f7c49b67f8 | 90 | mcp23s18 posiomux(spibus, selectpos, unselect); |
henryeherman | 1:b0f7c49b67f8 | 91 | DigitalOut posrst(P2_12); |
henryeherman | 1:b0f7c49b67f8 | 92 | |
henryeherman | 1:b0f7c49b67f8 | 93 | void setup_position_sensors() { |
henryeherman | 1:b0f7c49b67f8 | 94 | posrst = 0; |
henryeherman | 1:b0f7c49b67f8 | 95 | posrst = 1; |
henryeherman | 1:b0f7c49b67f8 | 96 | posiomux.initialize(); |
henryeherman | 1:b0f7c49b67f8 | 97 | posiomux.set_none_pullups(); |
henryeherman | 1:b0f7c49b67f8 | 98 | posiomux.set_all_input(); |
henryeherman | 1:b0f7c49b67f8 | 99 | } |
henryeherman | 1:b0f7c49b67f8 | 100 | |
henryeherman | 1:b0f7c49b67f8 | 101 | unsigned int read_poisition_sensors() { |
henryeherman | 1:b0f7c49b67f8 | 102 | return posiomux.read_port(); |
henryeherman | 1:b0f7c49b67f8 | 103 | } |
henryeherman | 1:b0f7c49b67f8 | 104 | |
henryeherman | 1:b0f7c49b67f8 | 105 | // Liquid Sensor Subsystem |
henryeherman | 1:b0f7c49b67f8 | 106 | mcp3208 liqadc(spibus, selectliq, unselect); |
henryeherman | 1:b0f7c49b67f8 | 107 | |
henryeherman | 1:b0f7c49b67f8 | 108 | void setup_elixys() { |
henryeherman | 1:b0f7c49b67f8 | 109 | setup_heater(); |
henryeherman | 1:b0f7c49b67f8 | 110 | setup_valves(); |
henryeherman | 1:b0f7c49b67f8 | 111 | setup_position_sensors(); |
henryeherman | 1:b0f7c49b67f8 | 112 | } |
henryeherman | 1:b0f7c49b67f8 | 113 | |
henryeherman | 1:b0f7c49b67f8 | 114 | #ifdef SYSTEMTEST |
henryeherman | 1:b0f7c49b67f8 | 115 | // System Tests |
henryeherman | 0:542583a6f6bb | 116 | |
henryeherman | 1:b0f7c49b67f8 | 117 | void fan_test() { |
henryeherman | 1:b0f7c49b67f8 | 118 | |
henryeherman | 1:b0f7c49b67f8 | 119 | fan1 = 1.0; |
henryeherman | 1:b0f7c49b67f8 | 120 | fan2 = 1.0; |
henryeherman | 1:b0f7c49b67f8 | 121 | fan0 = 1; |
henryeherman | 1:b0f7c49b67f8 | 122 | misc0 = 1; |
henryeherman | 1:b0f7c49b67f8 | 123 | |
henryeherman | 1:b0f7c49b67f8 | 124 | for(int i=0;i<5;i++) { |
henryeherman | 1:b0f7c49b67f8 | 125 | printf("FANTEST:%d\r\n", i); |
henryeherman | 1:b0f7c49b67f8 | 126 | for(float val=0.05;val<1.0;val=val+0.1) { |
henryeherman | 1:b0f7c49b67f8 | 127 | printf("FANVALUE:%f\r\n",val); |
henryeherman | 1:b0f7c49b67f8 | 128 | fan1 = val; |
henryeherman | 1:b0f7c49b67f8 | 129 | fan2 = val; |
henryeherman | 1:b0f7c49b67f8 | 130 | fan0 = !fan0; |
henryeherman | 1:b0f7c49b67f8 | 131 | misc0 = !misc0; |
henryeherman | 1:b0f7c49b67f8 | 132 | wait(0.05); |
henryeherman | 1:b0f7c49b67f8 | 133 | } |
henryeherman | 1:b0f7c49b67f8 | 134 | } |
henryeherman | 1:b0f7c49b67f8 | 135 | fan0 = 0; |
henryeherman | 1:b0f7c49b67f8 | 136 | misc0 = 0; |
henryeherman | 1:b0f7c49b67f8 | 137 | fan1 = 0.0; |
henryeherman | 1:b0f7c49b67f8 | 138 | fan2 = 0.0; |
henryeherman | 1:b0f7c49b67f8 | 139 | } |
henryeherman | 1:b0f7c49b67f8 | 140 | |
henryeherman | 1:b0f7c49b67f8 | 141 | void heater_test() { |
henryeherman | 1:b0f7c49b67f8 | 142 | setup_heater(); |
henryeherman | 1:b0f7c49b67f8 | 143 | printf("HEATERTEST\r\n"); |
henryeherman | 1:b0f7c49b67f8 | 144 | turn_on_heater(HEATER0); |
henryeherman | 1:b0f7c49b67f8 | 145 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 146 | turn_off_heater(HEATER0); |
henryeherman | 1:b0f7c49b67f8 | 147 | turn_on_heater(HEATER1); |
henryeherman | 1:b0f7c49b67f8 | 148 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 149 | turn_off_heater(HEATER1); |
henryeherman | 1:b0f7c49b67f8 | 150 | turn_on_heater(HEATER2); |
henryeherman | 1:b0f7c49b67f8 | 151 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 152 | turn_off_heater(HEATER2); |
henryeherman | 1:b0f7c49b67f8 | 153 | turn_on_heater(HEATER3); |
henryeherman | 1:b0f7c49b67f8 | 154 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 155 | turn_off_heater(HEATER3); |
henryeherman | 1:b0f7c49b67f8 | 156 | turn_on_heater(HEATER4); |
henryeherman | 1:b0f7c49b67f8 | 157 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 158 | turn_off_heater(HEATER4); |
henryeherman | 1:b0f7c49b67f8 | 159 | turn_on_heater(HEATER5); |
henryeherman | 1:b0f7c49b67f8 | 160 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 161 | turn_off_heater(HEATER5); |
henryeherman | 1:b0f7c49b67f8 | 162 | turn_on_heater(HEATER6); |
henryeherman | 1:b0f7c49b67f8 | 163 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 164 | turn_off_heater(HEATER6); |
henryeherman | 1:b0f7c49b67f8 | 165 | turn_on_heater(HEATER7); |
henryeherman | 1:b0f7c49b67f8 | 166 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 167 | turn_off_heater(HEATER7); |
henryeherman | 1:b0f7c49b67f8 | 168 | turn_on_heater(HEATER8); |
henryeherman | 1:b0f7c49b67f8 | 169 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 170 | turn_off_heater(HEATER8); |
henryeherman | 1:b0f7c49b67f8 | 171 | turn_on_heater(HTRLED0); |
henryeherman | 1:b0f7c49b67f8 | 172 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 173 | turn_off_heater(HTRLED0); |
henryeherman | 1:b0f7c49b67f8 | 174 | turn_on_heater(HTRLED1); |
henryeherman | 1:b0f7c49b67f8 | 175 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 176 | turn_off_heater(HTRLED2); |
henryeherman | 1:b0f7c49b67f8 | 177 | turn_on_heater(VAC); |
henryeherman | 1:b0f7c49b67f8 | 178 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 179 | turn_off_heater(VAC); |
henryeherman | 1:b0f7c49b67f8 | 180 | } |
henryeherman | 1:b0f7c49b67f8 | 181 | |
henryeherman | 1:b0f7c49b67f8 | 182 | void mixer_test() { |
henryeherman | 1:b0f7c49b67f8 | 183 | mtr0 = 1.0; |
henryeherman | 1:b0f7c49b67f8 | 184 | mtr1 = 1.0; |
henryeherman | 1:b0f7c49b67f8 | 185 | mtr2 = 1.0; |
henryeherman | 1:b0f7c49b67f8 | 186 | mtr3 = 1.0; |
henryeherman | 1:b0f7c49b67f8 | 187 | |
henryeherman | 1:b0f7c49b67f8 | 188 | for(int i=0;i<5;i++) { |
henryeherman | 1:b0f7c49b67f8 | 189 | printf("MIXERSTEST:%d\r\n", i); |
henryeherman | 1:b0f7c49b67f8 | 190 | for(float val=0.1;val<1.1;val=val+0.1) { |
henryeherman | 1:b0f7c49b67f8 | 191 | printf("MIXERVALUE:%f\r\n", val); |
henryeherman | 1:b0f7c49b67f8 | 192 | wait(0.05); |
henryeherman | 1:b0f7c49b67f8 | 193 | mtr0 = val; |
henryeherman | 1:b0f7c49b67f8 | 194 | mtr1 = val; |
henryeherman | 1:b0f7c49b67f8 | 195 | mtr2 = val; |
henryeherman | 1:b0f7c49b67f8 | 196 | mtr3 = val; |
henryeherman | 1:b0f7c49b67f8 | 197 | } |
henryeherman | 1:b0f7c49b67f8 | 198 | } |
henryeherman | 1:b0f7c49b67f8 | 199 | |
henryeherman | 1:b0f7c49b67f8 | 200 | mtr0 = 0.0; |
henryeherman | 1:b0f7c49b67f8 | 201 | mtr1 = 0.0; |
henryeherman | 1:b0f7c49b67f8 | 202 | mtr2 = 0.0; |
henryeherman | 1:b0f7c49b67f8 | 203 | mtr3 = 0.0; |
henryeherman | 1:b0f7c49b67f8 | 204 | } |
henryeherman | 1:b0f7c49b67f8 | 205 | |
henryeherman | 1:b0f7c49b67f8 | 206 | void smcadc_test() { |
henryeherman | 1:b0f7c49b67f8 | 207 | printf("SMCADCs|ADC0:0x%x,ADC1:0x%x\r\n", smcadc.readA(), smcadc.readB()); |
henryeherman | 1:b0f7c49b67f8 | 208 | } |
henryeherman | 1:b0f7c49b67f8 | 209 | |
henryeherman | 1:b0f7c49b67f8 | 210 | void smcdac_test() { |
henryeherman | 1:b0f7c49b67f8 | 211 | int ret; |
henryeherman | 1:b0f7c49b67f8 | 212 | smcdac.setGainA(2); |
henryeherman | 1:b0f7c49b67f8 | 213 | smcdac.setGainB(2); |
henryeherman | 1:b0f7c49b67f8 | 214 | for(int i = 0; i < 1024; i=i+16) { |
henryeherman | 1:b0f7c49b67f8 | 215 | ret = smcdac.writeA(i); |
henryeherman | 1:b0f7c49b67f8 | 216 | ret = smcdac.writeB(i); |
henryeherman | 1:b0f7c49b67f8 | 217 | wait(0.01); |
henryeherman | 1:b0f7c49b67f8 | 218 | printf("SMCDAC%d|ret%d\r\n", i, ret); |
henryeherman | 1:b0f7c49b67f8 | 219 | } |
henryeherman | 1:b0f7c49b67f8 | 220 | } |
henryeherman | 1:b0f7c49b67f8 | 221 | |
henryeherman | 1:b0f7c49b67f8 | 222 | int tc_test() { |
henryeherman | 1:b0f7c49b67f8 | 223 | float fvalue[9]; |
henryeherman | 1:b0f7c49b67f8 | 224 | fvalue[0] = tcintf0.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 225 | fvalue[1] = tcintf1.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 226 | fvalue[2] = tcintf2.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 227 | fvalue[3] = tcintf3.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 228 | fvalue[4] = tcintf4.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 229 | fvalue[5] = tcintf5.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 230 | fvalue[6] = tcintf6.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 231 | fvalue[7] = tcintf7.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 232 | fvalue[8] = tcintf8.read_temp(); |
henryeherman | 1:b0f7c49b67f8 | 233 | |
henryeherman | 1:b0f7c49b67f8 | 234 | stringstream res("THERMOCOUPLES|"); |
henryeherman | 1:b0f7c49b67f8 | 235 | for(int idx=0;idx<9;idx++) { |
henryeherman | 1:b0f7c49b67f8 | 236 | if (fvalue[idx] > 2000){ |
henryeherman | 1:b0f7c49b67f8 | 237 | if(fvalue[idx]==2001){ |
henryeherman | 1:b0f7c49b67f8 | 238 | res << "NoTC,"; |
henryeherman | 1:b0f7c49b67f8 | 239 | }else if(fvalue[idx]==2002){ |
henryeherman | 1:b0f7c49b67f8 | 240 | res << "ShrtGnd,"; |
henryeherman | 1:b0f7c49b67f8 | 241 | }else if(fvalue[idx]==2004){ |
henryeherman | 1:b0f7c49b67f8 | 242 | res << "ShrtVCC,"; |
henryeherman | 1:b0f7c49b67f8 | 243 | } |
henryeherman | 1:b0f7c49b67f8 | 244 | }else{ |
henryeherman | 1:b0f7c49b67f8 | 245 | res << fvalue[idx] << ","; |
henryeherman | 1:b0f7c49b67f8 | 246 | } |
henryeherman | 1:b0f7c49b67f8 | 247 | } |
henryeherman | 1:b0f7c49b67f8 | 248 | res << "\r\n"; |
henryeherman | 1:b0f7c49b67f8 | 249 | printf(res.str().c_str()); |
henryeherman | 1:b0f7c49b67f8 | 250 | return 0; |
henryeherman | 1:b0f7c49b67f8 | 251 | } |
henryeherman | 1:b0f7c49b67f8 | 252 | |
henryeherman | 1:b0f7c49b67f8 | 253 | void valve_test() { |
henryeherman | 1:b0f7c49b67f8 | 254 | setup_valves(); |
henryeherman | 1:b0f7c49b67f8 | 255 | for(int i=0;i<16;i++) { |
henryeherman | 1:b0f7c49b67f8 | 256 | printf("VALVEID:%d\r\n",i); |
henryeherman | 1:b0f7c49b67f8 | 257 | set_valves(0,(1<<i)); |
henryeherman | 1:b0f7c49b67f8 | 258 | set_valves(1,(1<<i)); |
henryeherman | 1:b0f7c49b67f8 | 259 | set_valves(2,(1<<i)); |
henryeherman | 1:b0f7c49b67f8 | 260 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 261 | } |
henryeherman | 1:b0f7c49b67f8 | 262 | |
henryeherman | 1:b0f7c49b67f8 | 263 | set_valves(0,0xFFFF); |
henryeherman | 1:b0f7c49b67f8 | 264 | set_valves(1,0xFFFF); |
henryeherman | 1:b0f7c49b67f8 | 265 | set_valves(2,0xFFFF); |
henryeherman | 1:b0f7c49b67f8 | 266 | printf("VALVES:AllOn\r\n"); |
henryeherman | 1:b0f7c49b67f8 | 267 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 268 | set_valves(0,0x0000); |
henryeherman | 1:b0f7c49b67f8 | 269 | set_valves(1,0x0000); |
henryeherman | 1:b0f7c49b67f8 | 270 | set_valves(2,0x0000); |
henryeherman | 1:b0f7c49b67f8 | 271 | printf("VALVESAllOff\r\n"); |
henryeherman | 1:b0f7c49b67f8 | 272 | wait(0.1); |
henryeherman | 1:b0f7c49b67f8 | 273 | } |
henryeherman | 1:b0f7c49b67f8 | 274 | |
henryeherman | 1:b0f7c49b67f8 | 275 | void position_sensor_test() { |
henryeherman | 1:b0f7c49b67f8 | 276 | printf("POSITIONSTATE:0x%x\r\n", posiomux.read_port()); |
henryeherman | 1:b0f7c49b67f8 | 277 | } |
henryeherman | 1:b0f7c49b67f8 | 278 | |
henryeherman | 1:b0f7c49b67f8 | 279 | void liquid_sensors_test() { |
henryeherman | 1:b0f7c49b67f8 | 280 | printf("LIQUIDSENSORS|ADC0:0x%x,ADC1:0x%x,ADC2:0x%x," |
henryeherman | 1:b0f7c49b67f8 | 281 | "ADC3:0x%x,ADC4:0x%x,ADC5:0x%x," |
henryeherman | 1:b0f7c49b67f8 | 282 | "ADC6:0x%x,ADC7:0x%x\r\n", |
henryeherman | 1:b0f7c49b67f8 | 283 | liqadc.read0(), |
henryeherman | 1:b0f7c49b67f8 | 284 | liqadc.read1(), |
henryeherman | 1:b0f7c49b67f8 | 285 | liqadc.read2(), |
henryeherman | 1:b0f7c49b67f8 | 286 | liqadc.read3(), |
henryeherman | 1:b0f7c49b67f8 | 287 | liqadc.read4(), |
henryeherman | 1:b0f7c49b67f8 | 288 | liqadc.read5(), |
henryeherman | 1:b0f7c49b67f8 | 289 | liqadc.read6(), |
henryeherman | 1:b0f7c49b67f8 | 290 | liqadc.read7()); |
henryeherman | 1:b0f7c49b67f8 | 291 | } |
henryeherman | 1:b0f7c49b67f8 | 292 | |
henryeherman | 1:b0f7c49b67f8 | 293 | void run_test() { |
henryeherman | 1:b0f7c49b67f8 | 294 | valve_test(); |
henryeherman | 1:b0f7c49b67f8 | 295 | tc_test(); |
henryeherman | 1:b0f7c49b67f8 | 296 | heater_test(); |
henryeherman | 1:b0f7c49b67f8 | 297 | mixer_test(); |
henryeherman | 1:b0f7c49b67f8 | 298 | fan_test(); |
henryeherman | 1:b0f7c49b67f8 | 299 | smcadc_test(); |
henryeherman | 1:b0f7c49b67f8 | 300 | smcdac_test(); |
henryeherman | 1:b0f7c49b67f8 | 301 | position_sensor_test(); |
henryeherman | 1:b0f7c49b67f8 | 302 | liquid_sensors_test(); |
henryeherman | 1:b0f7c49b67f8 | 303 | } |
henryeherman | 1:b0f7c49b67f8 | 304 | #endif |
henryeherman | 0:542583a6f6bb | 305 | } |