Cleanups
authorBernard Blackham <[email protected]>
Fri, 15 Aug 2003 08:14:21 +0000 (08:14 +0000)
committerBernard Blackham <[email protected]>
Fri, 15 Aug 2003 08:14:21 +0000 (08:14 +0000)
ROM2/16550.c [deleted file]
ROM2/16550.h [deleted file]
ROM2/Makefile
ROM2/main.c [deleted file]
ROM2/main_basic.c
ROM2/server.c [deleted file]
ROM2/server.h [deleted file]
ROM2/vend.h

diff --git a/ROM2/16550.c b/ROM2/16550.c
deleted file mode 100644 (file)
index c29e9dd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-
-#include "16550.h"
-#include "vend.h"
-
-
-
diff --git a/ROM2/16550.h b/ROM2/16550.h
deleted file mode 100644 (file)
index e7e0263..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _16550_H_
-#define _16550_H_
-
-#include "vend.h"
-
-/* Must be accessed with DLAB low */
-#define UART_RX_BUF       0x00 /* read  */
-#define UART_TX_BUF       0x00 /* write */
-#define UART_INT_ENABLE   0x01
-#define UART_INT_IDENT    0x02 /* read  */
-#define UART_FIFO_CTL     0x02 /* write */
-#define UART_LINE_CTL     0x03
-#define UART_MODEM_CTL    0x04
-#define UART_LINE_STATUS  0x05
-#define UART_MODEM_STATUS 0x06
-#define UART_SCRATCH      0x07
-
-/* Same addresses as above, but accessed with DLAB high */
-#define UART_DLAB_LSB     0x00
-#define UART_DLAB_MSB     0x01
-
-extern volatile u8 _uart_regs[]; /* UART registers - fixed at link time */
-
-#endif /* _16550_H_ */
index a7fd90d..672ee38 100644 (file)
@@ -2,8 +2,8 @@
 
 OBJS = \
        motors.o keypad.o display_basic.o coinmech.o chime.o \
-       helpers.o server.o main_basic.o comm.o \
-       vectors.o
+       helpers.o main_basic.o comm.o \
+       vectors.o start.o
 INCLUDES = vend.h keypad.h chime.h asm.h display_basic.h ports.h types.h
 
 CFLAGS = -O3 -m68hc11 -mshort -Wall -Os -g0 \
