diff --git a/.settings/de.innot.avreclipse.core.prefs b/.settings/de.innot.avreclipse.core.prefs index bebeb81..70a5759 100644 --- a/.settings/de.innot.avreclipse.core.prefs +++ b/.settings/de.innot.avreclipse.core.prefs @@ -1,4 +1,4 @@ -#Fri Nov 25 16:20:41 PST 2011 +#Wed Dec 07 17:06:43 PST 2011 avrtarget/ClockFrequency=16000000 avrtarget/ExtRAMSize=0 avrtarget/ExtendedRAM=false @@ -11,7 +11,7 @@ avrtarget/avrdude/EEPROMFile= avrtarget/avrdude/EEPROMFromConfig=true avrtarget/avrdude/FlashFile= avrtarget/avrdude/FlashFromConfig=true -avrtarget/avrdude/Fuses/ByteValues=223\:210\:248 +avrtarget/avrdude/Fuses/ByteValues=223\:211\:248 avrtarget/avrdude/Fuses/FileName= avrtarget/avrdude/Fuses/MCUid=at90usb646 avrtarget/avrdude/Fuses/UseFile=false diff --git a/main.c b/main.c index 486f64d..d6e8a98 100644 --- a/main.c +++ b/main.c @@ -5,9 +5,51 @@ * Author: Doug */ +#include +#include +#include "tests/simm_electrical_test.h" + int main(void) { - while (1); + DDRD |= (1 << 7); + PORTD &= ~(1 << 7); + + int result = SIMMElectricalTest_Run(); + + if (result == 0) + { + while (1) + { + _delay_ms(200); + PIND = (1 << 7); + } + } + else + { + while (1) + { + int tmpResult = result; + + while (tmpResult) + { + int thisDigit = (tmpResult % 10) + 1; + + while (thisDigit--) + { + PIND = (1 << 7); + _delay_ms(500); + PIND = (1 << 7); + _delay_ms(500); + } + + _delay_ms(2000); + + tmpResult /= 10; + } + + _delay_ms(5000); + } + } return 0; } diff --git a/mcp23s17.c b/mcp23s17.c index f07ac03..1b2bc57 100644 --- a/mcp23s17.c +++ b/mcp23s17.c @@ -7,6 +7,7 @@ #include "mcp23s17.h" #include +#include #include static bool MCP23S17_Inited = false; @@ -89,6 +90,8 @@ void MCP23S17_Init() // so it won't activate during AVR ISP programming) PORTB |= MCP23S17_RESET; + _delay_ms(50); + // All done! MCP23S17_Inited = true; } diff --git a/tests/simm_electrical_test.c b/tests/simm_electrical_test.c index 318012c..238051d 100644 --- a/tests/simm_electrical_test.c +++ b/tests/simm_electrical_test.c @@ -9,13 +9,13 @@ #include "../ports.h" #include "../delay.h" -#define SIMM_HIGHEST_ADDRESS_LINE 18 +#define SIMM_HIGHEST_ADDRESS_LINE 20 #define SIMM_ADDRESS_PINS_MASK ((1UL << (SIMM_HIGHEST_ADDRESS_LINE + 1)) - 1) #define SIMM_HIGHEST_DATA_LINE 31 #define SIMM_DATA_PINS_MASK (0xFFFFFFFFUL) -#define DELAY_SETTLE_TIME_MS 5 +#define DELAY_SETTLE_TIME_MS 20 typedef enum ElectricalTestStage { @@ -34,6 +34,8 @@ int SIMMElectricalTest_Run(void) Ports_Init(); + DelayMS(DELAY_SETTLE_TIME_MS); + // First check for anything shorted to ground. Set all lines as inputs with a weak pull-up resistor. // Then read the values back and check for any zeros. This would indicate a short to ground. Ports_SetAddressDDR(0); diff --git a/tests/simm_electrical_test.h b/tests/simm_electrical_test.h index 15e3d3b..5111943 100644 --- a/tests/simm_electrical_test.h +++ b/tests/simm_electrical_test.h @@ -8,5 +8,6 @@ #ifndef SIMM_ELECTRICAL_TEST_H_ #define SIMM_ELECTRICAL_TEST_H_ +int SIMMElectricalTest_Run(void); #endif /* SIMM_ELECTRICAL_TEST_H_ */