Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
main.c
Go to the documentation of this file.
1 #include<msp430g2553.h>
2 
3 #include <launchpad.h>
4 #include <Wrap.h>
5 
6 
7 int main()
8 {
9  /* Counting parameters */
10  volatile int counter = 0, endcount = 1000;
11  char ch;
12 
13 
14  desabWDT();
15  /* botao(); */
16  dco1mhz();
17  hserial();
18 
19  hled(VERM|VERD);
20  ligled(VERM);
21  //P1OUT ^= VERM;
22  /* Defined in Wrap.h */
23  int cmd;
24 
25  for(;;)
26  {
27  //P1OUT ^= VERM;
28  cmd = getchar();
29  switch(cmd)
30  {
31  case ALL_VALUES:
32  //printf("[%d,%d]\n", adc_read(0),adc_read(1));
33  break;
34  case 'a':
35  case BREAK_MSP:
36 
37  //dly_coxa(1000);
38 
39  ch = getchar();
40 
41  if((ch >= '0') && (ch <= '9'))
42  endcount = 1000 + (int) ((unsigned char) ch-'0')*10000/10;
43 
44  //if(counter >= endcount)
45  //{
46  counter = 0;
47  P1OUT ^= VERD;
48  //}
49  //else
50  //{
51  //counter++;
52  //}
53 
54 
55  /*
56  Read new value from serial
57  and use this value to set the
58  position of the servo motor
59  */
60  break;
61  case DIRECTION_MSP:
62  //printf("[%d]\n", adc_read(0));
63  break;
64  case VELOCITY_MSP:
65  //printf("[%d]\n", adc_read(0));
66  break;
67  default:
68  break;
69  }
70 
71 
72  if (counter >= endcount)
73  {
74  counter = 0;
75  P1OUT ^= VERM;
76  }
77  else
78  {
79  counter++;
80  }
81 
82  }
83 
84  return 0;
85 }
86 
int main()
Definition: main.c:7
#define ALL_VALUES
Definition: Wrap.h:19
void ligled(char numled)
Definition: launchpad.c:64
#define VELOCITY_MSP
Definition: Wrap.h:21
#define VERM
Definition: launchpad.h:13
void hled(unsigned char numled)
Enable LED.
Definition: launchpad.c:33
void hserial()
void dco1mhz()
Definition: launchpad.c:95
#define VERD
Definition: launchpad.h:14
char getchar()
void desabWDT()
Desable Watchdog.
Definition: launchpad.c:9
#define DIRECTION_MSP
Definition: Wrap.h:20