Add board-io, replace sevenseg in sw

This commit is contained in:
Byron Lathi
2022-03-18 01:27:55 +00:00
parent 63b942e29a
commit 5c32fe808e
10 changed files with 89 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -5,4 +5,7 @@ UART_TXB = UART
UART_RXB = UART
UART_STATUS = UART + 1
LED = $7ff6
SW = LED
IRQ_STATUS = $7fff

View File

@@ -4,7 +4,6 @@
#include "interrupt.h"
#include "uart.h"
#include "sevenseg.h"
char lastchar;

View File

@@ -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++)

View File

@@ -1,6 +1,6 @@
#include <stdio.h>
#include "sevenseg.h"
#include "board_io.h"
#include "uart.h"
#include "interrupt.h"