Add rtc_set
This commit is contained in:
@@ -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
|
||||
@@ -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,19 @@ IRQ_THRESHOLD_3 = $00
|
||||
sta RTC_DAT
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
; void rtc_set(uint32_t val, uint8_t idx);
|
||||
.proc _rtc_set
|
||||
tay ; move cmd to Y
|
||||
ldx #$04
|
||||
L1: sty RTC_CMD ; store cmd+idx to CMD
|
||||
jsr popa ; pop 1 byte of argument
|
||||
sta RTC_DAT ; write it to data
|
||||
iny ; increase index
|
||||
dex
|
||||
bne L1 ; repeat 4 times
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user