lots of fixes

This commit is contained in:
matthias@rpi 2023-10-28 03:48:27 +02:00
parent a63bd562d1
commit 4dbdbaf55d
7 changed files with 99 additions and 96 deletions

View File

@ -1,4 +0,0 @@
.build/test.o: test.s65 system/system.h65 system/io_W65C22.h65 utility.h65 /usr/share/cc65/asminc/longbranch.mac
test.s65 system/system.h65 system/io_W65C22.h65 utility.h65 /usr/share/cc65/asminc/longbranch.mac:

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
**.bin
**.o
.build
.dependencies

View File

@ -19,21 +19,22 @@ LDFLAGS = -C linker.conf
$(BUILD_DIR):
mkdir $@
.PHONY: default test clean
default: $(ROM)
test: ../test.bin
$(ROM): $(BUILD_DIR)/main.o
$(LD) $(LDFLAGS) $< -o $@
$(BUILD_DIR)/%.o: %.s65 $(BUILD_DIR)
$(ASM) $(ASMFLAGS) $(ASMDEPFLAGS) $< -o $@
.PHONY = test
test: ../test.bin
../test.bin: $(BUILD_DIR)/test.o
# $(VASM) -dotdir -opt-branch -wdc02 -chklabels test.asm6502
# $(ASM) $(ASMFLAGS) test.asm6502 -o test.o
$(LD) $(LDFLAGS) $(BUILD_DIR)/test.o -o ../test.bin
$(BUILD_DIR)/%.o: %.s65 | $(BUILD_DIR)
$(ASM) $(ASMFLAGS) $(ASMDEPFLAGS) $< -o $@
clean:
rm -r $(BUILD_DIR)
rm $(ROM)

View File

@ -1,6 +1,21 @@
.segment "CODE"
.include "system/system.h65"
;********************************************************************************
; Modules
;********************************************************************************
; LCD
; .include "utility.asm6502"
LCD_IO = IO1
.include "lcd.s65"
; Keypad Reading
KP_IO = IO1
.include "keypad.s65"
; Printer
.include "printer.s65"
; Digital Humidity and Temerature Sensor
; .include "dht.s65"
;********************************************************************************
; Interrupts
;********************************************************************************
@ -45,15 +60,15 @@ reset:
lda #%11111111
sta IO1 + IO_RANH
.endmacro
SET_DEBUG_LED_OFF
; SET_DEBUG_LED_OFF
jsr lcd_init
SET_DEBUG_LED_ON
.repeat 1000
nop
.endrepeat
SET_DEBUG_LED_OFF
; jsr kp_init
; .repeat 1000
; nop
; .endrepeat
; SET_DEBUG_LED_ON
jsr kp_init
; SET_DEBUG_LED_OFF
; ; INIT DHT
; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
@ -70,18 +85,20 @@ reset:
cli
.proc return_home
ldx #$00
@return_home:
lda menu,x
beq @return_home_done
sta TO_PRINT,x
inx
bra @return_home
@return_home_done:
jsr lcd_print_clear
Print message_menu
; @return_home:
; lda menu,x
; beq @return_home_done
; sta TO_PRINT,x
; jsr _lcd_char
; inx
; bra @return_home
; @return_home_done:
; jsr lcd_print_clear
.endproc
.proc home
; SET_DEBUG_LED_ON
jsr kb_read
beq home
cmp #'A'
@ -89,40 +106,37 @@ reset:
cmp #'B'
; jeq dht_request
cmp #'C'
beq print_1
jeq print_1
cmp #'D'
beq print_2
jeq print_2
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
beq return_home
bra home
; .repeat 500
; nop
; .endrepeat
; SET_DEBUG_LED_OFF
; .repeat 500
; nop
; .endrepeat
jmp home
.endproc
print_1:
ldx #$00
@print_1:
lda message_1,x
sta TO_PRINT,x
inx
bne @print_1
jsr lcd_print_clear
Print message_1
jmp home
print_2:
ldx #$00
@print_2:
lda message_2,x
sta TO_PRINT,x
inx
bne @print_2
jsr lcd_print_clear
Print message_2
jmp home
.segment "RODATA"
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) "
menu:
message_menu:
.byte "<A> Printer "
.byte "<B> Temperatur "
.byte "<C> Text 1 "
@ -130,20 +144,6 @@ menu:
.segment "CODE"
;********************************************************************************
; Modules
;********************************************************************************
; LCD
; .include "utility.asm6502"
LCD_IO = IO1
.include "lcd.s65"
; Keypad Reading
KP_IO = IO1
.include "keypad.s65"
; Printer
.include "printer.s65"
; Digital Humidity and Temerature Sensor
; .include "dht.s65"
;********************************************************************************
; reset vector
;********************************************************************************
.segment "RESET_VECTOR"

View File

@ -1,9 +1,10 @@
;********************************************************************************
; @module 4x4 Keypad
; @module keypad4x4
; @type driver
; @device 4x4 Matrix Keypad
; @details
; Keypad must be connected to a VIA
; The LCD must be connected to a W65C22N Interface Chip:
; - IO.RB0-7 ->
; @requires KP_IO: Base Address of IO Chip
; @depends IO-W65C22N
;********************************************************************************
@ -18,8 +19,8 @@ INCLUDE_KEYPAD = 1
; Keypad Buffer from $202 to $2ff
;********************************************************************************
KB_VAR = $00
KB_WRITE = $200
KB_READ = $201
KB_WRITE = $200 ; write pointer, relative to KB_WRITE
KB_READ = $201 ; read ponter, relative to KB_START
KB_START = $202
KB_LENGTH = $fd

View File

