Project

General

Profile

Revision 802

Added by Brad Neuman over 13 years ago

fixed test code

View differences:

branches/autonomous_recharging/code/projects/autonomous_recharging/archs/test/main.c
5 5

  
6 6
#define LED_GREEN PB4 //Green
7 7
#define LED_RED PB5 //Red
8
#define INT_COUNT 2
8
#define INT_COUNT 8
9 9

  
10 10
#define LED1 PB4 //Green
11 11
#define LED2 PB5 //Red
......
34 34

  
35 35

  
36 36
int interrupt_count=INT_COUNT;
37
int red=0;
38
int green=0;
37
volatile int red=0;
38
volatile int green=0;
39
volatile char blink=0;
39 40

  
40 41
//copied from Charging.c
41 42
void setup(void)
......
60 61
}
61 62

  
62 63

  
63
void blink_red() {
64
void blink_red(void) {
64 65
  red=2;
65
  while(red);
66
  while(red>0);
66 67
}
67 68

  
68
void blink_green() {
69
void blink_green(void) {
69 70
  green=2;
70
  while(green);
71
  while(green>0);
71 72
}
72 73

  
73
void blink_long() {
74
  red=6;
75
  green=6;
74
void blink_long(void) {
75
  blink=1;
76 76
  while(red || green);
77 77
}
78 78

  
79 79

  
80 80
int main(void) {
81
  setup();
82
  
81 83
  blink_red();
82 84
  blink_green();
83 85
  blink_long();
84 86

  
87
  while(1);
88

  
85 89
  return 0;
86 90
}
87 91

  
......
91 95
	interrupt_count--;
92 96
	if(interrupt_count==0)
93 97
	{
94
	  //should be every second
98

  
99
	  if(blink)
100
	    PORTB ^= _BV(LED_RED) | _BV(LED_GREEN);
101

  
95 102
	  if(red>0) {
96 103
	    PORTB ^= _BV(LED_RED);
97 104
	    red--;

Also available in: Unified diff