From: Bernard Blackham Date: Sun, 10 Aug 2003 16:37:50 +0000 (+0000) Subject: Deprecating main.c & other functions in order to be a dumb terminal. X-Git-Tag: ROMW~78 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5266fabbd6d0e04a49e31b945b3f3c96fbd12db6;p=uccvend-snackrom.git Deprecating main.c & other functions in order to be a dumb terminal. This requires a remake of display.c because we don't have that much RAM to play with, so we can't hold a 256 byte buffer. --- diff --git a/ROM2/Makefile b/ROM2/Makefile index 440d4cf..b023d7d 100644 --- a/ROM2/Makefile +++ b/ROM2/Makefile @@ -1,9 +1,9 @@ # muchly stolen from m68hc1x's example.tar.gz's Makefile OBJS = \ - motors.o keypad.o display.o coinmech.o chime.o helpers.o server.o main.o \ + motors.o keypad.o display_basic.o coinmech.o chime.o helpers.o server.o main_basic.o \ vectors.o -INCLUDES = vend.h keypad.h chime.h asm.h display.h ports.h types.h +INCLUDES = vend.h keypad.h chime.h asm.h display_basic.h ports.h types.h CFLAGS = -O3 -m68hc11 -mshort -Wall -Os -g0 \ -msoft-reg-count=0 -ffixed-z diff --git a/ROM2/display.c b/ROM2/display.c index 84df86e..7da3b10 100644 --- a/ROM2/display.c +++ b/ROM2/display.c @@ -1,6 +1,10 @@ /* * display.c - functions for controlling the display on the vending machine. * + * + * XXX obsolted - with a backend on the server machine, we don't need to + * handle scrolling, etc here. Replaced by display_basic.[cho] + * * Use set_msg(char*) to write a new message to the screen, replacing the * previous one. The message can be at most 255 characters long. Use * set_wrap_mode with one of the WRAP_* options in vend.h to set the scrolling diff --git a/ROM2/display_basic.c b/ROM2/display_basic.c new file mode 100644 index 0000000..0526d2f --- /dev/null +++ b/ROM2/display_basic.c @@ -0,0 +1,51 @@ +/* + * display_basic.c - simple functions for writing to the screen of the vendie. + * + * Use set_msg(char[10]) to write a new message to the screen, replacing the + * previous one. + * + */ + +#include "display_basic.h" +#include "vend.h" + +/* private prototypes */ +void display_send_byte(char c); +void display_reset(); + +void set_msg(char newmsg[10]) { + int i; + display_reset(); + for (i=0; i < 10; i++) { + display_send_byte(newmsg[i]&0x7f); + } +} + +void display_send_byte(char c) { + bset_misc_output(A3800_DISPLAY_WRITE); /* enable the display clock */ + + _io_ports[M6811_SPDR] = c; /* load SPI with byte */ + while(!(_io_ports[M6811_SPDR]&M6811_SPIE)); /* wait for completion */ + _io_ports[M6811_SPDR]; /* SPDR read to clear SPIE flag */ +} + +#define DISPLAY_DELAY 100 /* ms to delay between ops - could be tweaked */ +void display_reset() { + /* lower the reset line for a while */ + bclr((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET); + delay(DISPLAY_DELAY); + bset((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET); + + spi_enable(); + delay(DISPLAY_DELAY); + + display_send_byte(0xC0 | 10); /* tell the controller there are 10 digits */ + display_send_byte(0xE0); /* set duty cycle to 100% */ + + spi_disable(); +} + +void display_init() { + display_reset(); +} + diff --git a/ROM2/display_basic.h b/ROM2/display_basic.h new file mode 100644 index 0000000..6d59d7c --- /dev/null +++ b/ROM2/display_basic.h @@ -0,0 +1,9 @@ +#ifndef _DISPLAY_H_ +#define _DISPLAY_H_ + +#include "types.h" + +void display_init(); +void set_msg(char newmsg[10]); + +#endif /* _DISPLAY_H_ */ diff --git a/ROM2/helpers.c b/ROM2/helpers.c index 0ef21cb..0f9f4db 100644 --- a/ROM2/helpers.c +++ b/ROM2/helpers.c @@ -1,4 +1,4 @@ -#include "display.h" +#include "display_basic.h" #include "vend.h" #define DELAY_MAGIC 20 /* FIXME: number of loops for ~ 1 millisecond (< 256) */ @@ -17,5 +17,5 @@ void print_amount(u16 amt) { for (pos = 7; amt; pos--, amt/=10) { str[pos] = amt%10 + '0'; } - set_msg(str, WRAP_NONE); + set_msg(str); } diff --git a/ROM2/main_basic.c b/ROM2/main_basic.c new file mode 100644 index 0000000..ea4da00 --- /dev/null +++ b/ROM2/main_basic.c @@ -0,0 +1,31 @@ +/* + * main_basic.c - a simplified main procedure that relies upon a ersver to do + * anything smart. Just be a dumb interface to a display, keypad, coin mech + * and snacks. + */ + +#include "display_basic.h" +#include "keypad.h" +#include "chime.h" +#include "server.h" +#include "coinmech.h" +#include "vend.h" + +void _start() { + set_bus_expanded(); + display_init(); + /* enable RTI & set rate */ + /* init coin mech */ + /* scan for motors */ + main(); +} + +int main() { + while(1) { + /* stuff */ + } +} + +void rti() { + chime(); /* turn chime on or off as need be */ +} diff --git a/ROM2/memory.x b/ROM2/memory.x index 267c073..b4431ba 100644 --- a/ROM2/memory.x +++ b/ROM2/memory.x @@ -11,9 +11,9 @@ Foundation; either version 2, or (at your option) any later version. MEMORY { - page0 (rwx) : ORIGIN = 0x0000, LENGTH = 0x00ff /* 256 bytes internal RAM */ +/* page0 (rwx) : ORIGIN = 0x0000, LENGTH = 0x00ff * 256 bytes internal RAM */ + data (rw) : ORIGIN = 0x0000, LENGTH = 0x00ff text (rx) : ORIGIN = 0x8000, LENGTH = 0x7fff - data (rw) : ORIGIN = 0x0800, LENGTH = 0x07ff /* 2k external SRAM FIXME - dont want to use this */ } /* Setup the stack on the top of the data internal ram (not used). */