IO initial states are correct
This commit is contained in:
34
lib/serial.c
Normal file
34
lib/serial.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <serial.h>
|
||||
|
||||
static serial_context ctx;
|
||||
|
||||
serial_context *serial_get_context() {
|
||||
return &ctx;
|
||||
};
|
||||
|
||||
void serial_init() {
|
||||
ctx.serial_control = 0x7E;
|
||||
ctx.serial_data = 0;
|
||||
}
|
||||
|
||||
void serial_write(u16 address, u8 value) {
|
||||
if(address == 0xFF01) {
|
||||
ctx.serial_data = value;
|
||||
return;
|
||||
}
|
||||
|
||||
if(address == 0xFF02) {
|
||||
ctx.serial_control = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
u8 serial_read(u16 address) {
|
||||
if(address == 0xFF01) {
|
||||
return ctx.serial_data;
|
||||
}
|
||||
|
||||
if(address == 0xFF02) {
|
||||
return ctx.serial_control;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user