INCLUDES = vend.h
-CFLAGS = -O2 -Wall -m68hc11 -mshort -Wall -Os -g0 \
+CFLAGS = -O3 -Wall -m68hc11 -mshort -Wall -Os -g0 \
-msoft-reg-count=0 -ffixed-z
LDFLAGS = -m68hc11 -mshort -Wl,-m,m68hc11elfb \
--- /dev/null
+#ifndef _ASM_H_
+#define _ASM_H_
+
+#include "types.h"
+
+/* these would be inline functions, but gcc won't believe that mask is a constant
+ * when passed as a parameter
+ */
+#define bset(addr, mask) \
+ asm volatile ( \
+ "ldx %0\n" \
+ "bset 00,x,%1" \
+ : /* outputs */ \
+ : "p" (addr), "i" (mask) /* inputs */ \
+ : "x" /* altered registers */ \
+ );
+
+#define bclr(addr, mask) \
+ asm volatile ( \
+ "ldx %0\n" \
+ "bclr 00,x,%1" \
+ : /* outputs */ \
+ : "p" (addr), "i" (mask) /* inputs */ \
+ : "x" /* altered registers */ \
+ );
+
+#endif /* _ASM_H_ */
display_update();
}
-inline void set_wrap_mode(u8 new_wrap_mode) {
+extern inline void set_wrap_mode(u8 new_wrap_mode) {
/* in theory it should be inlined anyway? */
wrap_mode = new_wrap_mode;
}
#define DISPLAY_DELAY 100 /* ms to delay between ops - could be tweaked */
void display_reset() {
/* lower the reset line for a while */
- _io_ports[M6811_PORTA] &= ~PORTA_DISP_RESET;
+ bclr(&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
delay(DISPLAY_DELAY);
- _io_ports[M6811_PORTA] |= PORTA_DISP_RESET;
+ bset(&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
spi_enable();
delay(DISPLAY_DELAY);
--- /dev/null
+#ifndef _DISPLAY_H_
+#define _DISPLAY_H_
+
+#include "types.h"
+
+/* scrolling modes */
+#define WRAP_SCROLL_L 1 /* scroll to the left */
+#define WRAP_SCROLL_R 2 /* scroll to the right */
+#define WRAP_ALTERNATE 3 /* alternate between text */
+
+extern char current_message[256];
+
+void display_init();
+void set_msg(char* newmsg);
+void set_wrap_mode(u8 new_wrap_mode);
+void display_refresh();
+
+#endif /* _DISPLAY_H_ */
/* FIXME fill me in */
}
-#define buffered_addr(a) \
- u8 a; \
- inline void set_##a(u8 b) { a = *_##a = b; } \
- inline void bset_##a(u8 m) { a |= m; *_##a = a; } \
- inline void bclr_##a(u8 m) { a &= ~m ; *_##a = a; }
-
-buffered_addr(switch_input)
-buffered_addr(misc_input)
-buffered_addr(home_sensors)
-buffered_addr(changer_output)
-buffered_addr(misc_output)
-
-
-inline void spi_enable() {
- _io_ports[M6811_SPCR] |= M6811_SPE;
-}
-
-inline void spi_disable() {
- _io_ports[M6811_SPCR] &= ~M6811_SPE;
-}
+#include "display.h"
#include "vend.h"
int main() {
--- /dev/null
+#ifndef _TYPES_H_
+#define _TYPES_H_
+
+/* FIXME: are these typedefs right for m68hc11-gcc? */
+typedef unsigned char u8;
+typedef signed char s8;
+typedef unsigned short u16;
+typedef signed short s16;
+typedef unsigned long u32;
+typedef signed long s32;
+typedef u8 bool;
+typedef u16 addr_t;
+
+
+#endif /* _TYPES_H_ */
#define _VEND_H_
#include "ports.h"
-
-/* FIXME: are these typedefs right for m68hc11-gcc? */
-typedef unsigned char u8;
-typedef signed char s8;
-typedef unsigned short u16;
-typedef signed short s16;
-typedef unsigned long u32;
-typedef signed long s32;
-typedef u8 bool;
-typedef u16 addr_t;
+#include "types.h"
+#include "asm.h"
/* addresses of these set at link time */
/* to add more addresses, define them here with buffered_addr_h, in helpers.c
* with buffered_addr, and also in LDFLAGS in the Makefile
*/
-#define buffered_addr_h(a) \
+#define buffered_addr(a) \
extern volatile u8* _##a; \
- extern inline void set_##a(u8 b); \
- extern inline void bset_##a(u8 m); \
- extern inline void bclr_##a(u8 m); \
-
-buffered_addr_h(switch_input);
-buffered_addr_h(misc_input);
-buffered_addr_h(home_sensors);
-buffered_addr_h(changer_output);
-buffered_addr_h(misc_output);
-
-void spi_enable();
-void spi_disable();
-
-/******* from display.c *******/
+ u8 a; \
+ extern inline void set_##a(u8 b) { a = *_##a = b; } \
+ extern inline void bset_##a(u8 m) { a |= m; *_##a = a; } \
+ extern inline void bclr_##a(u8 m) { a &= ~m ; *_##a = a; }
-/* scrolling modes */
-#define WRAP_SCROLL_L 1 /* scroll to the left */
-#define WRAP_SCROLL_R 2 /* scroll to the right */
-#define WRAP_ALTERNATE 3 /* alternate between text */
+buffered_addr(switch_input);
+buffered_addr(misc_input);
+buffered_addr(home_sensors);
+buffered_addr(changer_output);
+buffered_addr(misc_output);
-extern char current_message[256];
+extern inline void spi_enable() { _io_ports[M6811_SPCR] |= M6811_SPE; }
+extern inline void spi_disable() { _io_ports[M6811_SPCR] &= ~M6811_SPE; }
-void display_init();
-void set_msg(char* newmsg);
-void set_wrap_mode(u8 new_wrap_mode);
-void display_refresh();
+/******* from helpers.c *******/
void delay(u16 ms);