@ -3,14 +3,14 @@
; @type driver
; @device ELECTRONIC ASSEMBLY - W164B-NLW
; @details
; Assumes it is connected to a W65C22N Interface Chip:
; The LCD must be connected to a W65C22N Interface Chip:
; - IO.RB0-7 -> LCD.D0-7 data lines
; - IO.RA5 -> LCD.RS register select
; - IO.RA6 -> LCD.R/W read/write
; - IO.RA7 -> LCD.E enable
;
; @requires LCD_IO: Base Address of IO Chip
; @optparam LCD_MEM: Address to a block of memory 1B. Default = $300
; @optparam LCD_MEM: Memory address for a runtime variable. Default = $300
; @depends IO-W65C22N
;********************************************************************************
@ -37,14 +37,14 @@ LCD_RW = %01000000
LCD_RS = %00100000
; .local LCD_E,LCD_RW,LCD_RS
; LCD Instructions
; LCD Instructions (see datasheet for more)
LCD_CMD_CLEAR = %00000001 ; clear display
LCD_CMD_ENTRY_MODE = %00000110 ; auto-shift cursor
LCD_CMD_DISPLAY_ON = %00001111 ; everything on, with blinking cursor
LCD_CMD_FUNCTION_SET = %00111000 ; 8-bit, 4 lines, 5x7 font
LCD_CMD_SET_ADDRESS = %10000000 ; or with the address
; LCD Constants
LCD_LINE1 = $00 ; line 1
LCD_LINE1 = $00
LCD_LINE2 = $40
LCD_LINE3 = $10
LCD_LINE4 = $50
@ -61,9 +61,9 @@ LCD_CLEAR = %00000000
lda #$ff ; RB 0-7 output
sta LCD_IO+IO_DDRB
UT_update_with_mask LCD_IO + IO_DDRA, (LCD_RS | LCD_RW | LCD_E), (LCD_RS | LCD_RW | LCD_E)
; lda #(LCD_RS | LCD_RW | LCD_E) ; RA 5-7 output
; sta LCD_IO+IO_DDRA
; UT_update_with_mask LCD_IO + IO_DDRA, (LCD_RS | LCD_RW | LCD_E), (LCD_RS | LCD_RW | LCD_E)
lda #(LCD_RS | LCD_RW | LCD_E) ; RA 5-7 output
sta LCD_IO+IO_DDRA
; init lcd
lda #LCD_CMD_FUNCTION_SET
@ -82,39 +82,44 @@ LCD_CLEAR = %00000000
;********************************************************************************
; PRINTING TO LCD
;********************************************************************************
_lcd_clear: ; clear lcd
;********************************************************************************
; @function Clear the display
; @see lcd_print
;********************************************************************************
.proc lcd_clear
stz LCD_CHARCOUNT
lda #LCD_CLEAR
jsr _lcd_cmd
lda #(LCD_CMD_SET_ADDRESS | LCD_LINE1)
jsr _lcd_cmd
rts
;********************************************************************************
; @function Clear the display and print a null-terminated string
; @see lcd_print
;********************************************************************************
lcd_print_clear: ; clear lcd and print word located at message
stz LCD_CHARCOUNT
lda #LCD_CLEAR
jsr _lcd_cmd
lda #(LCD_CMD_SET_ADDRESS | LCD_LINE1)
jsr _lcd_cmd
.endproc
;********************************************************************************
; @function Print a null-terminated string
; @param ARG0-1 Address of the string to print
;********************************************************************************
lcd_print:
ldx #$00
_lcd_print_loop:
lda (ARG0,x)
beq _lcd_print_end
.proc lcd_print
ldy #$00
@lcd_print_loop:
lda ARG0,y
beq @lcd_print_end
jsr _lcd_char
inx
bra _lcd_print_loop
_lcd_print_end:
iny
bra @lcd_print_loop
@lcd_print_end:
rts
.endproc
.macro Print message
jsr lcd_clear
lda #.LOBYTE(message)
sta ARG0
lda #.HIBYTE(message)
sta ARG1
jsr lcd_print
.endmacro
;********************************************************************************
; LCD Commands
@ -138,7 +143,7 @@ _lcd_wait_nbusy:
sta LCD_IO + IO_DDRB
rts
_lcd_cmd: ; send cmd in acc
.proc _lcd_cmd ; send cmd in acc
pha
jsr _lcd_wait_nbusy
pla
@ -152,6 +157,7 @@ _lcd_cmd: ; send cmd in acc
lda #LCD_CLEAR
sta LCD_IO + IO_RA
rts
.endproc
_lcd_char:
pha
@ -173,7 +179,7 @@ _lcd_char:
;********************************************************************************
; Set the LCD DD-RAM Address so that text linebreaks after 16 chars
;********************************************************************************
_lcd_set_address:
.proc _lcd_set_address
; check if checks are necessary
lda LCD_CHARCOUNT
beq @lcd_line1
@ -209,3 +215,4 @@ _lcd_set_address:
lda #(LCD_CMD_SET_ADDRESS | LCD_LINE4)
jsr _lcd_cmd
rts
.endproc

View File

@ -13,14 +13,11 @@ INCLUDE_SYSTEM = 1
; 20-ff - free
; 0100 - 01FF Stack
; 0200,0201 keybuffer write/read pointer
; 0202 - 02ff keybuffer
; 0202-02ff keybuffer
; 0300 lcd character counter
; 0301 - 0341 message to print
; 0400, 0401, 0402 dht status, dht bit, dht_bit_rot
; 0403 value offset
; 0405 - 04a0 rh high/low, temp high/low, checksum
TO_PRINT = $300
; 0405-04a0 rh high/low, temp high/low, checksum
; ARGUMENTS
; a,x,y can also be used