Support Controller
This commit is contained in:
@@ -1,26 +1,34 @@
|
||||
#pragma once
|
||||
#include <PSX/System/IOPorts/periphery_io.hpp>
|
||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/System/IOPorts/periphery_io.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void busy_loop(int count);
|
||||
|
||||
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);
|
||||
busy_loop(500);
|
||||
}
|
||||
|
||||
static void close_connection() {
|
||||
JOY_CTRL.write(JOY_CTRL::close());
|
||||
}
|
||||
|
||||
static void send_byte(uint8_t byte) {
|
||||
while(!JOY_STAT.read().is_ready_transfer());
|
||||
JOY_TX_DATA.write(JOY_TX_DATA::create(byte));
|
||||
}
|
||||
|
||||
static uint8_t read_byte() {
|
||||
while(!JOY_STAT.read().has_response());
|
||||
return JOY_RX_DATA.read().raw;
|
||||
}
|
||||
|
||||
static void acknowledge() {
|
||||
while(JOY_STAT.read().is_set(JOY_STAT::ACKIrqLow));
|
||||
JOY_CTRL.write(JOY_CTRL.read().set(JOY_CTRL::ACK));
|
||||
|
||||
Reference in New Issue
Block a user