# 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
/*
* 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
--- /dev/null
+/*
+ * 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();
+}
+
--- /dev/null
+#ifndef _DISPLAY_H_
+#define _DISPLAY_H_
+
+#include "types.h"
+
+void display_init();
+void set_msg(char newmsg[10]);
+
+#endif /* _DISPLAY_H_ */
-#include "display.h"
+#include "display_basic.h"
#include "vend.h"
#define DELAY_MAGIC 20 /* FIXME: number of loops for ~ 1 millisecond (< 256) */
for (pos = 7; amt; pos--, amt/=10) {
str[pos] = amt%10 + '0';
}
- set_msg(str, WRAP_NONE);
+ set_msg(str);
}
--- /dev/null
+/*
+ * 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 */
+}
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). */