X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fmotors.c;h=4bb216b273158616e047e2669a4ed9b1f1f2f223;hb=c99662693a4d79f65d406473647debbd33ec521e;hp=80a11a76d6b75cd4b4f61e4471986783c15b1097;hpb=11baa477da66fe8b2899dd50bd71d11615ff050e;p=uccvend-snackrom.git diff --git a/ROM2/motors.c b/ROM2/motors.c index 80a11a7..4bb216b 100644 --- a/ROM2/motors.c +++ b/ROM2/motors.c @@ -1,2 +1,50 @@ +#include "motors.h" #include "vend.h" +void motor_on(u8 slot) { + /* from jump34 */ +} + +void motors_off() { + bset_changer_output(A3000_MOTOR_ROW_ENABLE); /* XXX active low? */ + delay(10); /* XXX cf motors_off */ + bset((void*)&_io_ports[M6811_PORTA], PORTA_MOTOR_COL_DISABLE); + bclr_misc_output(A3800_MOTOR_COL8_ENABLE | A3800_MOTOR_COL9_ENABLE); +} + +bool motor_here(u8 slot) { + int i, c = 0; + motor_on(slot); + for (i=0; i < 8; i++) { + if (_io_ports[M6811_PORTE] & PORTE_MOTOR_OVERVOLTAGE) { + c++; + if (c == 0xff) { + motors_off(); + return 1; + } else + continue; + } + } + motors_off(); + return 0; +} + +bool is_motor(u8 slot) { + /* FIXME */ + return 1; +} + +u8 dispense_motor(u8 slot) { + if (!is_motor(slot)) { + return MOTOR_NOSLOT; + } + + motor_on(slot); + /* FIXME */ + return MOTOR_SUCCESS; +} + +void scan_motors() { + /* FIXME */ +} +