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 # Configuration files
config = gcc.cfg config = gcc.cfg
ifndef folder
folder = /usr/share/fxsdk
endif
#--- #---
# Automatic variables. # Automatic variables.
#--- #---
@ -206,5 +212,12 @@ distclean: mrproper
install: install:
p7 send -f $(target-g1a) 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 - Left-vram overflow when rendering text
- A few key hits ignored after leaving the application (could not reproduce) - A few key hits ignored after leaving the application (could not reproduce)
- Lost keyboard control at startup (could not reproduce) - Lost keyboard control at startup (could not reproduce)
- Back-light issues (0xa400012c on SH3, 0xa4050138 on SH4)
Simple improvements: Simple improvements:
- bopti: Monochrome bitmaps blending modes - bopti: Monochrome bitmaps blending modes
@ -14,6 +13,7 @@ Simple improvements:
- timer: Add duration and frequency settings - timer: Add duration and frequency settings
- core: Add VBR handlers debugging information (if possible) - core: Add VBR handlers debugging information (if possible)
- core: Implement all callbacks and a complete user API - core: Implement all callbacks and a complete user API
- project: Enhance Makefile install_lib rules
Modules to implement: Modules to implement:
- Serial communication - Serial communication

View file

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

View file

@ -56,8 +56,8 @@ static void kdelay(void)
/* /*
krow() krow()
Reads a keyboard row. Works like krow() for SH7705. See gint_7705.c for Reads a keyboard row. Works like krow() for SH7705; see source file
more details. keyboard_7705.c for more details.
*/ */
static int krow(int row) static int krow(int row)
{ {
@ -83,9 +83,9 @@ static int krow(int row)
*detector = 0xaaaa; *detector = 0xaaaa;
*key_register = 0xff; *key_register = 0xff;
*injector1 = (*injector1 & 0xf000) | 0x0555; *injector1 = (*injector1 & 0xf000) | 0x0555;
*injector2 = (*injector2 & 0xf000) | 0x0555; *injector2 = (*injector2 & 0xff00) | 0x0055;
*data1 |= 0x3f; *data1 |= 0x3f;
*data2 |= 0x3f; *data2 |= 0x0f;
kdelay(); kdelay();
if(row < 6) if(row < 6)
@ -94,11 +94,11 @@ static int krow(int row)
cmask = ~(1 << row); cmask = ~(1 << row);
*injector1 = ((*injector1 & 0xf000) | 0x0aaa) ^ smask; *injector1 = ((*injector1 & 0xf000) | 0x0aaa) ^ smask;
*injector2 = (*injector2 & 0xf000) | 0x0aaa; *injector2 = (*injector2 & 0xff00) | 0x00aa;
kdelay(); kdelay();
*data1 = (*data1 & 0xc0) | cmask; *data1 = (*data1 & 0xc0) | (cmask & 0x3f);
*data2 |= 0x3f; *data2 |= 0x0f;
kdelay(); kdelay();
} }
else else
@ -107,11 +107,11 @@ static int krow(int row)
cmask = ~(1 << (row - 6)); cmask = ~(1 << (row - 6));
*injector1 = (*injector1 & 0xf000) | 0x0aaa; *injector1 = (*injector1 & 0xf000) | 0x0aaa;
*injector2 = ((*injector2 & 0xf000) | 0x0aaa) ^ smask; *injector2 = ((*injector2 & 0xff00) | 0x00aa) ^ smask;
kdelay(); kdelay();
*data1 |= 0x3f; *data1 |= 0x3f;
*data2 = (*data2 & 0xc0) | cmask; *data2 = (*data2 & 0xf0) | (cmask & 0x0f);
kdelay(); kdelay();
} }
@ -121,13 +121,13 @@ static int krow(int row)
// Re-initializing the port configuration and data. // Re-initializing the port configuration and data.
*injector1 = (*injector1 & 0xf000) | 0x0aaa; *injector1 = (*injector1 & 0xf000) | 0x0aaa;
*injector2 = (*injector2 & 0xf000) | 0x0aaa; *injector2 = (*injector2 & 0xff00) | 0x00aa;
kdelay(); kdelay();
*injector1 = (*injector1 & 0xf000) | 0x0555; *injector1 = (*injector1 & 0xf000) | 0x0555;
*injector2 = (*injector2 & 0xf000) | 0x0555; *injector2 = (*injector2 & 0xff00) | 0x0055;
kdelay(); kdelay();
*data1 &= 0xc0; *data1 &= 0xc0;
*data2 &= 0xc0; *data2 &= 0xf0;
return result; 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; volatile struct mod_tmu *tmu;
timer_get(timer, &tmu, NULL); timer_get(timer, &tmu, NULL);
// Resetting the interrupt flag.
tmu->TCR.UNF = 0; tmu->TCR.UNF = 0;
// Calling the callback function.
if(timers[timer].callback) timers[timer].callback(); if(timers[timer].callback) timers[timer].callback();
// Reducing the number of repetitions left, if not infinite. // Reducing the number of repetitions left, if not infinite.
if(!timers[timer].repeats) return; if(!timers[timer].repeats) return;
// And stopping it if necessary.
if(timers[timer].repeats == 1) timer_stop(timer); if(timers[timer].repeats == 1) timer_stop(timer);
else timers[timer].repeats--; else timers[timer].repeats--;
} }