Add board-io, replace sevenseg in sw
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef _SEVEN_SEG
|
||||
#define _SEVEN_SEG
|
||||
#ifndef _BOARD_IO_H
|
||||
#define _BOARD_IO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -9,4 +9,8 @@ uint8_t hex_set_24(uint32_t val);
|
||||
|
||||
void hex_enable(uint8_t mask);
|
||||
|
||||
uint8_t sw_read();
|
||||
|
||||
void led_set(uint8_t val);
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
.export _hex_set_16
|
||||
.export _hex_set_24
|
||||
.export _hex_enable
|
||||
.export _sw_read
|
||||
.export _led_set
|
||||
|
||||
.autoimport on
|
||||
|
||||
@@ -52,4 +54,18 @@ _hex_set_24:
|
||||
; Set the mask for seven seg enables
|
||||
_hex_enable:
|
||||
sta SEVEN_SEG+3
|
||||
rts
|
||||
|
||||
; @out A: The Value of the switches
|
||||
; Reads the current values of the switches.
|
||||
_sw_read:
|
||||
lda SW
|
||||
ldx #$0
|
||||
rts
|
||||
|
||||
; @in A: val
|
||||
; @out A: 0 for success, 1 for failure
|
||||
; Sets the LEDs
|
||||
_led_set:
|
||||
sta LED
|
||||
rts
|
||||
@@ -5,4 +5,7 @@ UART_TXB = UART
|
||||
UART_RXB = UART
|
||||
UART_STATUS = UART + 1
|
||||
|
||||
LED = $7ff6
|
||||
SW = LED
|
||||
|
||||
IRQ_STATUS = $7fff
|
||||
|
||||
1
sw/irq.c
1
sw/irq.c
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "interrupt.h"
|
||||
#include "uart.h"
|
||||
#include "sevenseg.h"
|
||||
|
||||
char lastchar;
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include <stdint.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "sevenseg.h"
|
||||
#include "board_io.h"
|
||||
#include "uart.h"
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
uint8_t sw;
|
||||
char s[16];
|
||||
s[15] = 0;
|
||||
|
||||
@@ -13,6 +14,10 @@ int main() {
|
||||
cprintf("Hello, world!\n");
|
||||
|
||||
while (1) {
|
||||
|
||||
sw = sw_read();
|
||||
led_set(sw);
|
||||
|
||||
cscanf("%15s", s);
|
||||
cprintf("\n");
|
||||
for (i = 0; i < 16; i++)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sevenseg.h"
|
||||
#include "board_io.h"
|
||||
#include "uart.h"
|
||||
#include "interrupt.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user