Project

General

Profile

Revision 1255

renamed the _encoders files to _dynamos

View differences:

trunk/code/projects/diagnostic_station/station/hardware_encoders.c
1
#include "hardware_dynamos.h"
2

  
3
volatile int16_t count_l=0, count_r=0;
4

  
5

  
6
void encoders_init ()
7
{
8
  //enable pin change interrupts 4 and 5 (correspond to DIO2 and DIO3)
9
  //to trigger on both edges
10
  cli();
11
  EICRB = _BV(ISC40) | _BV(ISC50);
12
	EIMSK = _BV(INT4) | _BV(INT5);
13
  sei();
14
  
15
  //enable the 5V switching regulator to power the dynamos
16
  DDRB |= _BV(PB4);
17
  PORTB &= ~_BV(PB4);
18

  
19
}
20

  
21
void dynamos_reset (void)
22
{
23
  SYNC
24
  {
25
    count_l = 0;
26
    count_r = 0;
27
  }
28
}
29

  
30
ISR(INT4_vect)
31
{
32
  uint8_t temp = PINE;
33
  
34
  if(((temp&_BV(PE4))>>2)^(temp&_BV(PE2)))
35
    count_l--;
36
  else
37
    count_l++;
38
}
39

  
40
ISR(INT5_vect)
41
{
42
  uint8_t temp = PINE;
43
  
44
  if(((temp&_BV(PE5))>>2)^(temp&_BV(PE3)))
45
    count_r++;
46
  else
47
    count_r--;
48
}
49

  
50

  
51
void dynamos_read (int16_t *left, int16_t *right)
52
{
53
  SYNC
54
  {
55
	*left= count_l;
56
    *right = count_r;
57
  }
58
}
59

  
trunk/code/projects/diagnostic_station/station/hardware_encoders.h
1
#ifndef _hardware_dynamos_h
2
#define _hardware_dynamos_h
3

  
4
#include <dragonfly_lib.h>
5
#include "global.h"
6

  
7
void dynamos_init (void);
8

  
9
void dynamos_read (int16_t *left, int16_t *right);
10
void dynamos_reset (void);
11

  
12
#endif
trunk/code/projects/diagnostic_station/station/hardware_turntable.c
1 1
#include "hardware_turntable.h"
2
#include <encoders.h>
2 3

  
3 4
void turntable_init ()
4 5
{
5
	// FIXME implement
6
  encoders_init();
6 7
}
7 8

  
8
void turntable_rotate_to_position (uint16_t position)
9
void turntable_rotate_to_position (int16_t position)
9 10
{
10
	usb_puts ("# Turntable rotating to ");
11
	usb_puti (position);
12
	usb_puts (NL);
11
  usb_puts ("# Turntable rotating to ");
12
  usb_puti (position);
13
  usb_puts (NL);
13 14
	
14
	// FIXME implement
15
  // FIXME implement
15 16
	
16
	usb_puts ("# Turntable position reached" NL);
17
  usb_puts ("# Turntable position reached" NL);
17 18
}
18 19

  
19 20
uint16_t turntable_get_position (void)
20 21
{
21
	// FIXME implement
22

  
23
	return 42;
22
  //TODO: convert units
23
  return encoder_read(RIGHT);
24 24
}
trunk/code/projects/diagnostic_station/station/hardware_turntable.h
5 5
#include "global.h"
6 6

  
7 7
void turntable_init (void);
8
void turntable_rotate_to_position (uint16_t position);
8
/*
9
 * position: 10 bit angle, 0 is facing directly in to the station
10
 *     positive numbers are counterclockwise looking down on the robot
11
 */
12
void turntable_rotate_to_position (int16_t position);
9 13
uint16_t turntable_get_position (void);
10 14

  
11 15
#endif
trunk/code/projects/diagnostic_station/station/hardware_dynamos.c
1
#include "hardware_dynamos.h"
2

  
3
volatile int16_t count_l=0, count_r=0;
4

  
5

  
6
void dynamos_init (void)
7
{
8
  //enable pin change interrupts 4 and 5 (correspond to DIO2 and DIO3)
9
  //to trigger on both edges
10
  cli();
11
  EICRB = _BV(ISC40) | _BV(ISC50);
12
	EIMSK = _BV(INT4) | _BV(INT5);
13
  sei();
14
  
15
  //enable the 5V switching regulator to power the dynamos
16
  DDRB |= _BV(PB4);
17
  PORTB &= ~_BV(PB4);
18

  
19
}
20

  
21
void dynamos_reset (void)
22
{
23
  SYNC
24
  {
25
    count_l = 0;
26
    count_r = 0;
27
  }
28
}
29

  
30
ISR(INT4_vect)
31
{
32
  uint8_t temp = PINE;
33
  
34
  if(((temp&_BV(PE4))>>2)^(temp&_BV(PE2)))
35
    count_l--;
36
  else
37
    count_l++;
38
}
39

  
40
ISR(INT5_vect)
41
{
42
  uint8_t temp = PINE;
43
  
44
  if(((temp&_BV(PE5))>>2)^(temp&_BV(PE3)))
45
    count_r++;
46
  else
47
    count_r--;
48
}
49

  
50

  
51
void dynamos_read (int16_t *left, int16_t *right)
52
{
53
  SYNC
54
  {
55
	*left= count_l;
56
    *right = count_r;
57
  }
58
}
59

  
trunk/code/projects/diagnostic_station/station/hardware_dynamos.h
1
#ifndef _hardware_dynamos_h
2
#define _hardware_dynamos_h
3

  
4
#include <dragonfly_lib.h>
5
#include "global.h"
6

  
7
void dynamos_init (void);
8

  
9
void dynamos_read (int16_t *left, int16_t *right);
10
void dynamos_reset (void);
11

  
12
#endif

Also available in: Unified diff