Project

General

Profile

Revision 351481ed

ID351481edc9d802e0e4f70dd828c84a305e3951b5
Parent f4a85021
Child 1af81271

Added by Thomas Mullins almost 11 years ago

Finished paintboard code except for metal detector

View differences:

paintboard/code/Makefile
1
SRC = main.c twi.c motor.c servo.c
2
HDR = twi.h motor.h servo.h
1
SRC = main.c twi.c motor.c servo.c sol.c
2
HDR = twi.h motor.h servo.h sol.h
3 3

  
4 4
paint: paint.hex
5 5
	@
paintboard/code/main.c
1 1
#include "twi.h"
2 2
#include "motor.h"
3
#include "servo.h"
4
#include "sol.h"
3 5
#include <avr/io.h>
4 6
#include <avr/interrupt.h>
5 7

  
......
46 48
      internal_data[internal_index] = value;
47 49
      switch (internal_index) {
48 50
        case PAINT_MOTOR_A:
49
          /* ...TODO... */
51
          set_motor1(value);
50 52
          break;
51 53
        case PAINT_MOTOR_B:
52
          /* ...TODO... */
54
          set_motor2(value);
53 55
          break;
54 56
        case PAINT_SERVO_A:
55
          /* ...TODO... */
57
          set_servo1(value);
56 58
          break;
57 59
        case PAINT_SERVO_B:
58
          /* ...TODO... */
60
          set_servo2(value);
59 61
          break;
60 62
        case PAINT_12V_1:
61
          /* ...TODO... */
63
          set_sol1(value);
62 64
          break;
63 65
        case PAINT_12V_2:
64
          /* ...TODO... */
66
          set_sol2(value);
65 67
          break;
66 68
        case PAINT_12V_3:
67
          /* ...TODO... */
69
          set_sol3(value);
68 70
          break;
69 71
        case PAINT_12V_4:
70
          /* ...TODO... */
72
          set_sol4(value);
71 73
          break;
72 74
      }
73 75
    }
paintboard/code/sol.c
1
#include "sol.h"
2
#include <avr/io.h>
3

  
4
void sol_init() {
5
  DDRD |= _BV(DDD7);
6
  DDRB |= _BV(DDB7) | _BV(DDB6) | _BV(DDB0);
7
}
8

  
9
void set_sol1(char on) {
10
  if (on)
11
    PORTD |= _BV(PD7);
12
  else
13
    PORTD &= ~_BV(PD7);
14
}
15

  
16
void set_sol2(char on) {
17
  if (on)
18
    PORTB |= _BV(PB0);
19
  else
20
    PORTB &= ~_BV(PB0);
21
}
22

  
23
void set_sol3(char on) {
24
  if (on)
25
    PORTB |= _BV(PB6);
26
  else
27
    PORTB &= ~_BV(PB6);
28
}
29

  
30
void set_sol4(char on) {
31
  if (on)
32
    PORTB |= _BV(PB7);
33
  else
34
    PORTB &= ~_BV(PB7);
35
}
paintboard/code/sol.h
1
#ifndef SOL_H
2
#define SOL_H
3

  
4
void sol_init();
5
void set_sol1(char on);
6
void set_sol2(char on);
7
void set_sol3(char on);
8
void set_sol4(char on);
9

  
10
#endif

Also available in: Unified diff