Add driver for hex digits
This only includes the method to set the pairs of displays individually. The functions to write a single 16 or 32 bit value have not been implemented yet, nor has the mask function.
This commit is contained in:
@@ -1 +1 @@
|
||||
BB_SPI_BASE = $7ff0
|
||||
SEVEN_SEG = $7ff0
|
||||
|
||||
13
sw/main.c
13
sw/main.c
@@ -1,11 +1,12 @@
|
||||
#define SEVEN_SEG 0x7ff0
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int main() {
|
||||
uint16_t* seven_seg;
|
||||
seven_seg = (uint16_t*)SEVEN_SEG;
|
||||
#include "sevenseg.h"
|
||||
|
||||
*seven_seg = 0xbabe;
|
||||
int main() {
|
||||
//hex_enable(0xff);
|
||||
hex_set_8(0xb5, 0);
|
||||
hex_set_8(0x00, 1);
|
||||
hex_set_8(0xb0, 2);
|
||||
while(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
12
sw/sevenseg.h
Normal file
12
sw/sevenseg.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _SEVEN_SEG
|
||||
#define _SEVEN_SEG
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t hex_set_8(uint8_t val, uint8_t idx);
|
||||
uint8_t hex_set_16(uint16_t val);
|
||||
uint8_t hex_set_24(uint32_t val);
|
||||
|
||||
void hex_enable(uint8_t mask);
|
||||
|
||||
#endif
|
||||
39
sw/sevenseg.s
Normal file
39
sw/sevenseg.s
Normal file
@@ -0,0 +1,39 @@
|
||||
.include "io.inc65"
|
||||
|
||||
.export _hex_set_8
|
||||
.export _hex_set_16
|
||||
.export _hex_set_24
|
||||
.export _hex_enable
|
||||
|
||||
.autoimport on
|
||||
|
||||
.code
|
||||
|
||||
; @in A: idx Stack[0]: val
|
||||
; @out A: 0 for success, 1 for failure.
|
||||
; Sets one of the 3 pairs of hex digits.
|
||||
_hex_set_8:
|
||||
phx
|
||||
cmp #$3 ; If idx >= 3 then fail
|
||||
bcc @1
|
||||
lda #$1
|
||||
rts
|
||||
@1: tax ; Move idx into x
|
||||
jsr popa ; put val into a
|
||||
sta SEVEN_SEG,x ; write to val
|
||||
lda #$0
|
||||
plx
|
||||
rts
|
||||
|
||||
_hex_set_16:
|
||||
lda #$1
|
||||
rts
|
||||
|
||||
_hex_set_24:
|
||||
lda #$1
|
||||
rts
|
||||
|
||||
; @in A: mask
|
||||
; Set the mask for seven seg enables
|
||||
_hex_enable:
|
||||
rts
|
||||
Reference in New Issue
Block a user