diff --git a/ROM2/main.c b/ROM2/main.c
deleted file mode 100644 (file)
index 81919f0..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-#include "display.h"
-#include "keypad.h"
-#include "chime.h"
-#include "server.h"
-#include "coinmech.h"
-#include "vend.h"
-
-u16 uid;
-u16 pin;
-u8 selection;
-
-u16 scroll_timer;
-
-bool uid_enter() {
-       u8 uidpos;
-       /* the user has started to type in his/her UID. grab the last key and continue
-        * reading. Returns true if a UID was entered successfully.
-        * The UID will be entered as 5 digits. (shorter uids should be pre-padded
-        * with zeros)
-        */
-       uid = last_key%10; /* 10 => 0, it was _not_ reset (hopefuly :) */
-       set_msg("UID?      ", WRAP_NONE);
-       set_char((last_key%10)+'0', 5);
-
-       for (uidpos = 2; uidpos <= 5; uidpos++) {
-               keypad_getkey();
-               if (last_key == KEY_RESET) {
-                       uid = 0;
-                       return 0;
-               }
-               uid = (uid*10) + (last_key%10);
-               set_char((last_key%10)+'0', 4+uidpos);
-       }
-       return (uid!=0);
-}
-
-bool pin_enter() {
-       u8 pinpos;
-       /* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number.
-        * Strictly, they must be 16-bit, but it's easier to use the guarantee that
-        * 4-digits numbers are < 65536
-        *
-        * Also display X's on screen as the pin is entered.
-        */
-       pin = 0;
-       set_msg("PIN?      ", WRAP_NONE);
-       for (pinpos = 1; pinpos <= 4; pinpos++) {
-               keypad_getkey();
-               if (last_key == KEY_RESET) {
-                       pin = 0;
-                       return 0;
-               }
-               pin = (pin*10) + (last_key%10);
-               set_char('X', 4+pinpos);
-       }
-       return 1;
-}
-
-void make_request(u8 selection) {
-       set_msg("REQUESTING", WRAP_NONE); /* XXX: maybe this isn't needed? */
-       switch(server_request(uid, pin, selection)) {
-               case REQUEST_OK:
-                       set_msg("THANK YOU!", WRAP_NONE);
-                       break;
-               case REQUEST_NO_MONEY:
-                       set_msg("NO MONEY!", WRAP_NONE);
-                       break;
-               case REQUEST_SERVFAIL:
-                       set_msg("SERV FAIL!", WRAP_NONE);
-                       break;
-               case REQUEST_EMPTY:
-                       set_msg("NONE LEFT!", WRAP_NONE);
-                       break;
-               case REQUEST_INVAL:
-                       set_msg(" BAD SELN ", WRAP_NONE);
-                       break;
-       }
-       delay(1000);
-}
-
-void selection_menu() {
-       /* we have a valid username & PIN number */
-       /* either ask for a 2-digit selection, or wait for coins to be entered */
-       /* get the username somehow? */
-       set_msg("ENTER SELECTION OR INSERT COINS  ", WRAP_SCROLL);
-       selection = 0;
-       while(1) {
-               if (coin_value) { /* we have coins inserted */
-                       int prev_coin = 0;
-                       /* alternate between the price and a confirm message */
-                       while (coin_value) {
-                               if (prev_coin != coin_value) {
-                                       print_amount(coin_value);
-                                       append_msg("0: CONFIRM", WRAP_ALTERNATE);
-                                       prev_coin = coin_value;
-                               }
-                               keypad_read();
-                               if (keypad_pressed()) {
-                                       switch (last_key) {
-                                               case KEY_RESET:
-                                                       scroll_msg("PRESS COIN REFUND");
-                                                       while (coin_value);
-                                                       break;
-                                               case KEY_0:
-                                                       switch (server_credit_account(uid, pin, coin_value)) {
-                                                               case CREDIT_OK:
-                                                                       coin_eat();
-                                                                       set_msg(" SUCCESS! ", WRAP_NONE);
-                                                                       delay(1000);
-                                                                       break;
-                                                               case CREDIT_FAIL:
-                                                                       set_msg(" FAILED!  " "PRESS COIN" "  REFUND  ",
-                                                                                       WRAP_ALTERNATE);
-                                                                       while (coin_value);
-                                                                       break;
-                                                       }
-                                                       break;
-                                       }
-                               }
-                       }
-                       /* coins were refunded */
-               }
-
-               if (selection) { /* half way through a selection */
-                       keypad_read();
-                       if (keypad_pressed()) {
-                               switch (last_key) {
-                                       case KEY_RESET:
-                                               selection = 0;
-                                               break;
-                                       case 0:
-                                               break;
-                                       default:
-                                               selection = selection * 10 + (last_key%10);
-                                               make_request(selection);
-                                               selection = 0;
-                               }
-                       }
-               } else { /* else listen for the first key of a selection */
-                       keypad_read();
-                       if (keypad_pressed()) {
-                               switch (last_key) {
-                                       case KEY_RESET:
-                                               return;
-                                       case 0:
-                                               break;
-                                       default:
-                                               selection = last_key%10;
-                               }
-                       }
-               }
-       }
-}
-
-void load_default_msg() {
-       /* FIXME: want this message to be changeable from the server */
-       set_msg("UNIVERSITY COMPUTER CLUB *** INSERT COINS OR USER-ID *** ",
-                       WRAP_SCROLL);
-}
-
-void service_menu() {
-       while (door_open()) { /* don't quit until door is closed */
-
-       }
-}
-
-int main() {
-       /* do stuff */
-       set_msg("UNIVERSITY", WRAP_NONE);
-       delay(1000);
-       set_msg(" COMPUTER ", WRAP_NONE);
-       delay(1000);
-       set_msg("   CLUB   ", WRAP_NONE);
-       delay(1000);
-
-       load_default_msg();
-       while(1) {
-               /* this needs to be a relatively tight loop to make sure we catch
-                * keypresses at the main menu
-                */
-               keypad_read();
-               if (keypad_pressed()) {
-                       if (last_key != KEY_RESET) {
-                               if (uid_enter() && pin_enter()) {
-                                       /* authenticate them */
-                                       switch (server_authenticate(uid, pin)) {
-                                               case AUTH_GOOD:
-                                                       selection_menu();
-                                                       break;
-                                               case AUTH_BAD:
-                                                       set_msg(" BAD USER ", WRAP_NONE);
-                                                       delay(1000);
-                                                       break;
-                                               case AUTH_NO_MONEY:
-                                                       set_msg(" NO MONEY ", WRAP_NONE);
-                                                       delay(1000);
-                                                       break;
-                                               case AUTH_LOCKED:
-                                                       set_msg("YOUR ACCOUNT IS LOCKED", WRAP_SCROLL);
-                                                       delay(1000);
-                                                       break;
-                                       }
-                               }
-                               uid = 0;
-                               pin = 0;
-                               /* move on */
-                       }
-                       load_default_msg();
-               }
-
-               /* test door switch   */
-               if (door_open()) {
-                       service_menu();
-                       load_default_msg();
-               }
-
-               /* check on coin mech */
-       }
-}
-
-void _start() {
-       /* Initialize Stuff.  Particularly some memory locations that can only be
-        * written in the first 64 clock cycles upon reset.
-        */
-       display_init();
-       set_bus_expanded();
-       /* enable RTI & set rate */
-       /* init coin mech */
-       main();
-}
-
-void rti() {
-       chime(); /* turn chime on or of as need be */
-
-       /* scroll the display if need be too */
-       if (scroll_timer == 0) {
-               display_shift();
-               scroll_timer = SCROLL_TIME;
-       }
-       scroll_timer--;
-}
index ff8687b..006e5cb 100644 (file)
 #include "comm.h"
 #include "vend.h"
 
