From: Bernard Blackham Date: Wed, 6 Aug 2003 08:06:44 +0000 (+0000) Subject: Splitting out headers X-Git-Tag: ROMW~104 X-Git-Url: https://git.ucc.asn.au/?p=uccvend-snackrom.git;a=commitdiff_plain;h=c9763dcb182398266bae1c6a7a848beec1cba35d Splitting out headers Getting assembly right --- diff --git a/ROM2/Makefile b/ROM2/Makefile index 6c77f24..7a4421e 100644 --- a/ROM2/Makefile +++ b/ROM2/Makefile @@ -6,7 +6,7 @@ OBJS = \ 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 \ diff --git a/ROM2/asm.h b/ROM2/asm.h new file mode 100644 index 0000000..0c9b7fa --- /dev/null +++ b/ROM2/asm.h @@ -0,0 +1,27 @@ +#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_ */ diff --git a/ROM2/display.c b/ROM2/display.c index 25edee8..45b39fc 100644 --- a/ROM2/display.c +++ b/ROM2/display.c @@ -34,7 +34,7 @@ void set_msg(char* newmsg) { 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; } @@ -50,9 +50,9 @@ void display_send_byte(char c) { #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); diff --git a/ROM2/display.h b/ROM2/display.h new file mode 100644 index 0000000..c9af212 --- /dev/null +++ b/ROM2/display.h @@ -0,0 +1,18 @@ +#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_ */ diff --git a/ROM2/helpers.c b/ROM2/helpers.c index 68adb3f..b44be32 100644 --- a/ROM2/helpers.c +++ b/ROM2/helpers.c @@ -4,23 +4,3 @@ void delay(u16 ms) { /* 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; -} diff --git a/ROM2/main.c b/ROM2/main.c index 9d59f60..188fef0 100644 --- a/ROM2/main.c +++ b/ROM2/main.c @@ -1,3 +1,4 @@ +#include "display.h" #include "vend.h" int main() { diff --git a/ROM2/types.h b/ROM2/types.h new file mode 100644 index 0000000..8746dcc --- /dev/null +++ b/ROM2/types.h @@ -0,0 +1,15 @@ +#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_ */ diff --git a/ROM2/vend.h b/ROM2/vend.h index aa6409d..9e01aaa 100644 --- a/ROM2/vend.h +++ b/ROM2/vend.h @@ -2,49 +2,30 @@ #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);