Solved backlight issues and added backlight control to the API.

This commit is contained in:
lephe 2016-12-22 18:36:39 +01:00
parent 28748a820c
commit e6e0989436
6 changed files with 56 additions and 19 deletions

View File

@ -50,6 +50,12 @@ obj-std-spec =
# Configuration files
config = gcc.cfg
ifndef folder
folder = /usr/share/fxsdk
endif
#---
# Automatic variables.
#---
@ -206,5 +212,12 @@ distclean: mrproper
install:
p7 send -f $(target-g1a)
install_lib: $(target-std) $(target-lib)
mkdir -p $(folder)
install -m 644 $^ $(folder)
install -m 644 -T demo/gintdemo.ld $(folder)/linker.ld
mkdir -p $(folder)/gint
install -m 644 include/*.h $(folder)/gint
@ printf '\e[32;1mmsg \u00bb\e[0m All installed!\n'
.PHONY: all clean mrproper distclean install help
.PHONY: all clean mrproper distclean install install_lib help

2
TODO
View File

@ -2,7 +2,6 @@ Bugs to fix:
- Left-vram overflow when rendering text
- A few key hits ignored after leaving the application (could not reproduce)
- Lost keyboard control at startup (could not reproduce)
- Back-light issues (0xa400012c on SH3, 0xa4050138 on SH4)
Simple improvements:
- bopti: Monochrome bitmaps blending modes
@ -14,6 +13,7 @@ Simple improvements:
- timer: Add duration and frequency settings
- core: Add VBR handlers debugging information (if possible)
- core: Implement all callbacks and a complete user API
- project: Enhance Makefile install_lib rules
Modules to implement:
- Serial communication

View File

@ -20,4 +20,10 @@
*/
void screen_display(const void *vram);
/*
screen_setBacklight()
On compatible models, turns on or turns off the backlight.
*/
void screen_setBacklight(int on);
#endif

View File

@ -56,8 +56,8 @@ static void kdelay(void)
/*
krow()
Reads a keyboard row. Works like krow() for SH7705. See gint_7705.c for
more details.
Reads a keyboard row. Works like krow() for SH7705; see source file
keyboard_7705.c for more details.
*/
static int krow(int row)
{
@ -75,7 +75,7 @@ static int krow(int row)
unsigned short smask;
unsigned char cmask;
int result = 0;
int result = 0;
if(row < 0 || row > 9) return 0;
@ -83,9 +83,9 @@ static int krow(int row)
*detector = 0xaaaa;
*key_register = 0xff;
*injector1 = (*injector1 & 0xf000) | 0x0555;
*injector2 = (*injector2 & 0xf000) | 0x0555;
*injector2 = (*injector2 & 0xff00) | 0x0055;
*data1 |= 0x3f;
*data2 |= 0x3f;
*data2 |= 0x0f;
kdelay();
if(row < 6)
@ -94,11 +94,11 @@ static int krow(int row)
cmask = ~(1 << row);
*injector1 = ((*injector1 & 0xf000) | 0x0aaa) ^ smask;
*injector2 = (*injector2 & 0xf000) | 0x0aaa;
*injector2 = (*injector2 & 0xff00) | 0x00aa;
kdelay();
*data1 = (*data1 & 0xc0) | cmask;
*data2 |= 0x3f;
*data1 = (*data1 & 0xc0) | (cmask & 0x3f);
*data2 |= 0x0f;
kdelay();
}
else
@ -107,11 +107,11 @@ static int krow(int row)
cmask = ~(1 << (row - 6));
*injector1 = (*injector1 & 0xf000) | 0x0aaa;
*injector2 = ((*injector2 & 0xf000) | 0x0aaa) ^ smask;
*injector2 = ((*injector2 & 0xff00) | 0x00aa) ^ smask;
kdelay();
*data1 |= 0x3f;
*data2 = (*data2 & 0xc0) | cmask;
*data2 = (*data2 & 0xf0) | (cmask & 0x0f);
kdelay();
}
@ -121,13 +121,13 @@ static int krow(int row)
// Re-initializing the port configuration and data.
*injector1 = (*injector1 & 0xf000) | 0x0aaa;
*injector2 = (*injector2 & 0xf000) | 0x0aaa;
*injector2 = (*injector2 & 0xff00) | 0x00aa;
kdelay();
*injector1 = (*injector1 & 0xf000) | 0x0555;
*injector2 = (*injector2 & 0xf000) | 0x0555;
*injector2 = (*injector2 & 0xff00) | 0x0055;
kdelay();
*data1 &= 0xc0;
*data2 &= 0xc0;
*data2 &= 0xf0;
return result;
}

View File

@ -0,0 +1,22 @@
#include <screen.h>
#include <mpu.h>
/*
screen_setBacklight()
On compatible models, turns on or turns off the backlight.
*/
void screen_setBacklight(int on)
{
if(isSH3())
{
volatile unsigned char *PGDR = (void *)0xa400012c;
if(on) *PGDR |= 0x80;
else *PGDR &= ~0x80;
}
else
{
volatile unsigned char *PNDR = (void *)0xa4050138;
if(on) *PNDR |= 0x10;
else *PNDR &= ~0x10;
}
}

View File

@ -14,15 +14,11 @@ void timer_interrupt(int timer)
volatile struct mod_tmu *tmu;
timer_get(timer, &tmu, NULL);
// Resetting the interrupt flag.
tmu->TCR.UNF = 0;
// Calling the callback function.
if(timers[timer].callback) timers[timer].callback();
// Reducing the number of repetitions left, if not infinite.
if(!timers[timer].repeats) return;
// And stopping it if necessary.
if(timers[timer].repeats == 1) timer_stop(timer);
else timers[timer].repeats--;
}