-extern inline void enable_rti() {
-}
-
-void _start() {
-       set_bus_expanded();
-       /* enable RTI */
-       _io_ports[M6811_TMSK2] = 0x40;
-       /* powerup ADC, set IRQ' for edge-sensitive operation */
-       _io_ports[M6811_OPTION] = 0xA0;
-       /* set the stack pointer */
-       //asm volatile ("lds %1":: "i"(_stack):"sp");
-
-       main();
-
-loop_forever:
-       goto loop_forever; /* wait for an interrupt to wake us up again */
-}
-
 int main() {
        u16 last_coin_value = coin_value;
 
diff --git a/ROM2/server.c b/ROM2/server.c
deleted file mode 100644 (file)
index 554e070..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "display.h"
-#include "server.h"
-
-u8 server_authenticate(u16 uid, u16 pin) {
-       set_msg("VERIFYING ", WRAP_NONE);
-       /* send msgs to server and stuff */
-       return AUTH_GOOD; /* for now */
-}
-
-u8 server_credit_account(u16 uid, u16 pin, u16 amt) {
-       return CREDIT_OK;
-       /* alternatively credit fail? */
-}
-
-u8 server_request(u16 uid, u16 pin, u8 item) {
-       /* send a message to the server asking for item */
-       return REQUEST_OK;
-}
diff --git a/ROM2/server.h b/ROM2/server.h
deleted file mode 100644 (file)
index 7b118cb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _SERVER_H_
-#define _SERVER_H_
-
-#define AUTH_GOOD      1
-#define AUTH_BAD      -1
-#define AUTH_NO_MONEY -2  /* for balances < $0 */
-#define AUTH_LOCKED   -3
-
-#define CREDIT_OK      1
-#define CREDIT_FAIL    -1
-
-#define REQUEST_OK        1
-#define REQUEST_NO_MONEY -1 /* insufficient credit */
-#define REQUEST_SERVFAIL -2 /* server did not respond */
-#define REQUEST_EMPTY    -3 /* none of item left */
-#define REQUEST_INVAL    -4 /* no such item */
-
-u8 server_authenticate(u16 uid, u16 pin);
-u8 server_request(u16 uid, u16 pin, u8 item);
-u8 server_credit_account(u16 uid, u16 pin, u16 amt);
-
-#endif /* _SERVER_H_ */
index 9c3fe65..ea079b4 100644 (file)
@@ -58,7 +58,6 @@ void my_memcpy(char* dst, char* src, u8 size);
 #define A3800_MOTOR_COL9_ENABLE 0x40
 
 /******* from main.c *******/
-void __attribute__((noreturn)) _start (void);
 int __attribute__((noreturn)) main (void);
 void __attribute__((interrupt)) rti (void);
 void __attribute__((interrupt)) sci_interrupt (void);

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