mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
added a small 10ms wait before turning on the backlight, thanks to profi for reminding me of that
This commit is contained in:
parent
f5a877d00b
commit
bcff09a389
@ -1,20 +1,29 @@
|
||||
#include <types.h>
|
||||
#include <arm.h>
|
||||
|
||||
#include "arm/gic.h"
|
||||
#include "arm/timer.h"
|
||||
|
||||
#define TIMER_INTERRUPT (0x1E)
|
||||
|
||||
#define REG_TIMER(c, n) REG_ARM_PMR(0x700 + ((c) * 0x100) + (n), u32)
|
||||
#define TIMER_THIS_CPU (-1)
|
||||
|
||||
#define REG_TIMER_LOAD(c) *REG_TIMER((c), 0x00)
|
||||
#define REG_TIMER_COUNT(c) *REG_TIMER((c), 0x04)
|
||||
#define REG_TIMER_CNT(c) *REG_TIMER((c), 0x08)
|
||||
#define REG_TIMER_IRQ(c) *REG_TIMER((c), 0x0C)
|
||||
|
||||
#define TIMER_CNT_SCALE(n) ((n) << 8)
|
||||
#define TIMER_CNT_INT_EN BIT(2)
|
||||
#define TIMER_CNT_RELOAD BIT(1)
|
||||
#define TIMER_CNT_ENABLE BIT(0)
|
||||
#include <types.h>
|
||||
#include <arm.h>
|
||||
|
||||
#include "arm/gic.h"
|
||||
#include "arm/timer.h"
|
||||
|
||||
#define TIMER_INTERRUPT (0x1E)
|
||||
|
||||
#define REG_TIMER(c, n) REG_ARM_PMR(0x700 + ((c) * 0x100) + (n), u32)
|
||||
#define TIMER_THIS_CPU (-1)
|
||||
|
||||
#define REG_TIMER_LOAD(c) *REG_TIMER((c), 0x00)
|
||||
#define REG_TIMER_COUNT(c) *REG_TIMER((c), 0x04)
|
||||
#define REG_TIMER_CNT(c) *REG_TIMER((c), 0x08)
|
||||
#define REG_TIMER_IRQ(c) *REG_TIMER((c), 0x0C)
|
||||
|
||||
#define TIMER_CNT_SCALE(n) ((n) << 8)
|
||||
#define TIMER_CNT_INT_EN BIT(2)
|
||||
#define TIMER_CNT_RELOAD BIT(1)
|
||||
#define TIMER_CNT_ENABLE BIT(0)
|
||||
|
||||
void TIMER_WaitTicks(u32 ticks)
|
||||
{
|
||||
REG_TIMER_IRQ(TIMER_THIS_CPU) = 1;
|
||||
REG_TIMER_CNT(TIMER_THIS_CPU) = 0;
|
||||
REG_TIMER_LOAD(TIMER_THIS_CPU) = ticks;
|
||||
REG_TIMER_CNT(TIMER_THIS_CPU) = TIMER_CNT_ENABLE;
|
||||
while(REG_TIMER_COUNT(TIMER_THIS_CPU));
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
// The timer interval is calculated using the following equation:
|
||||
// T = [(PRESCALER_value + 1) * (Load_value + 1) * 2] / CPU_CLK
|
||||
// therefore
|
||||
// Load_value = [(CPU_CLK / 2) * (T / (PRESCALER_value + 1))] - 1
|
||||
|
||||
#define BASE_CLKRATE (268111856)
|
||||
|
||||
#define CLK_FREQ_TO_INTERVAL(f, p) ((BASE_CLKRATE/2) * ((f) / ((p) + 1)) - 1)
|
||||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
// The timer interval is calculated using the following equation:
|
||||
// T = [(PRESCALER_value + 1) * (Load_value + 1) * 2] / CPU_CLK
|
||||
// therefore
|
||||
// Load_value = [(CPU_CLK / 2) * (T / (PRESCALER_value + 1))] - 1
|
||||
|
||||
#define BASE_CLKRATE (268111856 / 2)
|
||||
|
||||
#define CLK_MS_TO_TICKS(m) (((BASE_CLKRATE / 1000) * (m)) - 1)
|
||||
|
||||
void TIMER_WaitTicks(u32 ticks);
|
||||
|
@ -4,8 +4,9 @@
|
||||
#include <pxi.h>
|
||||
|
||||
#include "arm/gic.h"
|
||||
#include "arm/scu.h"
|
||||
#include "arm/mmu.h"
|
||||
#include "arm/scu.h"
|
||||
#include "arm/timer.h"
|
||||
|
||||
#include "hw/gpulcd.h"
|
||||
#include "hw/i2c.h"
|
||||
@ -93,6 +94,8 @@ void SYS_CoreZeroInit(void)
|
||||
|
||||
GPU_SetFramebufferMode(0, PDC_RGB24);
|
||||
GPU_SetFramebufferMode(1, PDC_RGB24);
|
||||
|
||||
TIMER_WaitTicks(CLK_MS_TO_TICKS(10));
|
||||
MCU_WriteReg(0x22, 0x2A);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user