![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ft. button press reset
Fork of BeaconDemo_RobotCode by
Diff: PsiSwarm/i2c.cpp
- Revision:
- 6:ff3c66f7372b
- Parent:
- 5:598298aa4900
- Child:
- 7:ef9ab01b9e26
--- a/PsiSwarm/i2c.cpp Tue Oct 13 11:47:14 2015 +0000 +++ b/PsiSwarm/i2c.cpp Thu Oct 22 00:46:14 2015 +0000 @@ -2,11 +2,12 @@ * * File: i2c.cpp * - * (C) Dr James Hilder, Dept. Electronics & Computer Science, University of York + * (C) Dept. Electronics & Computer Science, University of York + * James Hilder, Alan Millard, Homero Elizondo, Jon Timmis * - * PsiSwarm Library Version: 0.2 + * PsiSwarm Library Version: 0.3 * - * September 2015 + * October 2015 * */ @@ -152,6 +153,21 @@ system_warnings += 2; okay = 0; debug("- WARNING: No I2C acknowledge for main GPIO IC\n"); + if(HALT_ON_GPIO_ERROR){ + debug("- PROGRAM HALTED. Check that robot is switched on!\n"); + while(1){ + mbed_led1=1; + mbed_led2=1; + mbed_led3=0; + mbed_led4=0; + wait(0.25); + mbed_led1=0; + mbed_led2=0; + mbed_led3=1; + mbed_led4=1; + wait(0.25); + } + } } //Set all inputs to polarity-inverted (so a logic low = 1) data [0] = 0x04; //Write to polarity inversion ports @@ -192,7 +208,7 @@ debug("- WARNING: No I2C acknowledge for aux GPIO IC\n"); } data [0] = 0x06; //Write to GPPU register - data [1] = 0x0F; //Set GP0-3 as active pull-up outputs + data [1] = 0x3F; //Set GP0-3 as active pull-up outputs and P4,P5 as pull-up inputs primary_i2c.write(AUX_IC_ADDRESS,data,2,false); //My interrupt is not so reliable: poll with a 50ms timeout in case interrupts aren't handled @@ -200,6 +216,18 @@ //return ret_val; } +void IF_read_aux_ic_data() +{ + //Read the values of the input pins on the auxilliary GPIO expander + char write_data [1]; + char read_data [1]; + write_data[0] = 0x09; + primary_i2c.write(AUX_IC_ADDRESS,write_data,1,false); + primary_i2c.read(AUX_IC_ADDRESS,read_data,1,false); + + pc.printf("Aux IC Data:%X\n",read_data[0]); +} + void IF_parse_gpio_byte0(char byte) { gpio_byte0 = byte; @@ -240,6 +268,21 @@ if(USE_LED4_FOR_VR_WARNINGS){ mbed_led4 = (!power_good_motor_left || !power_good_motor_right || !power_good_infrared); } + //Halt the system if settings flag is set and all v-regs are bad [usually this means robot is switched off!] + if(HALT_ON_ALL_VREGS_LOW && !power_good_motor_left && !power_good_motor_right && !power_good_infrared){ + while(1){ + mbed_led1=1; + mbed_led2=0; + mbed_led3=1; + mbed_led4=0; + wait(0.25); + mbed_led1=0; + mbed_led2=1; + mbed_led3=0; + mbed_led4=1; + wait(0.25); + } + } } void IF_parse_gpio_byte1(char byte)