diff options
author | Guillaume Knispel <gknispel@avencall.com> | 2012-07-05 19:56:13 +0200 |
---|---|---|
committer | Guillaume Knispel <gknispel@avencall.com> | 2012-07-05 19:56:13 +0200 |
commit | f77d27191ba4e81e90de283bc7bfd01a2c7ed6e6 (patch) | |
tree | 0c5d46ddb6c146b24f5ddc0dd041a9d371f72da0 /main.c | |
parent | 4313826dd3fbb0bc7424b7f2abcc383d3fd7688d (diff) |
multiple cleanups
Remove main.h (content moved in main.c)
Declare InitPorts and GlobalInit as static.
Move definition of states inside main.c, because reading the switch body
is essential to understand some constraints on their values.
Use stdint and stdbool.
Lower case U8 and U16 (so they are named like in Linux) and change their
definition to use uintX_t. Remove other unused typedefs.
Differentiate the platform headers by including them with <>.
Our own headers are included with "".
Remove some empty lines to increase the coherency of vertical indentation.
Diffstat (limited to 'main.c')
-rw-r--r--[-rwxr-xr-x] | main.c | 53 |
1 files changed, 37 insertions, 16 deletions
@@ -1,9 +1,10 @@ /* - * XIOHV5.12 power up & down sequence + * XIOHV5.12 power sequence * Copyright (C) 2012 Avencall * Authors: * Jean Marc Ouvrard * Noe Rubinstein + * Guillaume Knispel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,19 +20,29 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "main.h" +#include <stdbool.h> -volatile U16 Timer1; -volatile U16 SW1State, SW2State; +#include <io430.h> +#include <intrinsics.h> + +#include "def.h" +#include "hardware.h" + +static void InitPorts(void); +static void GlobalInit(void); + +volatile u16 Timer1; +volatile u16 SW1State; +volatile u16 SW2State; #ifdef CAN_WAIT_TENSION //has to be coded on real board -volatile U8 bV1P0 = true; -volatile U8 bV1P2 = true; -volatile U8 bV1P8_DDR = true; -volatile U8 bV2P5 = true; -volatile U8 bVCC3 = true; +volatile u8 bV1P0 = true; +volatile u8 bV1P2 = true; +volatile u8 bV1P8_DDR = true; +volatile u8 bV2P5 = true; +volatile u8 bVCC3 = true; #define TENSION_EXPIRED (SW1State || Timer1 == 0) #define TENSION_WAIT(t) (t) @@ -43,11 +54,23 @@ volatile U8 bVCC3 = true; #endif +#define STOP 10 +#define WAIT_START 20 +#define WAIT_ATX_OK 30 +#define WAIT_V1P0 40 +#define WAIT_V1P2 50 +#define WAIT_V1P8 60 +#define WAIT_RSMRST 70 +#define CK410_VTT_GD 80 +#define CPU_RUN 90 +#define WAIT_STOP 100 + int main(void) { - U16 state; + u16 state; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset + __disable_interrupt(); InitPorts(); @@ -64,8 +87,8 @@ int main(void) break; case WAIT_START + 1: // wait for release SW1 before real Start if (SW1State == 0) { - SetBit(P4OUT, CMDPWR); // Set Atx Power Supply - Timer1 = 2000; // set Timer1 @ 2 seconde + SetBit(P4OUT, CMDPWR); // Start Atx Power Supply + Timer1 = 2000; state = WAIT_ATX_OK; } break; @@ -164,7 +187,6 @@ int main(void) ClrBit(P2OUT, RED_LED_N); // To show no restart is possible for now state = STOP + 1; break; - case STOP + 1: InitPorts(); if (Timer1 == 0) { @@ -179,7 +201,6 @@ int main(void) #pragma vector = TIMERA1_VECTOR __interrupt void Timer_A(void) { - if (!(P1IN & START_SW1_N)) SW1State++; else @@ -194,7 +215,7 @@ __interrupt void Timer_A(void) Timer1--; } -void InitPorts(void) +static void InitPorts(void) { /* DIR: direction: 0 input 1 output * SEL: function: 0 gpio @@ -230,7 +251,7 @@ void InitPorts(void) } -void GlobalInit(void) +static void GlobalInit(void) { DCOCTL = CALDCO_12MHZ; BCSCTL1 = CALBC1_12MHZ; |