Project

General

Profile

Revision 850

completed! beacons turn on but still need to test frequency...

View differences:

branches/autonomous_recharging/code/projects/libbayboard/homing.c
41 41
#include "orb.h"
42 42
#include "serial.h"
43 43

  
44
int state = 0;
44
volatile int state = 0;
45
volatile int orbstate = 0;
45 46

  
46 47
void IR_init(void){
47 48
  
49
  
48 50
  DDRA |= _BV(DDA0)|_BV(DDA1);
49 51
  DDRB |= _BV(DDB3);
50 52
  
51
  SEI();
53
  sei();
52 54

  
53 55
  TIMSK1 |= _BV(TOIE1);
54 56

  
......
58 60

  
59 61
  TCCR1A |= _BV(COM1B1)|_BV(COM1B0)|_BV(WGM11);	
60 62
  TCCR1B |= _BV(WGM13)|_BV(WGM12)|_BV(CS10);
61
  ICR1 |= 0x9C40;
63
  ICR1 = 0x9C40;
64
  orb_init();
62 65
  
63 66
  
64
  
65 67
}
66 68

  
67 69
ISR(TIMER1_OVF_vect){
68
  state = (state++)%4;
69
  PORTA = state;
70
  state = (state+1)%4;
71
  PORTA |= state;
72
  set_orb(255*orbstate, 255*orbstate, 255*orbstate);
73
  orbstate = (orbstate+1)%2;
70 74
  
71
  
72 75

  
73 76
}

Also available in: Unified diff