Lots of fixes.
[uccvend-snackrom.git] / ROM2 / motors.c
1 #include "motors.h"
2 #include "vend.h"
3
4 void motor_on(u8 slot) {
5         /* from jump34 */
6 }
7
8 void motors_off() {
9         bset_changer_output(A3000_MOTOR_ROW_ENABLE); /* XXX active low? */
10         delay(10); /* XXX cf motors_off */
11         bset((void*)&_io_ports[M6811_PORTA], PORTA_MOTOR_COL_DISABLE);
12         bclr_misc_output(A3800_MOTOR_COL8_ENABLE | A3800_MOTOR_COL9_ENABLE);
13 }
14
15 bool motor_here(u8 slot) {
16         int i, c = 0;
17         motor_on(slot);
18         for (i=0; i < 8; i++) {
19                 if (_io_ports[M6811_PORTE] & PORTE_MOTOR_OVERVOLTAGE) {
20                         c++;
21                         if (c == 0xff) {
22                                 motors_off();
23                                 return 1;
24                         } else
25                                 continue;
26                 }
27         }
28         motors_off();
29         return 0;
30 }
31
32 bool is_motor(u8 slot) {
33         /* FIXME */
34         return 1;
35 }
36
37 u8 dispense_motor(u8 slot) {
38         if (!is_motor(slot)) {
39                 return MOTOR_NOSLOT;
40         }
41
42         motor_on(slot);
43         /* FIXME */
44         return MOTOR_SUCCESS;
45 }
46
47 void scan_motors() {
48         /* FIXME */
49 }
50

UCC git Repository :: git.ucc.asn.au