diff options
Diffstat (limited to 'main.c')
-rwxr-xr-x[-rw-r--r--] | main.c | 60 |
1 files changed, 32 insertions, 28 deletions
@@ -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; |