Extend Periphery code

This commit is contained in:
2024-01-02 19:47:23 -06:00
parent 32f7826c1d
commit fb20f8fe30
4 changed files with 81 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
#pragma once
#include <PSX/System/IOPorts/periphery_io.hpp>
#include <PSX/System/IOPorts/interrupt_io.hpp>
namespace JabyEngine {
namespace Periphery {
using namespace Periphery_IO;
static void busy_cycle(uint32_t cycles) {
while(cycles--) {
asm("");
}
}
static void connect_to(uint16_t port) {
JOY_CTRL.write(JOY_CTRL::create_for(port));
busy_cycle(500);
}
static void close_connection() {
JOY_CTRL.write(JOY_CTRL::close());
}
static void acknowledge() {
while(JOY_STAT.read().is_set(JOY_STAT::ACKIrqLow));
JOY_CTRL.write(JOY_CTRL.read().set(JOY_CTRL::ACK));
Interrupt::ack_irq(Interrupt::Periphery);
}
}
}