Merge branch '16-realtime-clock-driver' into 'master'

Resolve "realtime clock driver"

Closes #16

See merge request bslathi19/super6502!62
This commit is contained in:
Byron Lathi
2023-12-02 07:15:50 +00:00
3 changed files with 28 additions and 0 deletions

View File

@@ -6,6 +6,12 @@
#define RTC_CMD_ADDR 0xeffe
#define RTC_DAT_ADDR 0xefff
#define RTC_THRESHOLD 0x00
#define RTC_INCREMENT 0x10
#define RTC_IRQ_THRESHOLD 0x20
#define RTC_OUTPUT 0x30
#define RTC_CONTROL 0x30
/* initialize RTC with default values */
void init_rtc(void);
@@ -13,4 +19,7 @@ void init_rtc(void);
void handle_rtc(void);
void rtc_set(uint32_t val, uint8_t idx);
#endif

View File

@@ -2,8 +2,11 @@
.importzp tmp1
.import popa
.export _init_rtc
.export _handle_rtc
.export _rtc_set
RTC_CMD = $effe
RTC_DAT = $efff
@@ -86,7 +89,20 @@ IRQ_THRESHOLD_3 = $00
sta RTC_DAT
rts
.endproc
; void rtc_set(uint32_t val, uint8_t idx);
.proc _rtc_set
sta tmp1 ; store idx in tmp1
ldx #$04
L1: lda tmp1
sta RTC_CMD ; store cmd+idx to CMD
jsr popa ; pop 1 byte of argument
sta RTC_DAT ; write it to data
inc tmp1 ; increase index
dex
bne L1 ; repeat 4 times
rts
.endproc

View File

@@ -36,6 +36,9 @@ int main() {
register_irq(&handle_rtc_interrupt, 0);
rtc_set(0xaaaa, RTC_THRESHOLD);
rtc_set(0xbbbb, RTC_IRQ_THRESHOLD);
asm volatile("cli");
// cputs("Initialize Serial\n");