TS-8390-47XX Backlight

From embeddedTS Manuals

The backlight brightness on our off the shelf LCD products use the LCD_PWM output. This example takes an integer percentage as the only argument which will set the brightness.

/* Compile with:
 * gcc name.c -o output -mcpu=arm9
 */
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>

volatile uint32_t *mvpwmregs = 0;
void set_brightness(int pct) 
{
	if(mvpwmregs == 0) {
		int mem = open("/dev/mem", O_RDWR|O_SYNC);
		assert(mem != -1);
		mvpwmregs = (unsigned int *) mmap(0, 4096,
	  	  PROT_READ | PROT_WRITE, MAP_SHARED, mem, 0xd401a000);
	}

	// duty cycle floor is 57, max is 128
	mvpwmregs[0x004/4] = 57 + ((pct * 71)/100);
}

int main(int argc, char **argv)
{
	set_brightness(atoi(argv[1]));
	return 0;
}