diff options
author | Guillaume Knispel <gknispel@avencall.com> | 2012-07-09 16:37:34 +0200 |
---|---|---|
committer | Guillaume Knispel <gknispel@avencall.com> | 2012-07-09 16:37:34 +0200 |
commit | 3711f682f7baf279c242b92ed7e1fb3357ef9609 (patch) | |
tree | 7c965e07b06bbdc58dd63cc5fd62265029e64a2a | |
parent | 9603a96ae87212c2759ace4ea10c4213782fc308 (diff) |
remove/add comments
-rwxr-xr-x[-rw-r--r--] | hardware.h | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | main.c | 60 |
2 files changed, 44 insertions, 29 deletions
diff --git a/hardware.h b/hardware.h index 99e7334..56b8782 100644..100755 --- a/hardware.h +++ b/hardware.h @@ -67,11 +67,22 @@ PxOUT_INIT //Init Output data of portx PxDIR_INIT //Init of Portx Data-Direction Reg (Out=1 / Inp=0) PxSEL_INIT //Px-Modules: -PxREN_INIT // Pull up resistor +PxREN_INIT //Pull up resistor PxIE_INIT //Interrupt Enable (0=dis 1=enabled) PxIES_INIT //Interrupt Edge Select (0=pos 1=neg) */ +// NOTES: +// +// * V1P2_CORE_EN_N is initialized as an output high for a reason! +// +// ATX specifies that there can be as much as 20 ms between 5V reaching +// its 95% level and 3.3V doing likewise. U5H1 (ISL6545) is powered by +// 5V and Q5U1, that disables it, has a pull-up 3.3V on its gate. +// ISL6545 can ramp up its output between ~ 10 and 17 ms (and might +// do it even before) after Power On Reset. + + // PORT1 #define P1OUT_INIT (START_SW1_N | RST_SW2_N | V1P2_CORE_EN_N) #define P1DIR_INIT (V1P2_CORE_EN_N) @@ -82,10 +82,10 @@ int main(void) while (1) { switch (state) { case WAIT_START: - if (SW1State > 30) // SW1 pressed for at least 30ms + if (SW1State > 30) state = WAIT_START + 1; break; - case WAIT_START + 1: // wait for release SW1 before real Start + case WAIT_START + 1: if (SW1State == 0) { SetBit(P4OUT, CMDPWR); // Start Atx Power Supply Timer1 = 2000; @@ -95,13 +95,12 @@ int main(void) case WAIT_ATX_OK: if (SW1State || TENSION_EXPIRED) - state = STOP; // if SW1 just pressed during power or ATX didn't set up - // ATX power OK, stop + state = STOP; if ((P4IN & ATX_PWROK) && TENSION_WAIT(bV2P5 && bVCC3)) { - // atx power Ok & V2P5 Ok - SetBit(P1DIR, V1P2_CORE_EN_N); // enable V1P2 (V1P2_CORE_EN_N go from - // Hz to Out Low) - Timer1 = 30; // set Timer1 @ 30 milli seconde to get V1P2 stable + // assertion: V1P2_CORE_EN_N is low but high impedance here + // TO CHECK + SetBit(P1DIR, V1P2_CORE_EN_N); + Timer1 = 30; state = WAIT_V1P2; } break; @@ -109,9 +108,9 @@ int main(void) case WAIT_V1P2: if (SW1State || TENSION_EXPIRED) state = STOP; - if (TENSION_WAIT(bV1P2)) { // Got V1P2 stable - Timer1 = 30; // set Timer1 @ 30 milli seconde to get V1P8-DDR stable - SetBit(P4OUT, V1P8_CMD); // enable V1P8-DDR + if (TENSION_WAIT(bV1P2)) { + Timer1 = 30; + SetBit(P4OUT, V1P8_CMD); state = WAIT_RSMRST; } break; @@ -130,8 +129,8 @@ int main(void) if (SW1State || TENSION_EXPIRED) state = STOP; if (TENSION_WAIT(bV1P8)) { - ClrBit(P2OUT, CPU_VCCP_EN_N); // enable V1P0 - Timer1 = 30; // set Timer1 @ 30 milli seconde to get V1P0 stable + ClrBit(P2OUT, CPU_VCCP_EN_N); + Timer1 = 30; state = WAIT_V1P0; } break; @@ -139,51 +138,56 @@ int main(void) case WAIT_V1P0: if (SW1State || TENSION_EXPIRED) state = STOP; - if (TENSION_WAIT(bV1P0)) { // Got V1P0 stable and all other supplies too + if (TENSION_WAIT(bV1P0)) { SetBit(P3OUT, VRMPWRGD); - ClrBit(P2OUT, GREEN_LED_N); // set GREEN_LED_N to show Power Seq Ok - Timer1 = 3; // set Timer1 @ 3ms instead of 2 before assserted - // CK410_PWR_GD_N Low + ClrBit(P2OUT, GREEN_LED_N); + Timer1 = 3; state = CK410_VTT_GD; } break; case CK410_VTT_GD: if (Timer1 == 0) { - SetBit(P2DIR, CK410_PWR_GD_N); // asssert CK410_PWR_GD_N As output - ClrBit(P2OUT, CK410_PWR_GD_N); // asssert CK410_PWR_GD_N Low - Timer1 = 300; // set Timer1 @ 300 ms before starting Tolapai + SetBit(P2DIR, CK410_PWR_GD_N); + ClrBit(P2OUT, CK410_PWR_GD_N); + Timer1 = 300; state = CPU_RUN; } break; case CPU_RUN: - if (SW1State) // if SW1 just pressed during power up go STOP + if (SW1State) state = STOP; if (Timer1 == 0) { - SetBit(P2DIR, IMCH_PWRBTN_N); // Start Tolapai - Timer1 = 200; // pour relācher le bouton comme un humain + // Start Tolapai: emulate the power button from its point of view + // we don't really know where is the best place to do that so + // we will try it here at first. + SetBit(P2DIR, IMCH_PWRBTN_N); + Timer1 = 200; state = CPU_RUN + 1; } break; case CPU_RUN + 1: - if (SW1State) // if SW1 just pressed during power up go STOP + if (SW1State) state = STOP; if (Timer1 == 0) { - ClrBit(P2DIR, IMCH_PWRBTN_N); // Release IMCH-PWRBTN-N signal after 200 - // milli-secondes + ClrBit(P2DIR, IMCH_PWRBTN_N); state = WAIT_STOP; } break; case WAIT_STOP: - if (SW1State >= 6000) // Sw1 button press for more than 6 secondes + if (SW1State >= 6000) // Sw1 button pressed for more than 6 secondes state = STOP; break; case STOP: InitPorts(); - Timer1 = 10000; // set Timer1 @ 10s before any other Power up + Timer1 = 10000; // Disable any other Power up for 10s. + // We are very careful at first but we know no reason why this should + // not work with an extremely lower timer. Under some conditions ATX + // imposes debouncing up to at least 100 ms. I guess a good compromise + // would be somewhere between 0.5 to 1s. ClrBit(P2OUT, RED_LED_N); // To show no restart is possible for now state = STOP + 1; break; |