Cleanup code
This commit is contained in:
parent
7b1cefac0a
commit
297526e4d0
|
@ -31,7 +31,7 @@ namespace JabyEngine {
|
|||
static constexpr auto CounterTargetValue = BitRange<uint32_t>::from_to(0, 15);
|
||||
};
|
||||
|
||||
struct __no_align Timer {
|
||||
struct __no_align TimerInfo {
|
||||
IOPort<uint32_t> value;
|
||||
IOPort<CounterMode> mode;
|
||||
IOPort<CounterTarget> target;
|
||||
|
@ -39,6 +39,10 @@ namespace JabyEngine {
|
|||
uint32_t _unused[1];
|
||||
};
|
||||
|
||||
static constexpr uintptr_t counter_base_adr(size_t ID) {
|
||||
return (0x1F801100 + (ID*0x10));
|
||||
}
|
||||
|
||||
namespace Counter0 {
|
||||
struct SyncMode {
|
||||
static constexpr auto Pause_During_Hblank = CounterMode::SyncMode.with(0);
|
||||
|
@ -53,6 +57,8 @@ namespace JabyEngine {
|
|||
static constexpr auto System_Clock_Too = CounterMode::ClockSource.with(2);
|
||||
static constexpr auto Dot_Clock_Too = CounterMode::ClockSource.with(3);
|
||||
};
|
||||
|
||||
__declare_io_port_global_struct(TimerInfo, Timer, counter_base_adr(0));
|
||||
}
|
||||
|
||||
namespace Counter1 {
|
||||
|
@ -69,6 +75,8 @@ namespace JabyEngine {
|
|||
static constexpr auto System_Clock_Too = CounterMode::ClockSource.with(2);
|
||||
static constexpr auto Hblank_Too = CounterMode::ClockSource.with(3);
|
||||
};
|
||||
|
||||
__declare_io_port_global_struct(TimerInfo, Timer, counter_base_adr(1));
|
||||
}
|
||||
|
||||
namespace Counter2 {
|
||||
|
@ -85,10 +93,9 @@ namespace JabyEngine {
|
|||
static constexpr auto System_Clock_Div_8 = CounterMode::ClockSource.with(2);
|
||||
static constexpr auto System_Clock_Div_8_Too = CounterMode::ClockSource.with(3);
|
||||
};
|
||||
}
|
||||
|
||||
__declare_io_port_global_array(Timer, Counter, 0x1F801100, 3);
|
||||
static_assert(sizeof(Timer) == 0x10);
|
||||
__declare_io_port_global_struct(TimerInfo, Timer, counter_base_adr(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ static __always_inline void __syscall_ChangeClearPad(int32_t _reserved) {
|
|||
__syscall_function_cast(__syscall_Table_B, void(*)(int32_t))(_reserved);
|
||||
}
|
||||
|
||||
static __always_inline void __syscall_ReturnFromException() {
|
||||
static __always_inline void [[noreturn]] __syscall_ReturnFromException() {
|
||||
register uint32_t FuncID asm("t1") = 0x17;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
|
|
|
@ -31,16 +31,14 @@ namespace JabyEngine {
|
|||
static constexpr auto Mode = CounterMode::with(CounterMode::FreeRun, Counter2::SyncMode::Freerun, CounterMode::ResetAfterTarget, CounterMode::IRQAtTarget, CounterMode::IRQEveryTime, CounterMode::IRQPulse, Counter2::Source::System_Clock_Div_8);
|
||||
static constexpr uint16_t Target = MS_Per_Tick<uint16_t>(CPU_Frequncey_Hz_Div8)*10;
|
||||
|
||||
printf("Timer2 Target: %i\n", Target);
|
||||
|
||||
Interrupt::disable_irq(Interrupt::Timer2);
|
||||
|
||||
__syscall_EnterCriticalSection();
|
||||
__syscall_SysEnqIntRP(Timer2Irq, &IRQCallback);
|
||||
__syscall_ExitCriticalSection();
|
||||
|
||||
Counter[2].target.write(CounterTarget::CounterTargetValue.with(Target));
|
||||
Counter[2].mode.write(Mode);
|
||||
Counter2::Timer.target.write(CounterTarget::CounterTargetValue.with(Target));
|
||||
Counter2::Timer.mode.write(Mode);
|
||||
|
||||
Interrupt::enable_irq(Interrupt::Timer2);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
uint32_t interrupt_handler(uint32_t) {
|
||||
GlobalTime::global_counter++;
|
||||
GlobalTime::global_counter = GlobalTime::global_counter + 1;
|
||||
|
||||
Interrupt::ack_irg(Interrupt::Timer2);
|
||||
__syscall_ReturnFromException();
|
||||
// v to make GCC happy
|
||||
return 0;
|
||||
}
|
||||
|
||||
InterrupCallback IRQCallback = {
|
||||
|
|
Loading…
Reference in New Issue