Initial go at pulling things together.
authorBernard Blackham <[email protected]>
Tue, 5 Aug 2003 15:10:08 +0000 (15:10 +0000)
committerBernard Blackham <[email protected]>
Tue, 5 Aug 2003 15:10:08 +0000 (15:10 +0000)
ROM2/Makefile [new file with mode: 0644]
ROM2/coinmech.c [new file with mode: 0644]
ROM2/display.c [new file with mode: 0644]
ROM2/helpers.c [new file with mode: 0644]
ROM2/keypad.c [new file with mode: 0644]
ROM2/motors.c [new file with mode: 0644]

diff --git a/ROM2/Makefile b/ROM2/Makefile
new file mode 100644 (file)
index 0000000..efec0a7
--- /dev/null
@@ -0,0 +1,11 @@
+CFLAGS = -g -O2 -Wall
+CC = m68hc11-gcc
+
+OBJS = motors.o keypad.o display.o coinmech.o helpers.o
+
+all: rom
+
+rom: $(OBJS)
+
+clean:
+       rm -f $(OBJS)
diff --git a/ROM2/coinmech.c b/ROM2/coinmech.c
new file mode 100644 (file)
index 0000000..80a11a7
--- /dev/null
@@ -0,0 +1,2 @@
+#include "vend.h"
+
diff --git a/ROM2/display.c b/ROM2/display.c
new file mode 100644 (file)
index 0000000..ee3e94b
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * display.c - functions for controlling the display on the vending machine.
+ *
+ * Use set_msg(char*) to write a new message to the screen, replacing the previous
+ * one. The message can be at most 1023 characters long. Use set_wrap_mode with
+ * one of the WRAP_* options in vend.h to set the scrolling behaviour. If the
+ * message is less than 10 characters, it is centered and is not scrolled.
+ * Otherwise, the message will scroll.
+ *
+ */
+
+
+#include "vend.h"
+
+char display_buffer[10];    /* what each byte on the display reads          */
+char current_message[1024]; /* message that is scrolled or switched between */
+u8   wrap_mode;             /* whether to scroll or alternate between msgs  */
+
+void set_msg(char* newmsg) {
+       char* dest = current_message;
+       /* while (dest++ = newmsg++); */
+       while (newmsg) {
+               dest = newmsg;
+               dest++;
+               newmsg++;
+       }
+}
+
+void __inline__ set_wrap_mode(u8 new_wrap_mode) {
+       /* in theory it should be inlined anyway? */
+       wrap_mode = new_wrap_mode;
+}
+
+void display_send_byte(u8 b) {
+       bset_3800(A3800_DISPLAY_WRITE);
+}
+
+#define DISPLAY_DELAY  100 /* ms to delay between ops - could be tweaked */
+void display_reset() {
+       /* lower the reset line for 100ms */
+       bclr(PORTA, PORTA_DISP_RESET);
+       delay(DISPLAY_DELAY);
+       bset(PORTA, PORTA_DISP_RESET);
+
+       /* enable the SPI */
+       bset(SPCR, SPCR_SPE);
+       delay(DISPLAY_DELAY);
+
+       /* tell the controller there are 10 digits */
+       
+}
+
+void display_refresh() {
+       display_reset();
+}
diff --git a/ROM2/helpers.c b/ROM2/helpers.c
new file mode 100644 (file)
index 0000000..283ca30
--- /dev/null
@@ -0,0 +1,45 @@
+#include "vend.h"
+
+/* some IO addresses require buffering, so we create some generic buffering
+ * functions here
+ */
+
+/* create port-specific #defines: */
+#define buffered_port(p) \
+       u8   addr_##p##_buffer = 0; \
+       \
+       void __inline__ outb_##p(u8 b) { \
+               addr_##p##_buffer = b; \
+               outb(p, b); \
+       } \
+       \
+       void __inline__ bset_##p(u8 mask) { \
+               bset((addr_t)&addr_##p##_buffer, mask); \
+               outb(p, addr_##p##_buffer); \
+       } \
+       \
+       void __inline__ bclr_##p(u8 mask) { \
+               bclr((addr_t)&addr_##p##_buffer, mask); \
+               outb(p, addr_##p##_buffer); \
+       } 
+
+void __inline__ outb(addr_t addr, u8 byte) {
+       /* FIXME hmmm */
+       /* asm? */
+}
+
+void __inline__ bset(addr_t addr, u8 mask) {
+       /* FIXME again. asm? */
+}
+
+void __inline__ bclr(addr_t addr, u8 mask) {
+       /* FIXME again. asm? */
+}
+
+void delay(u16 ms) {
+       /* FIXME fill me in */
+}
+
+/* ports declared here must be defined with buffered_port_h() in vend.h too */
+buffered_port(3800);
+
diff --git a/ROM2/keypad.c b/ROM2/keypad.c
new file mode 100644 (file)
index 0000000..80a11a7
--- /dev/null
@@ -0,0 +1,2 @@
+#include "vend.h"
+
diff --git a/ROM2/motors.c b/ROM2/motors.c
new file mode 100644 (file)
index 0000000..80a11a7
--- /dev/null
@@ -0,0 +1,2 @@
+#include "vend.h"
+

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