-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcp23s17_main.asm
44 lines (41 loc) · 1.25 KB
/
mcp23s17_main.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;--------------------------------
; MCP23S17 SPI
; example for one expander @ $40
;--------------------------------
; expander-labels
; set up your wires, port, etc.
;-------------------------------
!src "mcp23s17_cfg.asm"
!to "p4userport.prg",cbm
*= $1000
!byte $00,$0c,$10,$0a,$00,$9e,$34,$31,$35,$39,$00,$00,$00
; main
!src "mcp23s17_lbl.asm"
*=$103f
lda #$93 ; clear screen
jsr $ffd2
; init the expander(s)
lda expander_0 ; expander_0 : $40
sta chip
lda IOCON ; i/o config
sta register
lda #$08 ; hardware-addressing
sta value
jsr set_register ; (chip, register, value)
; set dir-register
lda IODIRA ; Port A
sta register
lda output ; to output
sta value
jsr set_register ; (chip, register, value)
; set byte on port
lda OLATA ; use latch A
sta register
lda #%10101010
sta value
jsr set_register ; (chip, register, value)
rts
;--------------------------------
; some lowlevel SPI-routines
!src "mcp23s17_macro.asm"
;--------------------------------